I found the solution based on the discussion available at https://unix.stackexchange.com/questions/377345/installing-arm-none-eabi-gcc and the documentation available on https://mynewt.apache.org/latest/get_started/native_install/cross_tools.html#installing-the-arm-cross-toolchain.

The name and structure of the software changed over time. The arm-none-eabi-gcc is gcc-arm-none-eabi now, and so on.

$ sudo apt-get remove binutils-arm-none-eabi gcc-arm-none-eabi
$ sudo add-apt-repository ppa:team-gcc-arm-embedded/ppa
$ sudo apt-get update 
$ sudo apt-get upgrade
$ sudo apt-get install gcc-arm-none-eabi
$ sudo apt-get install gdb-arm-none-eabi 

And finally, to verify the downloads, you can run the following commands:

arm-none-eabi-gcc --version
arm-none-eabi-g++ --version
arm-none-eabi-size --version 
Answer from Aatif Shaikh on Stack Overflow
🌐
Arch Linux
archlinux.org › packages › extra › any › arm-none-eabi-newlib
Arch Linux - arm-none-eabi-newlib 4.5.0.20241231-2 (any)
View the file list for arm-none-eabi-newlib · View the soname list for arm-none-eabi-newlib · Copyright © 2002-2026 Judd Vinet, Aaron Griffin and Levente Polyák. The Arch Linux name and logo are recognized trademarks. Some rights reserved.
🌐
Arm Community
community.arm.com › support-forums › f › compilers-and-libraries-forum › 53310 › gcc-arm-none-eabi-what-were-the-newlib-compilation-options
gcc-arm-none-eabi: what were the Newlib compilation ...
August 4, 2022 - Have a question about working on Arm technology? Browse our support forums for solutions to your questions, answer questions from fellow community members and get help from Arm experts.
🌐
Debian
packages.debian.org › sid › libnewlib-arm-none-eabi
Details of package libnewlib-arm-none-eabi in sid
JavaScript is disabled in your browser · Please enable JavaScript to proceed · A required part of this site couldn’t load. This may be due to a browser extension, network issues, or browser settings. Please check your connection, disable any ad blockers, or try using a different browser
🌐
GitHub
github.com › ARMmbed › homebrew-formulae › issues › 24
Does arm-none-eabi-gcc provide gdb, newlib, binutils? · Issue #24 · ARMmbed/homebrew-formulae
May 14, 2019 - I downloaded https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-rm/8-2018q4/gcc-arm-none-eabi-8-2018-q4-major-mac.tar.bz2 and unzipped it and found it does indeed include arm-none-eabi-objcopy, arm-none-eabi-objdump, arm-none-eabi-strings, arm-none-eabi-strings and all the rest of binutils, and even arm-none-eabi-gdb. I can't tell if it has newlib, there's a newlib.h, but the rest of the library doesn't seem to be there.
Published   May 14, 2019
Author   kousu
🌐
Alpine Linux
pkgs.alpinelinux.org › package › edge › community › x86_64 › newlib-arm-none-eabi
newlib-arm-none-eabi - Alpine Linux packages
g++-arm-none-eabi · newlib · qmk-cli · Sub Packages (5) newlib-aarch64-none-elf · newlib-arm-none-eabi · newlib-msp430-elf · newlib-or1k-elf · newlib-riscv-none-elf · Provides (0) None ·
🌐
Debian
packages.debian.org › sid › libstdc++-arm-none-eabi-newlib
Details of package libstdc++-arm-none-eabi-newlib in sid
JavaScript is disabled in your browser · Please enable JavaScript to proceed · A required part of this site couldn’t load. This may be due to a browser extension, network issues, or browser settings. Please check your connection, disable any ad blockers, or try using a different browser
🌐
Ubuntu
launchpad.net › ubuntu › jammy › +package › libnewlib-arm-none-eabi
libnewlib-arm-none-eabi : Jammy (22.04) : Ubuntu - Launchpad
libnewlib-arm-none-eabi · Newlib is a C library and math library intended for use on embedded systems. It is a conglomeration of several library parts, all under free software licenses that make them easily usable on embedded products.
🌐
Debian
packages.debian.org › sid › devel › libstdc++-arm-none-eabi-newlib
Debian -- Details of package libstdc++-arm-none-eabi-newlib in sid
picolibc-arm-none-eabi · python3-pyocd · libstdc++6-arm64-cross · GNU Standard C++ library for embedded ARM chips using Cortex-M, and Cortex-R processors. This library is built using newlib as standard C library. dep: gcc-arm-none-eabi (= 15:14.2.rel1-1) GCC cross compiler for ARM Cortex-R/M ...
🌐
FreshPorts
freshports.org › devel › arm-none-eabi-newlib
FreshPorts -- devel/arm-none-eabi-newlib: Newlib distribution for arm-none-eabi targets
October 16, 2016 - Newlib is a C library intended for use on embedded systems. It is a conglomeration of several library parts, all under free software licenses, that make them easily usable on embedded products.
Find elsewhere
🌐
Fedora
packages.fedoraproject.org › pkgs › arm-none-eabi-newlib › arm-none-eabi-newlib
arm-none-eabi-newlib - Fedora Packages
View arm-none-eabi-newlib in the Fedora package repositories. arm-none-eabi-newlib: C library intended for use on arm-none-eabi embedded systems
🌐
Debian
packages.debian.org › sid › libs › libnewlib-arm-none-eabi
Debian -- Details of package libnewlib-arm-none-eabi in sid
This package contains the newlib library compiled for Cortex-A*, Cortex-R4/R5/R7 and Cortex-M0/M0+/M3/M4 targets. Tags: Role: Shared Library · dep: libnewlib-dev (= 4.5.0.20241231-1) C library and math library intended for use on embedded systems · rec: gcc-arm-none-eabi ·
🌐
MSYS2
packages.msys2.org › packages › mingw-w64-x86_64-arm-none-eabi-newlib
Package: mingw-w64-x86_64-arm-none-eabi-newlib - MSYS2 Packages
mingw-w64-arm-none-eabi-newlib · Description: GNU Tools for ARM Embedded Processors - Newlib (mingw-w64) Group(s): mingw-w64-x86_64-arm-none-eabi-toolchain · Repo: mingw64 · Homepage: https://sourceware.org/newlib/ License(s): GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-2.1-or-later AND LGPL-3.0-only AND 0BSD AND BSD-2-Clause AND BSD-3-Clause-Clear AND custom ·
🌐
Ubuntu
launchpad.net › ubuntu › noble › +package › libstdc++-arm-none-eabi-newlib
libstdc++-arm-none-eabi-newlib : Noble (24.04) - Launchpad
GNU Standard C++ library for embedded ARM chips using Cortex-M, and Cortex-R processors. . This library is built using newlib as standard C library. libstdc++-arm-none-eabi 26 source package in Ubuntu
Top answer
1 of 3
15

