Replace private libelf with elfio
Change-Id: I59ae33f7cc55e73f6519af14be91dd9863b03af3
This commit is contained in:
@@ -1,4 +1,10 @@
|
||||
#-------------------------------------LPL--------------------------------------#
|
||||
# Look for ROCclr which contains elfio
|
||||
find_package(ROCclr REQUIRED CONFIG
|
||||
PATHS
|
||||
/opt/rocm
|
||||
/opt/rocm/rocclr)
|
||||
|
||||
add_executable(lpl lpl.cpp)
|
||||
set_target_properties(
|
||||
lpl PROPERTIES
|
||||
@@ -6,7 +12,12 @@ set_target_properties(
|
||||
CXX_STANDARD_REQUIRED ON
|
||||
CXX_EXTENSIONS OFF
|
||||
RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
|
||||
target_include_directories(lpl PUBLIC ${PROJECT_SOURCE_DIR}/src)
|
||||
target_include_directories(lpl
|
||||
PUBLIC
|
||||
${PROJECT_SOURCE_DIR}/src
|
||||
PRIVATE
|
||||
$<TARGET_PROPERTY:amdrocclr_static,INTERFACE_INCLUDE_DIRECTORIES>)
|
||||
|
||||
target_compile_options(lpl PUBLIC -Wall)
|
||||
target_link_libraries(lpl PUBLIC pthread)
|
||||
|
||||
|
||||
+3
-3
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "clara/clara.hpp"
|
||||
#include "pstreams/pstream.h"
|
||||
#include "hip/hcc_detail/elfio/elfio.hpp"
|
||||
#include <elfio/elfio.hpp>
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
@@ -71,14 +71,14 @@ inline std::string make_hipcc_call(const std::vector<std::string>& sources,
|
||||
}
|
||||
|
||||
inline void copy_kernel_section_to_fat_binary(const std::string& tmp, const std::string& output) {
|
||||
ELFIO::elfio reader;
|
||||
amd::ELFIO::elfio reader;
|
||||
if (!reader.load(tmp)) {
|
||||
throw std::runtime_error{"The result of the compilation is inaccessible."};
|
||||
}
|
||||
|
||||
const auto it =
|
||||
std::find_if(reader.sections.begin(), reader.sections.end(),
|
||||
[](const ELFIO::section* x) { return x->get_name() == kernel_section(); });
|
||||
[](const amd::ELFIO::section* x) { return x->get_name() == kernel_section(); });
|
||||
|
||||
std::ofstream out{output};
|
||||
|
||||
|
||||
@@ -96,8 +96,6 @@ find_package(amd_comgr REQUIRED CONFIG
|
||||
|
||||
message(STATUS "Code Object Manager found at ${amd_comgr_DIR}.")
|
||||
|
||||
add_definitions(-DBSD_LIBELF)
|
||||
|
||||
add_library(hip64 OBJECT
|
||||
hip_context.cpp
|
||||
hip_code_object.cpp
|
||||
@@ -129,10 +127,8 @@ target_include_directories(hip64
|
||||
${PROJECT_SOURCE_DIR}/include
|
||||
${PROJECT_BINARY_DIR}/include
|
||||
PRIVATE
|
||||
${CMAKE_SOURCE_DIR}/elfio
|
||||
${PROJECT_SOURCE_DIR}
|
||||
${PROJECT_SOURCE_DIR}/amdocl
|
||||
${PROJECT_SOURCE_DIR}/include/hip/hcc_detail/elfio
|
||||
${ROCR_INCLUDES}
|
||||
$<TARGET_PROPERTY:amdrocclr_static,INTERFACE_INCLUDE_DIRECTORIES>
|
||||
$<TARGET_PROPERTY:amd_comgr,INTERFACE_INCLUDE_DIRECTORIES>)
|
||||
|
||||
@@ -6,27 +6,12 @@
|
||||
#include "hip/hip_runtime.h"
|
||||
#include "hip_internal.hpp"
|
||||
#include "platform/program.hpp"
|
||||
#include <elf/elf.hpp>
|
||||
|
||||
namespace hip {
|
||||
|
||||
uint64_t CodeObject::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);
|
||||
}
|
||||
|
||||
bool CodeObject::isCompatibleCodeObject(const std::string& codeobj_target_id,
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#include "platform/runtime.hpp"
|
||||
|
||||
#include <unordered_map>
|
||||
#include "elfio.hpp"
|
||||
|
||||
constexpr unsigned __hipFatMAGIC2 = 0x48495046; // "HIPF"
|
||||
|
||||
|
||||
مرجع در شماره جدید
Block a user