[PATCH] D156982: [JITLink][ELF] Create big-endian ELF object
Kai Luo via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 3 03:03:09 PDT 2023
lkail created this revision.
lkail added a reviewer: lhames.
Herald added subscribers: kbarton, hiraditya, nemanjai.
Herald added a project: All.
lkail requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
We're missing creating big-endian ELF object.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D156982
Files:
llvm/lib/ExecutionEngine/JITLink/ELF.cpp
llvm/test/ExecutionEngine/JITLink/ppc64/ppc64-relocs.s
Index: llvm/test/ExecutionEngine/JITLink/ppc64/ppc64-relocs.s
===================================================================
--- llvm/test/ExecutionEngine/JITLink/ppc64/ppc64-relocs.s
+++ llvm/test/ExecutionEngine/JITLink/ppc64/ppc64-relocs.s
@@ -2,7 +2,7 @@
# RUN: llvm-jitlink -abs external_var=0xffff0000 -abs puts=0xffff6400 -abs \
# RUN: foo=0xffff8800 -noexec %t
# RUN: llvm-mc -triple=powerpc64-unknown-linux-gnu -filetype=obj -o %t %s
-# RUN: not llvm-jitlink -abs external_var=0xffff0000 -abs puts=0xffff6400 -abs \
+# RUN: llvm-jitlink -abs external_var=0xffff0000 -abs puts=0xffff6400 -abs \
# RUN: foo=0xffff8800 -noexec %t
#
# Check typical relocations involving external function call, external variable
Index: llvm/lib/ExecutionEngine/JITLink/ELF.cpp
===================================================================
--- llvm/lib/ExecutionEngine/JITLink/ELF.cpp
+++ llvm/lib/ExecutionEngine/JITLink/ELF.cpp
@@ -52,6 +52,22 @@
}
}
+ if (Data[ELF::EI_DATA] == ELF::ELFDATA2MSB) {
+ if (Data[ELF::EI_CLASS] == ELF::ELFCLASS64) {
+ if (auto File = llvm::object::ELF64BEFile::create(Buffer)) {
+ return File->getHeader().e_machine;
+ } else {
+ return File.takeError();
+ }
+ } else if (Data[ELF::EI_CLASS] == ELF::ELFCLASS32) {
+ if (auto File = llvm::object::ELF32BEFile::create(Buffer)) {
+ return File->getHeader().e_machine;
+ } else {
+ return File.takeError();
+ }
+ }
+ }
+
return ELF::EM_NONE;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156982.546781.patch
Type: text/x-patch
Size: 1517 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230803/c20676cc/attachment.bin>
More information about the llvm-commits
mailing list