[klibc] [PATCH] do not use -R on ppc to link shared objects

H. Peter Anvin hpa at zytor.com
Sat Nov 29 17:00:16 PST 2003

Olaf Hering wrote:
>  On Thu, Nov 27, H. Peter Anvin wrote:
>>Olaf Hering wrote:
>>>The *.shared targets require -shared on powerpc, and -R leads to linker
>>>This patch makes the -R an arch define. ia64 at least requires -R.
>>Hmmm... *both* of those sounds like linker bugs.  Unless there is a 
>>specific reason for it I'd rather try to get binutils fixed.  I'm not 
>>sure what consequences -shared has, and in *particular* what 
>>consequences it will have in future linker versions.
> I guess the root cause is this, unmodified ppc32 build:
> make[1]: Entering directory `/tmp/xx/klibc-0.87/klibc'
> ld   -o libc.so \
> crt0.o __shared_init.o vsnprintf.o snprintf.o vsprintf.o sprintf.o vsscanf.o sscanf.o ctypes.o strntoumax.o strntoimax.o atoi.o atol.o atoll.o strtol.o strtoll.o strtoul.o strtoull.o strtoimax.o strtoumax.o globals.o exitc.o atexit.o onexit.o execl.o execle.o execv.o execvpe.o execvp.o execlp.o execlpe.o fork.o wait.o wait3.o waitpid.o system.o setpgrp.o printf.o vprintf.o fprintf.o vfprintf.o perror.o fopen.o fread.o fread2.o fgetc.o fgets.o fwrite.o fwrite2.o fputc.o fputs.o puts.o sleep.o usleep.o raise.o abort.o assert.o alarm.o pause.o __signal.o signal.o bsd_signal.o siglist.o siglongjmp.o sigaction.o sigpending.o sigprocmask.o sigsuspend.o brk.o sbrk.o malloc.o realloc.o calloc.o mmap.o memcpy.o memcmp.o memset.o memccpy.o memmem.o memswap.o memmove.o strcasecmp.o strncasecmp.o strndup.o strerror.o strcat.o strchr.o strcmp.o strcpy.o strdup.o strlen.o strncat.o strstr.o strncmp.o strncpy.o strrchr.o strspn.o strsep.o strtok.o gethostname.o getdomainname.o getcwd.o se
teuid.o setegid.o setresuid.o setresgid.o getenv.o setenv.o unsetenv.o getopt.o readdir.o syslog.o closelog.o pty.o isatty.o reboot.o time.o utime.o fdatasync.o llseek.o select.o nice.o getpriority.o qsort.o lrand48.o srand48.o seed48.o inet/inet_ntoa.o inet/inet_aton.o inet/inet_addr.o inet/inet_ntop.o inet/inet_pton.o inet/bindresvport.o send.o recv.o arch/ppc/setjmp.o \
>         syscalls/*.o socketcalls/*.o \
>         /usr/lib/gcc-lib/powerpc-suse-linux/3.2.2/libgcc.a
> crt0.o: In function `_start':
> crt0.o(.text+0x24): undefined reference to `main'
> crt0.o(.text+0x24): relocation truncated to fit: R_PPC_REL24 main
> make[1]: *** [libc.so] Error 1
> make[1]: Leaving directory `/tmp/xx/klibc-0.87/klibc'
> make: *** [all] Error 2

Okay, there is a real crt0.S bug (bitrot, really): the crt0.S for 
ppc/ppc64 still uses the old crt0 calling convention which didn't use 
__{shared,static}_init.c for the common code.  It needs to be rewritten 
to call __libc_init() instead of main() directly.

See __static_init.c and __shared_init.c for the calling convention expected.


More information about the klibc mailing list