[Openmp-commits] [openmp] [libomptarget] Support BE ELF files in plugins-nextgen (PR #83976)

Joseph Huber via Openmp-commits openmp-commits at lists.llvm.org
Wed Mar 6 07:47:11 PST 2024


================
@@ -27,18 +27,14 @@ bool isELF(llvm::StringRef Buffer);
 /// Checks if the given \p Object is a valid ELF matching the e_machine value.
 llvm::Expected<bool> checkMachine(llvm::StringRef Object, uint16_t EMachine);
 
-/// Returns a pointer to the given \p Symbol inside of an ELF object.
-llvm::Expected<const void *> getSymbolAddress(
-    const llvm::object::ELFObjectFile<llvm::object::ELF64LE> &ELFObj,
-    const llvm::object::ELF64LE::Sym &Symbol);
-
-/// Returns the symbol associated with the \p Name in the \p ELFObj. It will
+/// Returns the symbol associated with the \p Name in the \p Obj. It will
 /// first search for the hash sections to identify symbols from the hash table.
 /// If that fails it will fall back to a linear search in the case of an
-/// executable file without a hash table.
-llvm::Expected<const typename llvm::object::ELF64LE::Sym *>
-getSymbol(const llvm::object::ELFObjectFile<llvm::object::ELF64LE> &ELFObj,
-          llvm::StringRef Name);
+/// executable file without a hash table.  If the symbol is not found, returns
+/// an empty StringRef; otherwise, returns a StringRef covering the symbol's
+/// data in the Obj buffer, based on its address and size
+llvm::Expected<llvm::StringRef>
+findSymbolInImage(const llvm::MemoryBufferRef Obj, llvm::StringRef Name);
----------------
jhuber6 wrote:

Caller can use `Buffer.getBuffer()` to get the StringRef, and we already construct the memory buffer elsewhere. It's just easier to be consistent.

https://github.com/llvm/llvm-project/pull/83976


More information about the Openmp-commits mailing list