[JITLink][ELF][AArch64] Implement R_AARCH64_ABS64 relocation type.

Implement R_AARCH64_ABS64 relocation entry. This relocation type is generated
when creating a static function pointer to symbol.

Reviewed By: lhames, sgraenitz

Differential Revision: https://reviews.llvm.org/D126658
This commit is contained in:
Lang Hames 2022-06-07 17:48:09 -07:00
parent 67069e1980
commit 1deaa9b8bd
2 changed files with 27 additions and 1 deletions

View File

@ -54,6 +54,7 @@ private:
ELFLdSt32Abs12,
ELFLdSt64Abs12,
ELFLdSt128Abs12,
ELFAbs64,
};
static Expected<ELFAArch64RelocationKind>
@ -76,6 +77,8 @@ private:
return ELFLdSt64Abs12;
case ELF::R_AARCH64_LDST128_ABS_LO12_NC:
return ELFLdSt128Abs12;
case ELF::R_AARCH64_ABS64:
return ELFAbs64;
}
return make_error<JITLinkError>("Unsupported aarch64 relocation:" +
@ -199,6 +202,10 @@ private:
Kind = aarch64::PageOffset12;
break;
}
case ELFAbs64: {
Kind = aarch64::Pointer64;
break;
}
};
Edge GE(Kind, Offset, *GraphSymbol, Addend);
@ -231,6 +238,8 @@ private:
return "ELFLdSt64Abs12";
case ELFLdSt128Abs12:
return "ELFLdSt128Abs12";
case ELFAbs64:
return "ELFAbs64";
default:
return getGenericEdgeKindName(static_cast<Edge::Kind>(R));
}

View File

@ -1,5 +1,6 @@
# RUN: rm -rf %t && mkdir -p %t
# RUN: llvm-mc -triple=aarch64-unknown-linux-gnu -relax-relocations=false -position-independent -filetype=obj -o %t/elf_reloc.o %s
# RUN: llvm-mc -triple=aarch64-unknown-linux-gnu -relax-relocations=false \
# RUN: -position-independent -filetype=obj -o %t/elf_reloc.o %s
# RUN: llvm-jitlink -noexec -check %s %t/elf_reloc.o
.text
@ -113,6 +114,15 @@ test_str_64bit:
str x0, [x1, :lo12:named_data]
.size test_str_64bit, .-test_str_64bit
# Check R_AARCH64_ABS64 relocation of a function pointer to local symbol
#
# jitlink-check: *{8}local_func_addr_quad = named_func
.globl local_func_addr_quad
.p2align 3
local_func_addr_quad:
.xword named_func
.size local_func_addr_quad, 8
.globl named_data
.p2align 4
.type named_data,@object
@ -120,3 +130,10 @@ named_data:
.quad 0x2222222222222222
.quad 0x3333333333333333
.size named_data, .-named_data
.globl named_func
.p2align 2
.type named_func,@function
named_func:
ret
.size named_func, .-named_func