diff --git a/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp b/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp index 73a77b8e99e73..628b8f5040d99 100644 --- a/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp +++ b/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp @@ -680,12 +680,21 @@ Optional 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(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) diff --git a/llvm/test/MC/X86/reloc-directive-elf-32.s b/llvm/test/MC/X86/reloc-directive-elf-32.s index ed7e6bb756de6..b653e6029cf1d 100644 --- a/llvm/test/MC/X86/reloc-directive-elf-32.s +++ b/llvm/test/MC/X86/reloc-directive-elf-32.s @@ -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: diff --git a/llvm/test/MC/X86/reloc-directive-elf-64.s b/llvm/test/MC/X86/reloc-directive-elf-64.s index 30a252fcb84de..0cfa060839007 100644 --- a/llvm/test/MC/X86/reloc-directive-elf-64.s +++ b/llvm/test/MC/X86/reloc-directive-elf-64.s @@ -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: