[Openmp-commits] [openmp] 14e34a8 - [libomptarget][amdgpu][nfc] Replace use of gelf.h with libelf.h

Jon Chesterfield via Openmp-commits openmp-commits at lists.llvm.org
Thu Jul 22 12:04:28 PDT 2021


Author: Jon Chesterfield
Date: 2021-07-22T20:04:13+01:00
New Revision: 14e34a83b0d234e0651db2396a82ec6bb96a631a

URL: https://github.com/llvm/llvm-project/commit/14e34a83b0d234e0651db2396a82ec6bb96a631a
DIFF: https://github.com/llvm/llvm-project/commit/14e34a83b0d234e0651db2396a82ec6bb96a631a.diff

LOG: [libomptarget][amdgpu][nfc] Replace use of gelf.h with libelf.h

AMDGPU can assume Elf64 so doesn't need to abstract over Elf32

Drop a few other unused headers at the same time. Now only llvm elf
and libelf are used by the plugin.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D106579

Added: 
    

Modified: 
    openmp/libomptarget/plugins/amdgpu/impl/system.cpp
    openmp/libomptarget/plugins/amdgpu/src/rtl.cpp

Removed: 
    


################################################################################
diff  --git a/openmp/libomptarget/plugins/amdgpu/impl/system.cpp b/openmp/libomptarget/plugins/amdgpu/impl/system.cpp
index e80f0bb62cea..e39a7e30f912 100644
--- a/openmp/libomptarget/plugins/amdgpu/impl/system.cpp
+++ b/openmp/libomptarget/plugins/amdgpu/impl/system.cpp
@@ -3,13 +3,9 @@
  *
  * This file is distributed under the MIT License. See LICENSE.txt for details.
  *===------------------------------------------------------------------------*/
-#include <gelf.h>
 #include <libelf.h>
 
 #include <cassert>
-#include <fstream>
-#include <iomanip>
-#include <set>
 #include <sstream>
 #include <string>
 
@@ -465,11 +461,10 @@ find_metadata(void *binary, size_t binSize) {
     return failure;
   }
 
+  Elf64_Phdr *pHdrs = elf64_getphdr(e);
   for (size_t i = 0; i < numpHdrs; ++i) {
-    GElf_Phdr pHdr;
-    if (gelf_getphdr(e, i, &pHdr) != &pHdr) {
-      continue;
-    }
+    Elf64_Phdr pHdr = pHdrs[i];
+
     // Look for the runtime metadata note
     if (pHdr.p_type == PT_NOTE && pHdr.p_align >= sizeof(int)) {
       // Iterate over the notes in this segment

diff  --git a/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp b/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
index 25add33595ab..f88bc2ac3b05 100644
--- a/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
+++ b/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
@@ -15,10 +15,7 @@
 #include <cstdio>
 #include <cstdlib>
 #include <cstring>
-#include <elf.h>
-#include <fstream>
 #include <functional>
-#include <iostream>
 #include <libelf.h>
 #include <list>
 #include <memory>


        


More information about the Openmp-commits mailing list