Bug 10201 - ld.so fails to link on alpha due to relocation errors
Summary: ld.so fails to link on alpha due to relocation errors
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: ports (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Roland McGrath
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-05-26 07:34 UTC by Aurelien Jarno
Modified: 2014-07-01 20:18 UTC (History)
2 users (show)

See Also:
Host: alphaev68-unknown-linux-gnu
Target: alphaev68-unknown-linux-gnu
Build: alphaev68-unknown-linux-gnu
Last reconfirmed:
fweimer: security-


Attachments
Patch to fix the problem (320 bytes, patch)
2009-05-26 07:34 UTC, Aurelien Jarno
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Aurelien Jarno 2009-05-26 07:34:40 UTC
ld.so fails to link on alpha to relocation errors. The solution is to use -fPIC 
instead of -fpic for rtld.c. Patch will follow.
Comment 1 Aurelien Jarno 2009-05-26 07:34:58 UTC
Created attachment 3965 [details]
Patch to fix the problem
Comment 2 Richard Henderson 2010-05-04 16:22:13 UTC
Show me a log of such a link error.  I don't reproduce it here.
Comment 3 Matt Turner 2010-05-04 17:16:59 UTC
Can you still reproduce this?
Comment 4 Mike Frysinger 2010-05-04 22:50:47 UTC
i added this to the Gentoo patchset because i was hitting this error.  my system
is obviously using Gentoo patches, but they are by & large bug fixes/backports.
 i havent attempted a pure vanilla build since gcc/glibc vanilla releases of
late tend to have problems on alpha, and because i dont believe the original
reporter here is using Gentoo.

perhaps the important piece is that we're both targeting alphaev68-linux-gnu and
not something like alpha-linux-gnu ...

this is the build failure as seen with gcc-4.4.3 and glibc-2.11.1 (reformatted
slightly for bugzilla comment posting):
alphaev68-unknown-linux-gnu-gcc -nostdlib -nostartfiles -shared \
  -Wl,-z,now -Wl,-z,combreloc -Wl,-z,relro -Wl,--hash-style=both \
  -Wl,-z,defs -Wl,--verbose 2>&1 \
  | LC_ALL=C sed \
    -e '/^=========/,/^=========/!d;/^=========/d' \
    -e 's/\. = .* + SIZEOF_HEADERS;/& _begin = . - SIZEOF_HEADERS;/' \
  > ${build}/elf/ld.so.lds
alphaev68-unknown-linux-gnu-gcc -nostdlib -nostartfiles -shared \
  -Wl,-z,combreloc -Wl,-z,relro -Wl,--hash-style=both -Wl,-z,defs -Wl,-z,now \
  -o ${build}/elf/ld.so ${build}/elf/librtld.os \
  -Wl,--version-script=${build}/ld.map \
  -Wl,-soname=ld-linux.so.2 \
  -T ${build}/elf/ld.so.lds
${build}/elf/librtld.os: In function `security_init':
(.text+0x7a8): relocation truncated to fit: GPREL16 against symbol `_dl_random'
defined in .data.rel.ro section in ${build}/elf/librtld.os
${build}/elf/librtld.os: In function `security_init':
(.text+0x818): relocation truncated to fit: GPREL16 against symbol `_dl_random'
defined in .data.rel.ro section in ${build}/elf/librtld.os
collect2: ld returned 1 exit status
make[2]: *** [${build}/elf/ld.so] Error 1
Comment 5 Richard Henderson 2010-05-05 14:58:38 UTC
This error is fixed in commit d09580b1e6c3158fd00a41e71ec5a4ace9f0a2fe.

As the dump from my just-built ld.so has 

  [19] .got              PROGBITS         0000000000034078  00024078
       0000000000000048  0000000000000000  WA       0     0     8
  [20] .sdata            PROGBITS         00000000000340c0  000240c0
       0000000000001010  0000000000000000 WAp       0     0     8
  [21] .sbss             NOBITS           00000000000350d0  000250d0
       000000000000011c  0000000000000000 WAp       0     0     8

a small data area of 4468 bytes, I sincerely doubt this is going to
grow beyond 64k any time soon.  Therefore I'm going to close this bug.
Any future link errors as seen in your report should looked at with
suspicion that the attributes on the variable are incorrect.