| Summary: | sys-libs/glibc-2.11.2: TEXTRELs on SuperH when building PIEs (due to Scrt1.o) | ||
|---|---|---|---|
| Product: | Gentoo Linux | Reporter: | SpanKY <vapier> |
| Component: | Current packages | Assignee: | Gentoo Toolchain Maintainers <toolchain> |
| Status: | RESOLVED OBSOLETE | ||
| Severity: | normal | CC: | armin76, slyfox |
| Priority: | High | ||
| Version: | unspecified | ||
| Hardware: | sh | ||
| OS: | Linux | ||
| URL: | https://sourceware.org/PR23441 | ||
| See Also: | https://bugs.gentoo.org/show_bug.cgi?id=459784 | ||
| Whiteboard: | tracking upstream | ||
| Package list: | Runtime testing required: | --- | |
Still happens:
$ echo 'int main(){}' | sh4-unknown-linux-gnu-gcc-8.1.0 -fPIE -pie -x c - -o a.out
/usr/libexec/gcc/sh4-unknown-linux-gnu/ld: warning: creating a DT_TEXTREL in object.
Very similar dynamic relocations:
$ objdump -d -R a.out | fgrep -C30 R_SH_
000003f8 <_start>:
3f8: 00 ee mov #0,r14
3fa: f6 65 mov.l @r15+,r5
3fc: f3 66 mov r15,r6
3fe: 46 2f mov.l r4,@-r15
400: 06 d0 mov.l 41c <_start+0x24>,r0 ! 5cc <__libc_csu_fini>
402: 06 2f mov.l r0,@-r15
404: 03 d4 mov.l 414 <_start+0x1c>,r4 ! 54c <main>
406: 04 d7 mov.l 418 <_start+0x20>,r7 ! 564 <__libc_csu_init>
408: 05 d1 mov.l 420 <_start+0x28>,r1 ! 0
40a: 0b 41 jsr @r1
40c: 09 00 nop
40e: 05 d1 mov.l 424 <_start+0x2c>,r1 ! 0
410: 0b 41 jsr @r1
412: 09 00 nop
414: 4c 05 mov.b @(r0,r4),r5
414: R_SH_RELATIVE *ABS*+0x54c
416: 00 00 .word 0x0000
418: 64 05 mov.b r6,@(r0,r5)
418: R_SH_RELATIVE *ABS*+0x564
41a: 00 00 .word 0x0000
41c: cc 05 mov.b @(r0,r12),r5
41c: R_SH_RELATIVE *ABS*+0x5cc
...
420: R_SH_DIR32 __libc_start_main@GLIBC_2.2
424: R_SH_DIR32 abort@GLIBC_2.2
Filed bug upstream with a few details:
https://sourceware.org/PR23441
TL;DR: start.S (and some other sysdeps/sh) assembly code does not attempt to use PIC code and hardcodes absolute addresses to external symbols. Should use GOT/PLT instead.
SuperH port disbanded. |
basically the SuperH Scrt1.o is no good ... it has relocs to symbols $ /lib/libc.so.6 | head -n1 GNU C Library stable release version 2.11.2, by Roland McGrath et al. $ gcc --version | head -n1 gcc (Gentoo 4.4.3-r2 p1.2) 4.4.3 $ echo 'main(){}' | gcc -fPIE -pie -x c - -o a.out /usr/lib/gcc/sh4-unknown-linux-gnu/4.4.3/../../../../sh4-unknown-linux-gnu/bin/ld: warning: creating a DT_TEXTREL in object. $ scanelf -qT a.out a.out: (memory/data?) [0x45C] in (optimized out) [0x440] a.out: (memory/data?) [0x460] in (optimized out) [0x440] a.out: (memory/data?) [0x464] in (optimized out) [0x440] a.out: (memory/data?) [0x468] in (optimized out) [0x440] a.out: (memory/data?) [0x46C] in (optimized out) [0x440] $ objdump -dzr a.out ... 448: 06 d0 mov.l 464 <_start+0x24>,r0 ! 580 <__libc_csu_fini> 44a: 06 2f mov.l r0,@-r15 44c: 03 d4 mov.l 45c <_start+0x1c>,r4 ! 560 <main> 44e: 04 d7 mov.l 460 <_start+0x20>,r7 ! 5a0 <__libc_csu_init> 450: 05 d1 mov.l 468 <_start+0x28>,r1 ! 0 452: 0b 41 jsr @r1 454: 09 00 nop 456: 05 d1 mov.l 46c <_start+0x2c>,r1 ! 0 458: 0b 41 jsr @r1 45a: 09 00 nop 45c: 60 05 .word 0x0560 45e: 00 00 .word 0x0000 460: a0 05 .word 0x05a0 462: 00 00 .word 0x0000 464: 80 05 .word 0x0580 466: 00 00 .word 0x0000 468: 00 00 .word 0x0000 46a: 00 00 .word 0x0000 46c: 00 00 .word 0x0000 ... looking at the map output (-Wl,-M), we see: .text 0x0000000000000440 0x30 /usr/lib/Scrt1.o 0x0000000000000440 _start $ objdump -dzr /usr/lib/Scrt1.0 00000000 <_start>: 0: 00 ee mov #0,r14 2: f6 65 mov.l @r15+,r5 4: f3 66 mov r15,r6 6: 46 2f mov.l r4,@-r15 8: 06 d0 mov.l 24 <_start+0x24>,r0 ! 0 <_start> a: 06 2f mov.l r0,@-r15 c: 03 d4 mov.l 1c <_start+0x1c>,r4 ! 0 <_start> e: 04 d7 mov.l 20 <_start+0x20>,r7 ! 0 <_start> 10: 05 d1 mov.l 28 <_start+0x28>,r1 ! 0 <_start> 12: 0b 41 jsr @r1 14: 09 00 nop 16: 05 d1 mov.l 2c <_start+0x2c>,r1 ! 0 <_start> 18: 0b 41 jsr @r1 1a: 09 00 nop 1c: 00 00 .word 0x0000 1c: R_SH_DIR32 main 1e: 00 00 .word 0x0000 20: 00 00 .word 0x0000 20: R_SH_DIR32 __libc_csu_init 22: 00 00 .word 0x0000 24: 00 00 .word 0x0000 24: R_SH_DIR32 __libc_csu_fini 26: 00 00 .word 0x0000 28: 00 00 .word 0x0000 28: R_SH_DIR32 __libc_start_main 2a: 00 00 .word 0x0000 2c: 00 00 .word 0x0000 2c: R_SH_DIR32 abort 2e: 00 00 .word 0x0000 obviously these relocs are no good