Re: Bare metal ARM Cross compiler for arm-none-eabi target without libunwind?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


Hi

Sorry I maybe did not describe my problem clear enough.
It is not primary the gcc-toolchain that doesn't build.
It is the built bare metal arm libgcc that does not contain all symbols, and does not link with out compiled binary.

This is what the linker output

Linking sniffer2.elf ..
/usr/local/gcc/arm-elf-tools-4.7.0/lib/gcc/arm-none-eabi/4.7.0/thumb//libgcc.a(unwind-arm.o): In function `get_eit_entry':
/home/fredrikh/arm_toolchain/toolchain-4.7.0/build/gcc/arm-none-eabi/thumb/libgcc/../../../../../gcc-4.7.0/libgcc/unwind-arm-common.inc:275: undefined reference to `__exidx_start'
/home/fredrikh/arm_toolchain/toolchain-4.7.0/build/gcc/arm-none-eabi/thumb/libgcc/../../../../../gcc-4.7.0/libgcc/unwind-arm-common.inc:275: undefined reference to `__exidx_end'
/usr/local/gcc/arm-elf-tools-4.7.0/lib/gcc/arm-none-eabi/4.7.0/thumb//libgcc.a(unwind-arm.o): In function `unwind_phase2_forced':
/home/fredrikh/arm_toolchain/toolchain-4.7.0/build/gcc/arm-none-eabi/thumb/libgcc/../../../../../gcc-4.7.0/libgcc/unwind-arm-common.inc:319: undefined reference to `memcpy'
/home/fredrikh/arm_toolchain/toolchain-4.7.0/build/gcc/arm-none-eabi/thumb/libgcc/../../../../../gcc-4.7.0/libgcc/unwind-arm-common.inc:346: undefined reference to `memcpy'
/home/fredrikh/arm_toolchain/toolchain-4.7.0/build/gcc/arm-none-eabi/thumb/libgcc/../../../../../gcc-4.7.0/libgcc/unwind-arm-common.inc:376: undefined reference to `memcpy'
/usr/local/gcc/arm-elf-tools-4.7.0/lib/gcc/arm-none-eabi/4.7.0/thumb//libgcc.a(unwind-arm.o): In function `unwind_phase2':
/home/fredrikh/arm_toolchain/toolchain-4.7.0/build/gcc/arm-none-eabi/thumb/libgcc/../../../../../gcc-4.7.0/libgcc/unwind-arm-common.inc:289: undefined reference to `abort'
/usr/local/gcc/arm-elf-tools-4.7.0/lib/gcc/arm-none-eabi/4.7.0/thumb//libgcc.a(unwind-arm.o): In function `__gnu_Unwind_RaiseException':
/home/fredrikh/arm_toolchain/toolchain-4.7.0/build/gcc/arm-none-eabi/thumb/libgcc/../../../../../gcc-4.7.0/libgcc/unwind-arm-common.inc:420: undefined reference to `memcpy'
/usr/local/gcc/arm-elf-tools-4.7.0/lib/gcc/arm-none-eabi/4.7.0/thumb//libgcc.a(unwind-arm.o): In function `__gnu_Unwind_Resume':
/home/fredrikh/arm_toolchain/toolchain-4.7.0/build/gcc/arm-none-eabi/thumb/libgcc/../../../../../gcc-4.7.0/libgcc/unwind-arm-common.inc:505: undefined reference to `abort'
/usr/local/gcc/arm-elf-tools-4.7.0/lib/gcc/arm-none-eabi/4.7.0/thumb//libgcc.a(unwind-arm.o): In function `__gnu_Unwind_Backtrace':
/home/fredrikh/arm_toolchain/toolchain-4.7.0/build/gcc/arm-none-eabi/thumb/libgcc/../../../../../gcc-4.7.0/libgcc/unwind-arm-common.inc:560: undefined reference to `memcpy'
/usr/local/gcc/arm-elf-tools-4.7.0/lib/gcc/arm-none-eabi/4.7.0/thumb//libgcc.a(pr-support.o): In function `_Unwind_GetDataRelBase':
/home/fredrikh/arm_toolchain/toolchain-4.7.0/build/gcc/arm-none-eabi/thumb/libgcc/../../../../../gcc-4.7.0/libgcc/config/arm/pr-support.c:394: undefined reference to `abort'
/usr/local/gcc/arm-elf-tools-4.7.0/lib/gcc/arm-none-eabi/4.7.0/thumb//libgcc.a(pr-support.o): In function `_Unwind_GetTextRelBase':
/home/fredrikh/arm_toolchain/toolchain-4.7.0/build/gcc/arm-none-eabi/thumb/libgcc/../../../../../gcc-4.7.0/libgcc/config/arm/pr-support.c:400: undefined reference to `abort'
make[1]: *** [../../../build/sniffer2/sniffer2.elf] Error 1
make[1]: Leaving directory `/home/fredrikh/workspace/product/app/sniffer2'
make: *** [all] Error 2

