[PATCH] D95994: [ELF] Allow R_386_GOTOFF from .debug_info
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 4 09:18:02 PST 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb3165a70ae83: [ELF] Allow R_386_GOTOFF from .debug_info (authored by MaskRay).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D95994/new/
https://reviews.llvm.org/D95994
Files:
lld/ELF/InputSection.cpp
lld/test/ELF/non-abs-reloc.s
Index: lld/test/ELF/non-abs-reloc.s
===================================================================
--- lld/test/ELF/non-abs-reloc.s
+++ lld/test/ELF/non-abs-reloc.s
@@ -1,17 +1,17 @@
// REQUIRES: x86
// RUN: split-file %s %t
-// RUN: llvm-mc -filetype=obj -triple=x86_64 %t/asm -o %t.o
-// RUN: ld.lld -T %t/lds %t.o -o %t.exe 2>&1 | FileCheck %s
-// CHECK: warning: {{.*}}.o:(.nonalloc1+0x1): has non-ABS relocation R_X86_64_PC32 against symbol '_start'
-// CHECK-NEXT: warning: {{.*}}.o:(.nonalloc1+0x6): has non-ABS relocation R_X86_64_PC32 against symbol '_start'
+// RUN: llvm-mc -filetype=obj -triple=i386 %t/asm -o %t.o
+// RUN: ld.lld -T %t/lds %t.o -o %t.exe 2>&1 | FileCheck %s --implicit-check-not=warning: --implicit-check-not=error:
+// CHECK: warning: {{.*}}.o:(.nonalloc1+0x1): has non-ABS relocation R_386_PC32 against symbol '_start'
+// CHECK-NEXT: warning: {{.*}}.o:(.nonalloc1+0x6): has non-ABS relocation R_386_PC32 against symbol '_start'
// RUN: llvm-objdump -D --no-show-raw-insn %t.exe | FileCheck --check-prefix=DISASM %s
// DISASM: Disassembly of section .nonalloc:
// DISASM-EMPTY:
// DISASM-NEXT: <.nonalloc>:
// DISASM-NEXT: 0: nop
-// DISASM-NEXT: 1: callq 0x0
-// DISASM-NEXT: 6: callq 0x0
+// DISASM-NEXT: 1: calll 0x0
+// DISASM-NEXT: 6: calll 0x0
//--- lds
SECTIONS {
@@ -20,6 +20,7 @@
//--- asm
.globl _start
_start:
+.L0:
nop
.section .nonalloc0
@@ -30,3 +31,8 @@
.long _start - . - 4
.byte 0xe8
.long _start - . - 4
+
+// GCC may relocate DW_AT_GNU_call_site_value with R_386_GOTOFF.
+// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98946
+.section .debug_info
+ .long .L0 at gotoff
Index: lld/ELF/InputSection.cpp
===================================================================
--- lld/ELF/InputSection.cpp
+++ lld/ELF/InputSection.cpp
@@ -901,7 +901,10 @@
continue;
}
- if (expr != R_ABS && expr != R_DTPREL && expr != R_RISCV_ADD) {
+ // R_ABS/R_DTPREL and some other relocations can be used from non-SHF_ALLOC
+ // sections.
+ if (expr != R_ABS && expr != R_DTPREL && expr != R_GOTPLTREL &&
+ expr != R_RISCV_ADD) {
std::string msg = getLocation<ELFT>(offset) +
": has non-ABS relocation " + toString(type) +
" against symbol '" + toString(sym) + "'";
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95994.321484.patch
Type: text/x-patch
Size: 2347 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210204/c51c26ad/attachment.bin>
More information about the llvm-commits
mailing list