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

Ulrich Weigand via Openmp-commits openmp-commits at lists.llvm.org
Wed Mar 6 07:49:59 PST 2024


================
@@ -81,55 +71,36 @@ Error GenericGlobalHandlerTy::moveGlobalBetweenDeviceAndHost(
 bool GenericGlobalHandlerTy::isSymbolInImage(GenericDeviceTy &Device,
                                              DeviceImageTy &Image,
                                              StringRef SymName) {
-  // Get the ELF object file for the image. Notice the ELF object may already
-  // be created in previous calls, so we can reuse it. If this is unsuccessful
-  // just return false as we couldn't find it.
-  auto ELFObjOrErr = getELFObjectFile(Image);
-  if (!ELFObjOrErr) {
-    consumeError(ELFObjOrErr.takeError());
-    return false;
-  }
 
   // Search the ELF symbol using the symbol name.
-  auto SymOrErr = utils::elf::getSymbol(*ELFObjOrErr, SymName);
+  auto SymOrErr =
+      utils::elf::findSymbolInImage(Image.getMemoryBuffer(), SymName);
   if (!SymOrErr) {
     consumeError(SymOrErr.takeError());
     return false;
   }
 
-  return *SymOrErr;
+  return !SymOrErr->empty();
----------------
uweigand wrote:

It's true that for symbols with no size, we'd also report an empty StringRef, so we cannot distinguish these two cases (easily).  I thought this should be OK as the user here actually wants to copy data to/from the memory object identified by the symbol, so it cannot really do anything with a zero-sized symbol either.

If we do need to be able to make that distinction, we'd have to tweak the interface a bit.  Either add an explicit boolean, or else expose a bit more details of the implementation (e.g. we could check for `SymOrErr->data() != nullptr`).


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


More information about the Openmp-commits mailing list