[llvm] fb1b994 - [JITLink][ELF][AArch64] Add support for ELF R_AARCH64_ABS32 relocation.
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 20 14:03:03 PDT 2023
Author: Lang Hames
Date: 2023-03-20T21:00:20Z
New Revision: fb1b9945be7657a3a25b727eaf0eeb3f74525210
URL: https://github.com/llvm/llvm-project/commit/fb1b9945be7657a3a25b727eaf0eeb3f74525210
DIFF: https://github.com/llvm/llvm-project/commit/fb1b9945be7657a3a25b727eaf0eeb3f74525210.diff
LOG: [JITLink][ELF][AArch64] Add support for ELF R_AARCH64_ABS32 relocation.
This relocation is commonly used in debug sections. Failure to handle it caused
the test failure in https://lab.llvm.org/buildbot/#/builders/197/builds/4272,
which forced the reversion, in f721fcb6ed0, of 57aeb305460 ("[JITLink][ELF]
Don't skip debug info sections by default"). This fix should allow us to
re-land 57aeb305460.
Added:
llvm/test/ExecutionEngine/JITLink/AArch64/ELF_R_AARCH64_ABS32.yaml
Modified:
llvm/lib/ExecutionEngine/JITLink/ELF_aarch64.cpp
Removed:
################################################################################
diff --git a/llvm/lib/ExecutionEngine/JITLink/ELF_aarch64.cpp b/llvm/lib/ExecutionEngine/JITLink/ELF_aarch64.cpp
index 3eb7e1bccde7e..ab47f86859dd6 100644
--- a/llvm/lib/ExecutionEngine/JITLink/ELF_aarch64.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/ELF_aarch64.cpp
@@ -58,6 +58,7 @@ class ELFLinkGraphBuilder_aarch64 : public ELFLinkGraphBuilder<ELFT> {
ELFMovwAbsG1,
ELFMovwAbsG2,
ELFMovwAbsG3,
+ ELFAbs32,
ELFAbs64,
ELFPrel32,
ELFPrel64,
@@ -98,6 +99,8 @@ class ELFLinkGraphBuilder_aarch64 : public ELFLinkGraphBuilder<ELFT> {
return ELFMovwAbsG2;
case ELF::R_AARCH64_MOVW_UABS_G3:
return ELFMovwAbsG3;
+ case ELF::R_AARCH64_ABS32:
+ return ELFAbs32;
case ELF::R_AARCH64_ABS64:
return ELFAbs64;
case ELF::R_AARCH64_PREL32:
@@ -284,6 +287,10 @@ class ELFLinkGraphBuilder_aarch64 : public ELFLinkGraphBuilder<ELFT> {
Kind = aarch64::MoveWide16;
break;
}
+ case ELFAbs32: {
+ Kind = aarch64::Pointer32;
+ break;
+ }
case ELFAbs64: {
Kind = aarch64::Pointer64;
break;
@@ -357,6 +364,8 @@ class ELFLinkGraphBuilder_aarch64 : public ELFLinkGraphBuilder<ELFT> {
return "ELFMovwAbsG2";
case ELFMovwAbsG3:
return "ELFMovwAbsG3";
+ case ELFAbs32:
+ return "ELFAbs32";
case ELFAbs64:
return "ELFAbs64";
case ELFPrel32:
diff --git a/llvm/test/ExecutionEngine/JITLink/AArch64/ELF_R_AARCH64_ABS32.yaml b/llvm/test/ExecutionEngine/JITLink/AArch64/ELF_R_AARCH64_ABS32.yaml
new file mode 100644
index 0000000000000..ca992adbba819
--- /dev/null
+++ b/llvm/test/ExecutionEngine/JITLink/AArch64/ELF_R_AARCH64_ABS32.yaml
@@ -0,0 +1,90 @@
+# Check success and failure cases of R_AARCH64_32 handling.
+# This file contains a single R_AARCH64_ABS32 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_AARCH64
+ SectionHeaderStringTable: .strtab
+Sections:
+ - Name: .text
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+ AddressAlign: 0x4
+ Content: E0031F2AC0035FD6
+ - 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: 00636C616E672076657273696F6E2031372E302E30202868747470733A2F2F6769746875622E636F6D2F6C6C766D2F6C6C766D2D70726F6A6563742E67697420333130616161633834363336656336633933383739633138643933653332663537623264383938362900
+ - 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_AARCH64_ABS32
+ - 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: hw.c
+ Type: STT_FILE
+ Index: SHN_ABS
+ - Name: '$x.0'
+ Section: .text
+ - Name: '$d.1'
+ Section: .data
+ - Name: '$d.2'
+ Section: .comment
+ - Name: main
+ Type: STT_FUNC
+ Section: .text
+ Binding: STB_GLOBAL
+ Size: 0x8
+ - Name: xptr
+ Type: STT_OBJECT
+ Section: .data
+ Binding: STB_GLOBAL
+ Size: 0x8
+ - Name: x
+ Binding: STB_GLOBAL
+...
More information about the llvm-commits
mailing list