If i understand you correctly, a more detailed question is:
What configure options did 'GNU Arm Embedded Toolchain' developers used when building newlib libraries shipped in gcc-arm-none-eabi-6-2017-q2-update-linux.tar.bz2 archive?
These ones for newlib:

--target=arm-none-eabi --enable-newlib-io-long-long --enable-newlib-register-fini --enable-newlib-retargetable-locking --disable-newlib-supplied-syscalls --disable-nls

And these ones for newlib-nano:

--target=arm-none-eabi --enable-newlib-reent-small --disable-newlib-fvwrite-in-streamio --disable-newlib-fseek-optimization --disable-newlib-wide-orient --enable-newlib-nano-malloc --disable-newlib-unbuf-stream-opt --enable-lite-exit --enable-newlib-global-atexit --enable-newlib-nano-formatted-io --disable-nls

How I got it? Let's walk through the process:
These packages are build on launchpad, where from you find all the builds that took place on lanuchpad. I picked gcc-arm-none-eabi 6-2017q2-1 from 2017-10-24. There i can find the buildlog. I grepped the buildlog with | grep "^+ " | grep "configure " | grep 'src/newlib' and i was left with:

+ /<<PKGBUILDDIR>>/src/newlib/configure --target=arm-none-eabi --prefix=/<<PKGBUILDDIR>>/install-native --infodir=/<<PKGBUILDDIR>>/install-native/share/doc/gcc-arm-none-eabi/info --mandir=/<<PKGBUILDDIR>>/install-native/share/doc/gcc-arm-none-eabi/man --htmldir=/<<PKGBUILDDIR>>/install-native/share/doc/gcc-arm-none-eabi/html --pdfdir=/<<PKGBUILDDIR>>/install-native/share/doc/gcc-arm-none-eabi/pdf --enable-newlib-io-long-long --enable-newlib-register-fini --enable-newlib-retargetable-locking --disable-newlib-supplied-syscalls --disable-nls + /<<PKGBUILDDIR>>/src/newlib/configure --target=arm-none-eabi --prefix=/<<PKGBUILDDIR>>/build-native/target-libs --disable-newlib-supplied-syscalls --enable-newlib-reent-small --disable-newlib-fvwrite-in-streamio --disable-newlib-fseek-optimization --disable-newlib-wide-orient --enable-newlib-nano-malloc --disable-newlib-unbuf-stream-opt --enable-lite-exit --enable-newlib-global-atexit --enable-newlib-nano-formatted-io --disable-nls

