https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98784

--- Comment #6 from Romain Naour <romain.naour at gmail dot com> ---
Hello,

Thanks for the help,

The previous gcc command line was from the busybox build (without -fPIC) but
this is not busybox that crash... this is the libc.

See how the libc (uClibc) was built:

output/host/bin/sparc-buildroot-linux-uclibc-gcc -c libc/stdlib/atoll.c -o
libc/stdlib/atoll.os -Wall -Wstrict-prototypes -Wstrict-aliasing
-Wno-nonnull-compare -funsigned-char -fno-builtin -fcommon -fno-asm
-fmerge-all-constants -std=gnu99 -mcpu=v8 -fno-stack-protector -nostdinc
-I./include -I./include -include libc-symbols.h -I./libc/sysdeps/linux/sparc
-I./libc/sysdeps/linux -I./ldso/ldso/sparc -I./ldso/include -I. -Os
-fstrict-aliasing -D__USE_STDIO_FUTEXES__ -DHAVE_FORCED_UNWIND
-D_LIBC_REENTRANT -I./libpthread/nptl -I./libpthread/nptl
-I./libpthread/nptl/sysdeps/unix/sysv/linux/sparc
-I./libpthread/nptl/sysdeps/sparc -I./libpthread/nptl/sysdeps/sparc
-I./libpthread/nptl/sysdeps/unix/sysv/linux
-I./libpthread/nptl/sysdeps/unix/sysv/linux -I./libpthread/nptl/sysdeps/pthread
-I./libpthread/nptl/sysdeps/pthread/bits -I./libpthread/nptl/sysdeps/generic
-I./libc/sysdeps/linux/common -isystem
output/host/lib/gcc/sparc-buildroot-linux-uclibc/10.2.0/include-fixed -isystem
output/host/lib/gcc/sparc-buildroot-linux-uclibc/10.2.0/include
-Ioutput/build/linux-headers-5.4.88/usr/include/ -DNDEBUG -DIN_LIB=libc -fPIC
-MT libc/stdlib/atoll.os -MD -MP -MF libc/stdlib/.atoll.os.dep

Indeed we have "-fPIC"

The system boot correctly if I replace the libc library with a working one.

I'm not familiar with gcc internals but I tried to remove "!optimize" from the
if clauses [1] :

"if (!flag_pic || !crtl->uses_pic_offset_table)"

It seems to work (ok probably not the correct fix).
Is the issue related to the optimization level (Os vs O1) ?

[1]
https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/config/sparc/sparc.c;h=aefced85fe142885b1b31fa878a0ff0dfd4e921a;hb=ee5c3db6c5b2c3332912fb4c9cfa2864569ebd9a#l13097

Reply via email to