[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    Re: gc-sections requires either an entry or an undefined symbol
From:       Denys Vlasenko <vda.linux () googlemail ! com>
Date:       2012-01-31 15:07:17
Message-ID: CAK1hOcPo8nDErw568ZOG_Yk-dSOAJmFdx3UojAY30QE1qJhwfg () mail ! gmail ! com
[Download RAW message or body]

On Tue, Jan 31, 2012 at 3:33 PM, stl <st.lambert02@gmail.com> wrote:
>>
>> This version should be ok. Versions before 2.18 were buggy.
>>
>> Can you give a more detailed description of what you are doing
>> than mere "I am trying to statically build busybox-1.19.3"?
>
> Ok. I am porting Linux for a new architecture.
> Of course, I am unable to pass the romfs mounting step, because my
> Linux system is not built.
> So I have built a uClibc cross-compiler and now I need to built my romfs
> image with busybox apps.
> I am trying to build busybox with this cross-compiler,
> and I want (at the moment) build static applications.
>
>> What .config do you use? Do you pass any variables such as
>> EXTRA_CFLAGS to make?
>
> I need -G0 and -fsrodata-size=0 as extra cflags.
> But the problem with gc-sections appears even if I try to compile
> without them.
>
>> Does just "make defconfig; make" work for you?
>
> Indeed, the build behaves differently with make defconfig; make.
> It is clearly when I set the CONFIG_CROSS_COMPILER_PREFIX option
> that I obtain the
> "gc-sections requires either an entry or an undefined symbol"
> error.

I suggest:
- set "debug=true" in scripts/trylink
- run make V=1 and save the command used for linking.
  Example:

Trying: i486-linux-uclibc-gcc -Wall -Wshadow -Wwrite-strings -Wundef
-Wstrict-prototypes -Wunused -Wunused-parameter -Wunused-function
-Wunused-value -Wmissing-prototypes -Wmissing-declarations
-Wdeclaration-after-statement -Werror -Wold-style-definition
-fno-builtin-strlen -finline-limit=0 -fomit-frame-pointer
-ffunction-sections -fdata-sections -fno-guess-branch-probability
-funsigned-char -static-libgcc -falign-functions=1 -falign-jumps=1
-falign-labels=1 -falign-loops=1 -Os -march=i386
-mpreferred-stack-boundary=2 -static -o busybox_unstripped
-Wl,--sort-common -Wl,--sort-section,alignment -Wl,--gc-sections
-Wl,--start-group applets/built-in.o archival/lib.a
archival/libarchive/lib.a console-tools/lib.a coreutils/lib.a
coreutils/libcoreutils/lib.a debianutils/lib.a e2fsprogs/lib.a
editors/lib.a findutils/lib.a init/lib.a libbb/lib.a libpwdgrp/lib.a
loginutils/lib.a mailutils/lib.a miscutils/lib.a modutils/lib.a
networking/lib.a networking/libiproute/lib.a networking/udhcp/lib.a
printutils/lib.a procps/lib.a runit/lib.a selinux/lib.a shell/lib.a
sysklogd/lib.a util-linux/lib.a util-linux/volume_id/lib.a
archival/built-in.o archival/libarchive/built-in.o
console-tools/built-in.o coreutils/built-in.o
coreutils/libcoreutils/built-in.o debianutils/built-in.o
e2fsprogs/built-in.o editors/built-in.o findutils/built-in.o
init/built-in.o libbb/built-in.o libpwdgrp/built-in.o
loginutils/built-in.o mailutils/built-in.o miscutils/built-in.o
modutils/built-in.o networking/built-in.o
networking/libiproute/built-in.o networking/udhcp/built-in.o
printutils/built-in.o procps/built-in.o runit/built-in.o
selinux/built-in.o shell/built-in.o sysklogd/built-in.o
util-linux/built-in.o util-linux/volume_id/built-in.o -Wl,--end-group
-Wl,--start-group -lm -Wl,--end-group -Wl,--warn-common
-Wl,-Map,busybox_unstripped.map -Wl,--verbose

Run it with -v, so that you see ld invocation and much more.

 /usr/app/gcc-4.3.1-i486-linux-uclibc/libexec/gcc/i486-linux-uclibc/4.3.1/collect2
--sysroot=/usr/cross/i486-linux-uclibc -m elf_i386 -static -o
busybox_unstripped /usr/cross/i486-linux-uclibc/lib/crt1.o
/usr/cross/i486-linux-uclibc/lib/crti.o
/usr/app/gcc-4.3.1-i486-linux-uclibc/lib/gcc/i486-linux-uclibc/4.3.1/crtbeginT.o
-L ... ... ...
...
...
...

For example, I see ENTRY(_start) in ld output:

...
using internal linker script:
==================================================
/* Script for -z combreloc: combine and sort reloc sections */
OUTPUT_FORMAT("elf32-i386", "elf32-i386",
              "elf32-i386")
OUTPUT_ARCH(i386)
ENTRY(_start)      <===================== HERE
SEARCH_DIR("=/usr/local/lib"); SEARCH_DIR("=/lib"); SEARCH_DIR("=/usr/lib");
...

and "objdump -drsx /usr/cross/i486-linux-uclibc/lib/crt1.o"
indeed tells me that symbol _start exists in one of the files
passed to linker.

Do something like this on the failing build and investigate
why linker can't find the program starting point.

-- 
vda
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic