[Openmp-commits] [openmp] [libomptarget] Support BE ELF files in plugins-nextgen (PR #83976)
Joseph Huber via Openmp-commits
openmp-commits at lists.llvm.org
Tue Mar 5 20:42:20 PST 2024
================
@@ -71,6 +63,27 @@ Expected<bool> utils::elf::checkMachine(StringRef Object, uint16_t EMachine) {
return Header.e_machine == EMachine;
}
+Expected<bool> utils::elf::checkMachine(StringRef Object, uint16_t EMachine) {
+ assert(isELF(Object) && "Input is not an ELF!");
+
+ Expected<std::unique_ptr<ObjectFile>> ElfOrErr =
+ ObjectFile::createELFObjectFile(
+ MemoryBufferRef(Object, /*Identifier=*/""),
+ /*InitContent=*/false);
+ if (!ElfOrErr)
+ return ElfOrErr.takeError();
+
+ // Little-endian 64-bit
+ if (const ELF64LEObjectFile *ELFObj =
+ dyn_cast<ELF64LEObjectFile>(&**ElfOrErr))
+ return checkMachineImpl(*ELFObj, EMachine);
+ // Big-endian 64-bit
----------------
jhuber6 wrote:
Nit, comments probably unnecessary, but if you keep them they should end with punctuation.
https://github.com/llvm/llvm-project/pull/83976
More information about the Openmp-commits
mailing list