Replace private libelf with elfio

Change-Id: I59ae33f7cc55e73f6519af14be91dd9863b03af3
This commit is contained in:
Tao Sang
2020-08-11 12:49:50 -04:00
committed by Tao Sang
parent 280d300320
commit 4e1344de0f
6 changed files with 19 additions and 44 deletions
+2 -18
View File
@@ -19,7 +19,7 @@
THE SOFTWARE. */
#include <hip/hip_runtime.h>
#include <libelf.h>
#include <elf/elf.hpp>
#include <fstream>
#include "hip_internal.hpp"
@@ -45,23 +45,7 @@ const std::string& FunctionName(const hipFunction_t f) {
static uint64_t ElfSize(const void *emi)
{
const Elf64_Ehdr *ehdr = (const Elf64_Ehdr*)emi;
const Elf64_Shdr *shdr = (const Elf64_Shdr*)((char*)emi + ehdr->e_shoff);
uint64_t max_offset = ehdr->e_shoff;
uint64_t total_size = max_offset + ehdr->e_shentsize * ehdr->e_shnum;
for (uint16_t i=0; i < ehdr->e_shnum; ++i){
uint64_t cur_offset = static_cast<uint64_t>(shdr[i].sh_offset);
if (max_offset < cur_offset) {
max_offset = cur_offset;
total_size = max_offset;
if(SHT_NOBITS != shdr[i].sh_type) {
total_size += static_cast<uint64_t>(shdr[i].sh_size);
}
}
}
return total_size;
return amd::Elf::getElfSize(emi);
}
hipError_t hipModuleUnload(hipModule_t hmod) {