A bit of Sherlock Holmes and i deduced that the second line is newlib configured to build as newlib-nano (--enable-newlib-reent-small), the first is newlib configured to build as full newlib.
To answer your topic question, to recompile newlib and newlib-nano the same way pass the options I have posted above to newlib ./configure script.

2 of 3
3

Hints about how the compiler was configured are found in:

  • $COMPILER_PATH/arm-none-eabi/include/newlib.h
  • $COMPILER_PATH/arm-none-eabi/include/newlib-nano/newlib.h

The #defines there have a close correspondence to the options that were passed to 'configure', when newlib was built.

Top answer
1 of 1
2

First of all, __libc_init_array() belongs inside extern "C". The map file you have above has it correct: it gets pulled in from libc_nano.a(lib_a-init.o).

This is not really the problem though. In your vector table, you have Reset_Handler where you should have the initial value of the stack pointer, and main where you should have the reset handler. main should never be in the vector, it is called by the reset handler as a normal function, not through the vector.

The crash you are having is most likely because you don't have a correct stack pointer, and the code is trying to use the stack.

Also, the first thing you do in your reset handler is call __libc_init_array. This is wrong. You need to (at least) copy the initialized data and zero the bss section first. If you are following the CMSIS pattern then you also need to call SystemInit. See the sample startup code and linker scripts in the STM32CubeF4 package.

EDIT: The above problems are in your pseudocode; the code doesn't match the pseudocode and doesn't have the above problems.

The next problem is that you have deleted half of the standard linker script. Try looking at the source of __libc_init_array to see what it needs. It needs the init array sections etc.

Here is an example with them in:

.init :
{
  KEEP (*(SORT_NONE(.init)))
}
>FLASH

.text :
{
  *(.text .text.* .stub .gnu.linkonce.t.*)
}
>FLASH

.fini :
{
  KEEP (*(SORT_NONE(.fini)))
}
>FLASH

.preinit_array :
{
  PROVIDE_HIDDEN (__preinit_array_start = .);
  KEEP (*(.preinit_array))
  PROVIDE_HIDDEN (__preinit_array_end = .);
}
>FLASH

.init_array :
{
  PROVIDE_HIDDEN (__init_array_start = .);
  KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
  KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))
  PROVIDE_HIDDEN (__init_array_end = .);
}
>FLASH

.fini_array :
{
  PROVIDE_HIDDEN (__fini_array_start = .);
  KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
  KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))
  PROVIDE_HIDDEN (__fini_array_end = .);
}
>FLASH

.ctors :
{
  KEEP (*crtbegin.o(.ctors))
  KEEP (*crtbegin?.o(.ctors))
  KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
  KEEP (*(SORT(.ctors.*)))
  KEEP (*(.ctors))
}
>FLASH

.dtors :
{
  KEEP (*crtbegin.o(.dtors))
  KEEP (*crtbegin?.o(.dtors))
  KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
  KEEP (*(SORT(.dtors.*)))
  KEEP (*(.dtors))
}
>FLASH
🌐
Arch Linux
archlinux.org › packages › extra › x86_64 › arm-none-eabi-gcc
Arch Linux - arm-none-eabi-gcc 14.2.0-2 (x86_64)
arm-none-eabi-newlib (optional) - Standard C library optimized for embedded systems · arm-none-eabi-newlib (make) gmp (make) mpfr (make) qmk · klipper (optional) arm-none-eabi-newlib (make) easy-pdk (make) efifs (make) libopencm3 (make) proxmark3 (make) View the file list for arm-none-eabi-gcc ·
🌐
MacPorts
trac.macports.org › ticket › 51397
#51397 (Newlib nano support for arm-none-eabi-gcc toolchain) – MacPorts
Create a arm-none-eabi-newlib-nano Portfile to add *_nano.a files. To do it I recompile a gcc+newlib with specific configure option + -Os optimization.
🌐
Ubuntu
packages.ubuntu.com › focal › libs › libnewlib-arm-none-eabi
Details of package libnewlib-arm-none-eabi in focal
two or more packages specified (libnewlib-arm-none-eabi focal) Content Copyright © 2025 Canonical Ltd.; See license terms. Ubuntu is a trademark of Canonical Ltd. Learn more about this site.