The first problem with __exidx_start we could try workaround by adding a few lines to linker-script.

__exidx_start = .;
.ARM.exidx   : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) }
__exidx_end = .;

But since we have an extreme bare metal system with custom memcpy(), no abort() etc,
the libgcc does not link.

We've tried to compile all files without unwind info nor exceptions.

If we build toolchain with 'arm-elf' taget instead, it works fine.

I submit script to build non-working toolchain.
If we just change to "TARGET=arm-none-elf" instead and add "--enable-obsolete" to configure, then it works fine.
It seems to TARGET=arm-none-eabi" introduces dependencies of libc functions like memcpy() and abort() that did not excist in previous versions.
Also I don't understand how I could work-around these dependencies or get rid of them.

------------- SCRIPT START BUILD TOOLCHAIN ARM EABI -------------
#!/bin/sh

set -e -x 

TARGET=arm-none-eabi

BINUTILS_VERSION=2.22
GCC_VERSION=4.7.0
NEWLIB_VERSION=1.20.0

DEST="/usr/local/gcc/arm-elf-tools-$GCC_VERSION"

BINUTILS_DIR="binutils-$BINUTILS_VERSION" 
GCC_DIR="gcc-$GCC_VERSION" 
NEWLIB_DIR="newlib-$NEWLIB_VERSION" 

# set rwx access

umask 022 

# unpack tar-balls

rm -fr "$BINUTILS_DIR" "$GCC_DIR" "$NEWLIB_DIR"
tar xvjf "binutils-$BINUTILS_VERSION.tar.bz2" 
tar xvjf "gcc-$GCC_VERSION.tar.bz2" 
tar xvzf "newlib-$NEWLIB_VERSION.tar.gz" 

cd "$GCC_DIR"
ln -s "../$NEWLIB_DIR/newlib" newlib 
ln -s "../$NEWLIB_DIR/libgloss" libgloss 
cd ..

rm -fr build 
mkdir -p build/binutils build/gcc build/newlib

# Build binutils

cd build/binutils 
"../../$BINUTILS_DIR/configure" --target="$TARGET" --prefix="$DEST" --disable-nls
make LDFLAGS=-s all install 

# Build GCC

cd ../gcc 
PATH="$DEST/bin:$PATH" 
"../../$GCC_DIR/configure" --enable-languages=c --target="$TARGET" --prefix="$DEST" --with-gnu-as --with-gnu-ld --disable-nls --disable-shared --with-newlib --disable-libunwind-exceptions --enable-target-optspace
make LDFLAGS=-s all all-gcc install install-gcc

# Remove uncompressed sources

cd ../.. 
rm -fr "$BINUTILS_DIR" "$GCC_DIR" "$NEWLIB_DIR" build

------------- SCRIPT END -------------

Thanks and Best Regards/Fredrik




-----Ian Lance Taylor <iant@xxxxxxxxxx> wrote: -----

>To: Fredrik Hederstierna <fredrik.hederstierna@xxxxxxxxxxxxxxxxxxxx>
>From: Ian Lance Taylor <iant@xxxxxxxxxx>
>Date: 03/26/2012 10:53PM
>Cc: gcc-help@xxxxxxxxxxx
>Subject: Re: Bare metal ARM Cross compiler for arm-none-eabi target
>without libunwind?
>
>Fredrik Hederstierna <fredrik.hederstierna@xxxxxxxxxxxxxxxxxxxx>
>writes:  > Now when we try to build GCC 4.7.0 we get errors that
>LibGCC has dependencies on UnWind stuff we cannot get rid of.  Please
>always tell us the exact error messages.  When we have to guess what
>is going wrong, we often guess wrong.  In fact in this case I can't
>even guess.  It's true that libgcc includes code for stack unwinding,
>but I can't think of any reason why that should matter when you are
>building gcc.  Ian 



[Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

Add to Google