[all-commits] [llvm/llvm-project] 38ed1d: [ELF] Support non-RAX/non-adjacent R_X86_64_GOTPC3...

Fangrui Song via All-commits all-commits at lists.llvm.org
Tue Nov 23 10:30:28 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 38ed1db7e8740fce236d1893ff9e20cc22ef0ada
      https://github.com/llvm/llvm-project/commit/38ed1db7e8740fce236d1893ff9e20cc22ef0ada
  Author: Fangrui Song <i at maskray.me>
  Date:   2021-11-23 (Tue, 23 Nov 2021)

  Changed paths:
    M lld/ELF/Arch/X86_64.cpp
    M lld/docs/ReleaseNotes.rst
    M lld/test/ELF/invalid/x86-64-tlsdesc-gd.s
    M lld/test/ELF/x86-64-tlsdesc-gd.s

  Log Message:
  -----------
  [ELF] Support non-RAX/non-adjacent R_X86_64_GOTPC32_TLSDESC/R_X86_64_TLSDESC_CALL

The current TLSDESC optimization code assumes:
```
leaq x at tlsdesc(%rip), %rax
call *x at tlscall(%rax)       # adjacent
```

>From https://gitlab.freedesktop.org/mesa/mesa/-/issues/5665 , it seems that the
two instructions may not be adjacent in GCC 10's output:
```
leaq x at tlsdesc(%rip), %rax
something else
call *x at tlscall(%rax)
```

This patch supports the case. While here, support non-RAX registers for
R_X86_64_GOTPC32_TLSDESC, in case the compiler generates inefficient:

```
leaq x at tlsdesc(%rip), %rcx  # or %rdx, %rbx, %rdi, ...
movq %rcx, %rax
call *x at tlscall(%rax)       # GNU ld/gold error for non-RAX
```

Differential Revision: https://reviews.llvm.org/D114416




More information about the All-commits mailing list