Summary: | Overflow in relocation (R_AARCH64_TLSLE_ADD_TPREL_HI12) silently ignored | ||
---|---|---|---|
Product: | binutils | Reporter: | Han Shen <shenhan> |
Component: | binutils | Assignee: | Jiong Wang <jiwang> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | jiwang |
Priority: | P2 | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Host: | Target: | ||
Build: | Last reconfirmed: | ||
Attachments: | test case |
The master branch has been updated by Jiong Wang <jiwang@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=bab91cce20e052822e128c672e0570c8f3f58131 commit bab91cce20e052822e128c672e0570c8f3f58131 Author: Jiong Wang <jiong.wang@arm.com> Date: Tue Jan 13 11:18:10 2015 +0000 [AArch64] Enable overflow check for R_AARCH64_TLSLE_ADD_TPREL_HI12 bfd/ PR ld/17415 * elfnn-aarch64.c (elfNN_aarch64_howto_table): Mark R_AARCH64_TLSLE_ADD_TPREL_HI12 as complain_overflow_unsigned. * elfxx-aarch64.c (_bfd_aarch64_elf_resolve_relocation): Correct the bit mask. ld/testsuite/ PR ld/17415 * ld-aarch64/pr17415.s: Source file for new test. * ld-aarch64/pr17415.d: Expect file for new test. * ld-aarch64/aarch64-elf.exp: Run the new test. fixed |
Created attachment 7795 [details] test case Hi while developing gold for aarch64, we found a case (attached) that overflows relocation R_AARCH64_TLSLE_ADD_TPREL_HI12, because the offset from TP (thread pointer) is too large (bigger than 2^24). Instead of generating an error, the bfd aarch64 linker silently truncates the higher bits of offset, leading to a run time error. To reproduce, just compile - gcc -O0 case.c ./a.out The exit value is 7, but the correct value should be 0. The relocations to compute tp-offset of "i" is at 400600 and 400604, which is apparently not "10". .... .... 4005fc: d53bd040 mrs x0, tpidr_el0 400600: 91400000 add x0, x0, #0x0, lsl #12 400604: 91004000 add x0, x0, #0x10 400608: b9400000 ldr w0, [x0] 40060c: 910043ff add sp, sp, #0x10 400610: d65f03c0 ret .... .... This was observed on trunk as well as 2.24.