[lld] [lld/ELF][X86] Respect outSecOff when checking if GOTPCREL can be relaxed (PR #86334)

Arthur Eubanks via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 22 14:17:20 PDT 2024


================
@@ -47,6 +50,13 @@ SECTIONS {
   data 0x80200000 : { *(data) }
 }
 #--- lds2
+SECTIONS {
+  .text.foo 0x100000 : { *(.text.foo) }
----------------
aeubanks wrote:

> Do we need any checks to go along with the new sections?

What do you mean by `new sections`? This linker script is a copy of the first one, but with the output section address adjusted.

> Use two input sections instead? The second input contains relocations while the first is for padding.

if I'm understanding your request, using two input sections (e.g.)
```
.section .text,"ax"
.space 4096

.section .text,"ax"
.globl _start
.type _start, @function
_start:
  movl __stop_data at GOTPCREL(%rip), %eax  # out of range
  movq __stop_data at GOTPCREL(%rip), %rax  # out of range
  movq __stop_data at GOTPCREL(%rip), %rax  # in range
  movl __stop_data at GOTPCREL(%rip), %eax  # in range
```
adjusts `rel.offset` instead of `sec->outSecOff` so it doesn't trigger this bug

the bug I found was in the context of a linker script

https://github.com/llvm/llvm-project/pull/86334


More information about the llvm-commits mailing list