enum ELFX86RelocationKind : Edge::Kind {
Branch32 = Edge::FirstRelocation,
+ Pointer32,
Pointer32Signed,
Pointer64,
PCRel32,
static Expected<ELFX86RelocationKind> getRelocationKind(const uint32_t Type) {
switch (Type) {
+ case ELF::R_X86_64_32:
+ return ELFX86RelocationKind::Pointer32;
case ELF::R_X86_64_32S:
return ELFX86RelocationKind::Pointer32Signed;
case ELF::R_X86_64_PC32:
case Delta64:
Kind = x86_64::Delta64;
break;
+ case Pointer32:
+ Kind = x86_64::Pointer32;
+ break;
case Pointer32Signed:
Kind = x86_64::Pointer32Signed;
break;
--- /dev/null
+# Check success and failure cases of R_X86_64_32 handling.
+# This file contains a single R_X86_64_32 relocation. We expect the relocation
+# to apply successfully when we assign x an address in the low 32-bits of the
+# address space, and fail if we assign x an address outside that range.
+
+# RUN: yaml2obj -o %t.o %s
+# RUN: llvm-jitlink -abs x=0x12345678 -noexec -check=%s %t.o
+# RUN: not llvm-jitlink -abs x=0x123456789 -noexec %t.o 2>&1 | \
+# RUN: FileCheck -check-prefix=CHECK-ERROR %s
+
+# jitlink-check: *{8}xptr = x
+
+# CHECK-ERROR: relocation target "x" {{.*}} is out of range of Pointer32 fixup
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_X86_64
+ SectionHeaderStringTable: .strtab
+Sections:
+ - Name: .text
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+ AddressAlign: 0x10
+ Content: 31C0C3
+ - Name: .data
+ Type: SHT_PROGBITS
+ Flags: [ SHF_WRITE, SHF_ALLOC ]
+ AddressAlign: 0x8
+ Content: '0000000000000000'
+ - Name: .comment
+ Type: SHT_PROGBITS
+ Flags: [ SHF_MERGE, SHF_STRINGS ]
+ AddressAlign: 0x1
+ EntSize: 0x1
+ Content: 00636C616E672076657273696F6E2031372E302E302028676974406769746875622E636F6D3A6C6C766D2F6C6C766D2D70726F6A6563742E67697420393361303461303539316331393538643533343466333534313135376662643862386666373337302900
+ - Name: .note.GNU-stack
+ Type: SHT_PROGBITS
+ AddressAlign: 0x1
+ - Name: .rela.data
+ Type: SHT_RELA
+ Flags: [ SHF_INFO_LINK ]
+ Link: .symtab
+ AddressAlign: 0x8
+ Info: .data
+ Relocations:
+ - Symbol: x
+ Type: R_X86_64_32
+ - Name: .llvm_addrsig
+ Type: SHT_LLVM_ADDRSIG
+ Flags: [ SHF_EXCLUDE ]
+ Link: .symtab
+ AddressAlign: 0x1
+ Symbols: [ x ]
+ - Type: SectionHeaderTable
+ Sections:
+ - Name: .strtab
+ - Name: .text
+ - Name: .data
+ - Name: .rela.data
+ - Name: .comment
+ - Name: .note.GNU-stack
+ - Name: .llvm_addrsig
+ - Name: .symtab
+Symbols:
+ - Name: testcase.c
+ Type: STT_FILE
+ Index: SHN_ABS
+ - Name: main
+ Type: STT_FUNC
+ Section: .text
+ Binding: STB_GLOBAL
+ Size: 0x3
+ - Name: xptr
+ Type: STT_OBJECT
+ Section: .data
+ Binding: STB_GLOBAL
+ Size: 0x8
+ - Name: x
+ Binding: STB_GLOBAL
+...