[PATCH] D81359: [ELF] Add --[no-]relax for RISC-V
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 12 08:38:11 PDT 2020
MaskRay added a comment.
I have a use case for x86 R_X86_64_[REX_]GOTPCRELX when debugging a glibc static-pie issue.
GNU ld --no-relax (loads an address from GOT):
// elf_get_dynamic_info called by dl-reloc-static-pie.c
316│ 176 if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_FILES, 0)
317│ 0x00007fefd511896e <+462>: mov 0x695b(%rip),%rcx # 0x7fefd511f2d0
###### %rcx is 0 => null pointer dereference
318│ 0x00007fefd5118975 <+469>: testb $0x40,(%rcx)
--relax (PC-relative):
316│ 176 if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_FILES, 0)
317│ 0x00007f27dd56cdbe <+462>: lea 0x6f87b(%rip),%rcx # 0x7f27dd5dc640 <_dl_debug_mask>
318│ 0x00007f27dd56cdc5 <+469>: testb $0x40,(%rcx)
In a static pie program, it is a bug accessing GOT entry before the program relocates itself, as the GOT entry is likely 0 initially. lea is safe to use. If LLD has --relax --no-relax, it can be easier to verify that the behavior matches GNU ld. Honestly this is still a small use case and I managed to figure out the bug even if LLD does not support --no-relax.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D81359/new/
https://reviews.llvm.org/D81359
More information about the llvm-commits
mailing list