mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 03:02:36 +01:00
[MC][X86] Support .reloc *, BFD_RELOC_{NONE,8,16,32,64}, *
The names are unfortunate, but BFD_RELOC_NONE provides a generic way indicating a dependency between two sections, which is useful for ld --gc-sections. See https://sourceware.org/bugzilla/show_bug.cgi?id=27530
This commit is contained in:
parent
073a491a84
commit
d0c3033896
@ -680,12 +680,21 @@ Optional<MCFixupKind> X86AsmBackend::getFixupKind(StringRef Name) const {
|
||||
#define ELF_RELOC(X, Y) .Case(#X, Y)
|
||||
#include "llvm/BinaryFormat/ELFRelocs/x86_64.def"
|
||||
#undef ELF_RELOC
|
||||
.Case("BFD_RELOC_NONE", ELF::R_X86_64_NONE)
|
||||
.Case("BFD_RELOC_8", ELF::R_X86_64_8)
|
||||
.Case("BFD_RELOC_16", ELF::R_X86_64_16)
|
||||
.Case("BFD_RELOC_32", ELF::R_X86_64_32)
|
||||
.Case("BFD_RELOC_64", ELF::R_X86_64_64)
|
||||
.Default(-1u);
|
||||
} else {
|
||||
Type = llvm::StringSwitch<unsigned>(Name)
|
||||
#define ELF_RELOC(X, Y) .Case(#X, Y)
|
||||
#include "llvm/BinaryFormat/ELFRelocs/i386.def"
|
||||
#undef ELF_RELOC
|
||||
.Case("BFD_RELOC_NONE", ELF::R_386_NONE)
|
||||
.Case("BFD_RELOC_8", ELF::R_386_8)
|
||||
.Case("BFD_RELOC_16", ELF::R_386_16)
|
||||
.Case("BFD_RELOC_32", ELF::R_386_32)
|
||||
.Default(-1u);
|
||||
}
|
||||
if (Type == -1u)
|
||||
|
@ -10,6 +10,10 @@
|
||||
# PRINT-NEXT: .reloc 0, R_386_32, .data+2
|
||||
# PRINT-NEXT: .reloc 0, R_386_IRELATIVE, foo+3
|
||||
# PRINT-NEXT: .reloc 0, R_386_GOT32X, 5
|
||||
# PRINT-NEXT: .reloc 0, BFD_RELOC_NONE, 9
|
||||
# PRINT-NEXT: .reloc 0, BFD_RELOC_8, 9
|
||||
# PRINT-NEXT: .reloc 0, BFD_RELOC_16, 9
|
||||
# PRINT-NEXT: .reloc 0, BFD_RELOC_32, 9
|
||||
|
||||
# X86 relocations use the Elf32_Rel format. Addends are neither stored in the
|
||||
# relocation entries nor applied in the referenced locations.
|
||||
@ -19,6 +23,10 @@
|
||||
# CHECK-NEXT: 0x0 R_386_32 .data
|
||||
# CHECK-NEXT: 0x0 R_386_IRELATIVE foo
|
||||
# CHECK-NEXT: 0x0 R_386_GOT32X -
|
||||
# CHECK-NEXT: 0x0 R_386_NONE -
|
||||
# CHECK-NEXT: 0x0 R_386_8 -
|
||||
# CHECK-NEXT: 0x0 R_386_16 -
|
||||
# CHECK-NEXT: 0x0 R_386_32 -
|
||||
|
||||
# HEX: 0x00000000 00000000 00000000
|
||||
|
||||
@ -33,6 +41,11 @@
|
||||
.reloc 0, R_386_IRELATIVE, foo+3
|
||||
.reloc 0, R_386_GOT32X, 5
|
||||
|
||||
.reloc 0, BFD_RELOC_NONE, 9
|
||||
.reloc 0, BFD_RELOC_8, 9
|
||||
.reloc 0, BFD_RELOC_16, 9
|
||||
.reloc 0, BFD_RELOC_32, 9
|
||||
|
||||
.data
|
||||
.globl foo
|
||||
foo:
|
||||
|
@ -9,6 +9,11 @@
|
||||
# PRINT-NEXT: .reloc 0, R_X86_64_64, .data+2
|
||||
# PRINT-NEXT: .reloc 0, R_X86_64_GOTPCRELX, foo+3
|
||||
# PRINT-NEXT: .reloc 0, R_X86_64_REX_GOTPCRELX, 5
|
||||
# PRINT-NEXT: .reloc 0, BFD_RELOC_NONE, 9
|
||||
# PRINT-NEXT: .reloc 0, BFD_RELOC_8, 9
|
||||
# PRINT-NEXT: .reloc 0, BFD_RELOC_16, 9
|
||||
# PRINT-NEXT: .reloc 0, BFD_RELOC_32, 9
|
||||
# PRINT-NEXT: .reloc 0, BFD_RELOC_64, 9
|
||||
|
||||
# CHECK: 0x2 R_X86_64_NONE .data 0x0
|
||||
# CHECK-NEXT: 0x1 R_X86_64_NONE foo 0x4
|
||||
@ -16,6 +21,11 @@
|
||||
# CHECK-NEXT: 0x0 R_X86_64_64 .data 0x2
|
||||
# CHECK-NEXT: 0x0 R_X86_64_GOTPCRELX foo 0x3
|
||||
# CHECK-NEXT: 0x0 R_X86_64_REX_GOTPCRELX - 0x5
|
||||
# CHECK-NEXT: 0x0 R_X86_64_NONE - 0x9
|
||||
# CHECK-NEXT: 0x0 R_X86_64_8 - 0x9
|
||||
# CHECK-NEXT: 0x0 R_X86_64_16 - 0x9
|
||||
# CHECK-NEXT: 0x0 R_X86_64_32 - 0x9
|
||||
# CHECK-NEXT: 0x0 R_X86_64_64 - 0x9
|
||||
|
||||
.text
|
||||
ret
|
||||
@ -28,6 +38,12 @@
|
||||
.reloc 0, R_X86_64_GOTPCRELX, foo+3
|
||||
.reloc 0, R_X86_64_REX_GOTPCRELX, 5
|
||||
|
||||
.reloc 0, BFD_RELOC_NONE, 9
|
||||
.reloc 0, BFD_RELOC_8, 9
|
||||
.reloc 0, BFD_RELOC_16, 9
|
||||
.reloc 0, BFD_RELOC_32, 9
|
||||
.reloc 0, BFD_RELOC_64, 9
|
||||
|
||||
.data
|
||||
.globl foo
|
||||
foo:
|
||||
|
Loading…
Reference in New Issue
Block a user