Browse Source
TCB_SIZE is 2*sizeof(void *), which is 0x10 for lp64, and 0x8 for ilp32. During relaxation, ld goes to do a replace: bl __tls_get_addr => add R0, R0, TCB_SIZE But actual implementation is: bfd_putl32 (0x91004000, contents + rel->r_offset + 4); Which is equivalent of add x0, x0, 0x10. This is wrong for ilp32. The possible fix for it is: bfd_putl32 (0x91000000 | (TCB_SIZE<<10), contents + rel->r_offset + 4); But ilp32 also needs w-registers, so it's simpler to put proper instruction in #if/#else condition. There are 2 such relaxations in elfNN_aarch64_tls_relax(), and so 2 new tests added for ilp32 mode to test it. Yury * bfd/elfnn-aarch64.c: fix TLS relaxations for ilp32 where TCB_SIZE is used. * ld/testsuite/ld-aarch64/aarch64-elf.exp: Add tests for the case. * ld/testsuite/ld-aarch64/tls-relax-ld-le-small-ilp32.d: New file. * ld/testsuite/ld-aarch64/tls-relax-ld-le-tiny-ilp32.d: New file. Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>binutils-2_28-branch
6 changed files with 56 additions and 5 deletions
@ -0,0 +1,14 @@ |
|||
#source: tls-relax-ld-le-small.s |
|||
#as: -mabi=ilp32 |
|||
#ld: -m [aarch64_choose_ilp32_emul] -T relocs-ilp32.ld -e0 |
|||
#objdump: -dr |
|||
#... |
|||
+10000: 910003fd mov x29, sp |
|||
+10004: d53bd040 mrs x0, tpidr_el0 |
|||
+10008: 11002000 add w0, w0, #0x8 |
|||
+1000c: d503201f nop |
|||
+10010: d503201f nop |
|||
+10014: 91400001 add x1, x0, #0x0, lsl #12 |
|||
+10018: 91000021 add x1, x1, #0x0 |
|||
+1001c: 90000000 adrp x0, 10000 <.*> |
|||
+10020: d65f03c0 ret |
|||
@ -0,0 +1,13 @@ |
|||
#source: tls-relax-ld-le-tiny.s |
|||
#as: -mabi=ilp32 |
|||
#ld: -m [aarch64_choose_ilp32_emul] -T relocs-ilp32.ld -e0 |
|||
#objdump: -dr |
|||
#... |
|||
+10000: 910003fd mov x29, sp |
|||
+10004: d53bd040 mrs x0, tpidr_el0 |
|||
+10008: 11002000 add w0, w0, #0x8 |
|||
+1000c: d503201f nop |
|||
+10010: 91400001 add x1, x0, #0x0, lsl #12 |
|||
+10014: 91000021 add x1, x1, #0x0 |
|||
+10018: 90000000 adrp x0, 10000 <main> |
|||
+1001c: d65f03c0 ret |
|||
Loading…
Reference in new issue