Hello,

On Sat, 15 Jul 2017 14:44:21 +0200, Denys Vlasenko wrote:

> Can you investigate this further?
> LIBBUSYBOX build results in entire busybox code being put into a library.
> 
> nm -D libbusybox.so.1.28.0.git
> 
> shows that there are only defined entry points to each applet's main():
> 
> 0007b159 T bunzip2_main
> 0007c8db T bzip2_main
> 000677bb T cal_main
> 0008e08e T cat_main
> 
> (so, at max less than 350 entry points), and references to libc functions:
> 
>          U asprintf
>          U atof
>          U atoi
> 
> No internal libbb functions or variables are exposed.
> 
> I don't understand the error messages you are seeing. bb_errno should
> have hidden visibility,
> meaning that it is an internal (to libbusybox.so) label, and all
> references to it
> should be resolved without any shared linker magic. .LCn labels are
> similar, they are
> referring to text strings (messages and such).
> 
> What is going on? Why your linker has relocations between individual
> .o files which go
> to the same library?

I'm not really sure what's going on. But the problem can very easily be
reproduced:

$ git clone git://git.buildroot.org/buildroot
$ cd buildroot/
$ cat > .config <<EOF
BR2_sparc=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y
BR2_TOOLCHAIN_EXTERNAL_URL="http://autobuild.buildroot.org/toolchains/tarballs/br-sparc-uclibc-2017.05-1078-g95b1dae.tar.bz2";
BR2_TOOLCHAIN_EXTERNAL_GCC_6=y
BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_1=y
BR2_TOOLCHAIN_EXTERNAL_LOCALE=y
# BR2_TOOLCHAIN_EXTERNAL_HAS_THREADS_DEBUG is not set
BR2_TOOLCHAIN_EXTERNAL_CXX=y
BR2_INIT_NONE=y
BR2_SYSTEM_BIN_SH_NONE=y
BR2_PACKAGE_BUSYBOX_INDIVIDUAL_BINARIES=y
# BR2_TARGET_ROOTFS_TAR is not set
EOF
$ make olddefconfig
$ make

It builds only Busybox, so it's very quick to reach the build failure.
This time, I got:

libbb/lib.a(appletlib.o): In function `find_applet_by_name':
appletlib.c:(.text.find_applet_by_name+0x14): relocation truncated to fit: 
R_SPARC_GOT13 against symbol `applet_nameofs' defined in .rodata.applet_nameofs 
section in libbb/lib.a(appletlib.o)
appletlib.c:(.text.find_applet_by_name+0x18): relocation truncated to fit: 
R_SPARC_GOT13 against symbol `applet_names' defined in .rodata.applet_names 
section in libbb/lib.a(appletlib.o)
libbb/lib.a(appletlib.o): In function `bb_show_usage':
appletlib.c:(.text.bb_show_usage+0x10): relocation truncated to fit: 
R_SPARC_GOT13 against symbol `applet_name' defined in COMMON section in 
libbb/lib.a(appletlib.o)
appletlib.c:(.text.bb_show_usage+0x54): relocation truncated to fit: 
R_SPARC_GOT13 against symbol `bb_banner' defined in .rodata.bb_banner section 
in libbb/lib.a(messages.o)
libbb/lib.a(appletlib.o): In function `lbb_prepare':
appletlib.c:(.text.lbb_prepare+0x18): relocation truncated to fit: 
R_SPARC_GOT13 against symbol `bb_errno' defined in COMMON section in 
libbb/lib.a(ptr_to_globals.o)
appletlib.c:(.text.lbb_prepare+0x20): relocation truncated to fit: 
R_SPARC_GOT13 against symbol `applet_name' defined in COMMON section in 
libbb/lib.a(appletlib.o)
libbb/lib.a(appletlib.o): In function `run_applet_no_and_exit':
appletlib.c:(.text.run_applet_no_and_exit+0x28): relocation truncated to fit: 
R_SPARC_GOT13 against symbol `xfunc_error_retval' defined in 
.data.xfunc_error_retval section in libbb/lib.a(default_error_retval.o)
appletlib.c:(.text.run_applet_no_and_exit+0x38): relocation truncated to fit: 
R_SPARC_GOT13 against symbol `applet_name' defined in COMMON section in 
libbb/lib.a(appletlib.o)
appletlib.c:(.text.run_applet_no_and_exit+0xb0): relocation truncated to fit: 
R_SPARC_GOT13 against symbol `applet_main' defined in .data.rel.ro.applet_main 
section in libbb/lib.a(appletlib.o)
appletlib.c:(.text.run_applet_no_and_exit+0xcc): relocation truncated to fit: 
R_SPARC_GOT13 against symbol `applet_suid' defined in .rodata.applet_suid 
section in libbb/lib.a(appletlib.o)
appletlib.c:(.text.run_applet_no_and_exit+0x11c): additional relocation 
overflows omitted from the output
collect2: error: ld returned 1 exit status

When I build with my patches (the build is successful), and then look
at libbbusybox.so with readelf, the .got section is indeed very small,
much smaller than the 8 KB limit detailed in gcc's documentation about
-fpic vs. -fPIC:

$ ./output/host/usr/bin/sparc-linux-readelf -a 
output/target/lib/libbusybox.so.1.26.2 | grep "\.got"
  [17] .got              PROGBITS        000dc000 0cc000 00021c 04  WA  0   0  4

So the size is only 0x21c.

Any idea on how to investigate this further?

Thanks!

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to