mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-10-07 08:03:29 +00:00
Add .strtab And .symtab to Aot An File
Issue:https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/I71WRT Signed-off-by: wuzhangda <wuzhangda@huawei.com> Change-Id: I71561c4fa4a156cf4592430834d93085368d3a58
This commit is contained in:
parent
c672a8427b
commit
ce1b5e0849
@ -32,11 +32,7 @@ void AnFileInfo::Save(const std::string &filename, Triple triple)
|
|||||||
|
|
||||||
std::ofstream file(realPath.c_str(), std::ofstream::binary);
|
std::ofstream file(realPath.c_str(), std::ofstream::binary);
|
||||||
SetStubNum(entries_.size());
|
SetStubNum(entries_.size());
|
||||||
ModuleSectionDes &des = des_[0];
|
AddFuncEntrySec();
|
||||||
// add section
|
|
||||||
uint64_t funcEntryAddr = reinterpret_cast<uint64_t>(entries_.data());
|
|
||||||
uint32_t funcEntrySize = sizeof(FuncEntryDes) * entryNum_;
|
|
||||||
des.SetSecAddrAndSize(ElfSecName::ARK_FUNCENTRY, funcEntryAddr, funcEntrySize);
|
|
||||||
|
|
||||||
ElfBuilder builder(des_, GetDumpSectionNames());
|
ElfBuilder builder(des_, GetDumpSectionNames());
|
||||||
llvm::ELF::Elf64_Ehdr header;
|
llvm::ELF::Elf64_Ehdr header;
|
||||||
@ -120,6 +116,8 @@ const std::vector<ElfSecName> &AnFileInfo::GetDumpSectionNames()
|
|||||||
static const std::vector<ElfSecName> secNames = {
|
static const std::vector<ElfSecName> secNames = {
|
||||||
ElfSecName::TEXT,
|
ElfSecName::TEXT,
|
||||||
ElfSecName::STRTAB,
|
ElfSecName::STRTAB,
|
||||||
|
ElfSecName::SYMTAB,
|
||||||
|
ElfSecName::SHSTRTAB,
|
||||||
ElfSecName::ARK_STACKMAP,
|
ElfSecName::ARK_STACKMAP,
|
||||||
ElfSecName::ARK_FUNCENTRY
|
ElfSecName::ARK_FUNCENTRY
|
||||||
};
|
};
|
||||||
@ -159,4 +157,13 @@ bool AnFileInfo::IsLoadMain(const JSPandaFile *jsPandaFile, const CString &entry
|
|||||||
auto it = mainEntryMap_.find(methodId);
|
auto it = mainEntryMap_.find(methodId);
|
||||||
return it != mainEntryMap_.end();
|
return it != mainEntryMap_.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AnFileInfo::AddFuncEntrySec()
|
||||||
|
{
|
||||||
|
ModuleSectionDes &des = des_[ElfBuilder::FuncEntryModuleDesIndex];
|
||||||
|
// add section
|
||||||
|
uint64_t funcEntryAddr = reinterpret_cast<uint64_t>(entries_.data());
|
||||||
|
uint32_t funcEntrySize = sizeof(FuncEntryDes) * entryNum_;
|
||||||
|
des.SetSecAddrAndSize(ElfSecName::ARK_FUNCENTRY, funcEntryAddr, funcEntrySize);
|
||||||
|
}
|
||||||
} // namespace panda::ecmascript
|
} // namespace panda::ecmascript
|
||||||
|
@ -76,6 +76,7 @@ private:
|
|||||||
bool Load(const std::string &filename);
|
bool Load(const std::string &filename);
|
||||||
void ParseFunctionEntrySection(ModuleSectionDes &moduleDes);
|
void ParseFunctionEntrySection(ModuleSectionDes &moduleDes);
|
||||||
void UpdateFuncEntries();
|
void UpdateFuncEntries();
|
||||||
|
void AddFuncEntrySec();
|
||||||
uint64_t curTextSecOffset_ {0};
|
uint64_t curTextSecOffset_ {0};
|
||||||
std::unordered_map<uint32_t, uint64_t> mainEntryMap_ {};
|
std::unordered_map<uint32_t, uint64_t> mainEntryMap_ {};
|
||||||
bool isLoad_ {false};
|
bool isLoad_ {false};
|
||||||
|
@ -25,7 +25,7 @@ public:
|
|||||||
// Release Version Snapshot Version
|
// Release Version Snapshot Version
|
||||||
// 3.2 0.0.0.x
|
// 3.2 0.0.0.x
|
||||||
// 4.0 4.0.0.x
|
// 4.0 4.0.0.x
|
||||||
static constexpr base::FileHeader::VersionType AN_VERSION = {4, 0, 0, 2};
|
static constexpr base::FileHeader::VersionType AN_VERSION = {4, 0, 0, 3};
|
||||||
static constexpr bool AN_STRICT_MATCH = true;
|
static constexpr bool AN_STRICT_MATCH = true;
|
||||||
static constexpr base::FileHeader::VersionType AI_VERSION = {4, 0, 0, 1};
|
static constexpr base::FileHeader::VersionType AI_VERSION = {4, 0, 0, 1};
|
||||||
static constexpr bool AI_STRICT_MATCH = true;
|
static constexpr bool AI_STRICT_MATCH = true;
|
||||||
|
@ -19,9 +19,10 @@
|
|||||||
#include "securec.h"
|
#include "securec.h"
|
||||||
|
|
||||||
namespace panda::ecmascript {
|
namespace panda::ecmascript {
|
||||||
void ElfBuilder::ModifyStrTabSection()
|
void ElfBuilder::AddShStrTabSection()
|
||||||
{
|
{
|
||||||
std::map<ElfSecName, std::pair<uint64_t, uint32_t>> §ions = des_[0].GetSectionsInfo();
|
std::map<ElfSecName, std::pair<uint64_t, uint32_t>> §ions =
|
||||||
|
des_[ShStrTableModuleDesIndex].GetSectionsInfo();
|
||||||
|
|
||||||
uint32_t size = 1;
|
uint32_t size = 1;
|
||||||
for (auto &s : sections_) {
|
for (auto &s : sections_) {
|
||||||
@ -29,8 +30,8 @@ void ElfBuilder::ModifyStrTabSection()
|
|||||||
size = size + str.size() + 1;
|
size = size + str.size() + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
strTabPtr_ = std::make_unique<char []>(size);
|
shStrTabPtr_ = std::make_unique<char []>(size);
|
||||||
char *dst = strTabPtr_.get();
|
char *dst = shStrTabPtr_.get();
|
||||||
dst[0] = 0x0;
|
dst[0] = 0x0;
|
||||||
uint32_t i = 1;
|
uint32_t i = 1;
|
||||||
for (auto &s: sections_) {
|
for (auto &s: sections_) {
|
||||||
@ -45,10 +46,10 @@ void ElfBuilder::ModifyStrTabSection()
|
|||||||
dst[i + copySize] = 0x0;
|
dst[i + copySize] = 0x0;
|
||||||
i = i + copySize + 1;
|
i = i + copySize + 1;
|
||||||
}
|
}
|
||||||
if (sections.find(ElfSecName::STRTAB) != sections.end()) {
|
if (sections.find(ElfSecName::SHSTRTAB) != sections.end()) {
|
||||||
sections.erase(ElfSecName::STRTAB);
|
sections.erase(ElfSecName::SHSTRTAB);
|
||||||
}
|
}
|
||||||
sections[ElfSecName::STRTAB] = std::make_pair(reinterpret_cast<uint64_t>(strTabPtr_.get()), size);
|
sections[ElfSecName::SHSTRTAB] = std::make_pair(reinterpret_cast<uint64_t>(shStrTabPtr_.get()), size);
|
||||||
if (enableSecDump_) {
|
if (enableSecDump_) {
|
||||||
DumpSection();
|
DumpSection();
|
||||||
}
|
}
|
||||||
@ -56,7 +57,7 @@ void ElfBuilder::ModifyStrTabSection()
|
|||||||
|
|
||||||
void ElfBuilder::DumpSection() const
|
void ElfBuilder::DumpSection() const
|
||||||
{
|
{
|
||||||
const std::map<ElfSecName, std::pair<uint64_t, uint32_t>> §ions = GetCurrentSecInfo();
|
const std::map<ElfSecName, std::pair<uint64_t, uint32_t>> §ions = GetFullSecInfo();
|
||||||
// dump
|
// dump
|
||||||
for (auto &s : sections) {
|
for (auto &s : sections) {
|
||||||
ElfSection section = ElfSection(s.first);
|
ElfSection section = ElfSection(s.first);
|
||||||
@ -68,24 +69,19 @@ void ElfBuilder::DumpSection() const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ElfBuilder::AddArkStackMapSection()
|
|
||||||
{
|
|
||||||
for (auto &des : des_) {
|
|
||||||
std::map<ElfSecName, std::pair<uint64_t, uint32_t>> §ions = des.GetSectionsInfo();
|
|
||||||
std::shared_ptr<uint8_t> ptr = des.GetArkStackMapSharePtr();
|
|
||||||
uint64_t arkStackMapAddr = reinterpret_cast<uint64_t>(ptr.get());
|
|
||||||
uint32_t arkStackMapSize = des.GetArkStackMapSize();
|
|
||||||
if (arkStackMapSize > 0) {
|
|
||||||
sections[ElfSecName::ARK_STACKMAP] = std::pair(arkStackMapAddr, arkStackMapSize);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ElfBuilder::ElfBuilder(const std::vector<ModuleSectionDes> &des,
|
ElfBuilder::ElfBuilder(const std::vector<ModuleSectionDes> &des,
|
||||||
const std::vector<ElfSecName> §ions): des_(des), sections_(sections)
|
const std::vector<ElfSecName> §ions): des_(des), sections_(sections)
|
||||||
{
|
{
|
||||||
AddArkStackMapSection();
|
Initialize();
|
||||||
ModifyStrTabSection();
|
AddShStrTabSection();
|
||||||
|
RemoveNotNeedSection();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ElfBuilder::Initialize()
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < des_.size(); i++) {
|
||||||
|
des_[i].AddArkStackMapSection();
|
||||||
|
}
|
||||||
sectionToAlign_ = {
|
sectionToAlign_ = {
|
||||||
{ElfSecName::RODATA, AOTFileInfo::TEXT_SEC_ALIGN},
|
{ElfSecName::RODATA, AOTFileInfo::TEXT_SEC_ALIGN},
|
||||||
{ElfSecName::RODATA_CST4, AOTFileInfo::TEXT_SEC_ALIGN},
|
{ElfSecName::RODATA_CST4, AOTFileInfo::TEXT_SEC_ALIGN},
|
||||||
@ -94,6 +90,8 @@ ElfBuilder::ElfBuilder(const std::vector<ModuleSectionDes> &des,
|
|||||||
{ElfSecName::RODATA_CST32, AOTFileInfo::TEXT_SEC_ALIGN},
|
{ElfSecName::RODATA_CST32, AOTFileInfo::TEXT_SEC_ALIGN},
|
||||||
{ElfSecName::TEXT, AOTFileInfo::TEXT_SEC_ALIGN},
|
{ElfSecName::TEXT, AOTFileInfo::TEXT_SEC_ALIGN},
|
||||||
{ElfSecName::STRTAB, 1},
|
{ElfSecName::STRTAB, 1},
|
||||||
|
{ElfSecName::SYMTAB, AOTFileInfo::DATA_SEC_ALIGN},
|
||||||
|
{ElfSecName::SHSTRTAB, AOTFileInfo::DATA_SEC_ALIGN},
|
||||||
{ElfSecName::ARK_STACKMAP, AOTFileInfo::DATA_SEC_ALIGN},
|
{ElfSecName::ARK_STACKMAP, AOTFileInfo::DATA_SEC_ALIGN},
|
||||||
{ElfSecName::ARK_FUNCENTRY, AOTFileInfo::DATA_SEC_ALIGN},
|
{ElfSecName::ARK_FUNCENTRY, AOTFileInfo::DATA_SEC_ALIGN},
|
||||||
{ElfSecName::ARK_ASMSTUB, AOTFileInfo::DATA_SEC_ALIGN},
|
{ElfSecName::ARK_ASMSTUB, AOTFileInfo::DATA_SEC_ALIGN},
|
||||||
@ -108,6 +106,8 @@ ElfBuilder::ElfBuilder(const std::vector<ModuleSectionDes> &des,
|
|||||||
{ElfSecName::RODATA_CST32, ElfSecName::TEXT},
|
{ElfSecName::RODATA_CST32, ElfSecName::TEXT},
|
||||||
{ElfSecName::TEXT, ElfSecName::TEXT},
|
{ElfSecName::TEXT, ElfSecName::TEXT},
|
||||||
{ElfSecName::STRTAB, ElfSecName::DATA},
|
{ElfSecName::STRTAB, ElfSecName::DATA},
|
||||||
|
{ElfSecName::SYMTAB, ElfSecName::DATA},
|
||||||
|
{ElfSecName::SHSTRTAB, ElfSecName::DATA},
|
||||||
{ElfSecName::ARK_STACKMAP, ElfSecName::DATA},
|
{ElfSecName::ARK_STACKMAP, ElfSecName::DATA},
|
||||||
{ElfSecName::ARK_FUNCENTRY, ElfSecName::DATA},
|
{ElfSecName::ARK_FUNCENTRY, ElfSecName::DATA},
|
||||||
{ElfSecName::ARK_ASMSTUB, ElfSecName::TEXT},
|
{ElfSecName::ARK_ASMSTUB, ElfSecName::TEXT},
|
||||||
@ -119,12 +119,12 @@ ElfBuilder::ElfBuilder(const std::vector<ModuleSectionDes> &des,
|
|||||||
{ElfSecName::DATA, llvm::ELF::PF_R},
|
{ElfSecName::DATA, llvm::ELF::PF_R},
|
||||||
};
|
};
|
||||||
|
|
||||||
RemoveNotNeedSection();
|
SetLastSection();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ElfBuilder::RemoveNotNeedSection()
|
void ElfBuilder::RemoveNotNeedSection()
|
||||||
{
|
{
|
||||||
const std::map<ElfSecName, std::pair<uint64_t, uint32_t>> §ions = GetCurrentSecInfo();
|
const std::map<ElfSecName, std::pair<uint64_t, uint32_t>> §ions = GetFullSecInfo();
|
||||||
for (size_t i = 0; i < sections_.size();) {
|
for (size_t i = 0; i < sections_.size();) {
|
||||||
if (sections.find(sections_[i]) == sections.end()) {
|
if (sections.find(sections_[i]) == sections.end()) {
|
||||||
auto it = sections_.begin() + i;
|
auto it = sections_.begin() + i;
|
||||||
@ -137,7 +137,7 @@ void ElfBuilder::RemoveNotNeedSection()
|
|||||||
|
|
||||||
ElfBuilder::~ElfBuilder()
|
ElfBuilder::~ElfBuilder()
|
||||||
{
|
{
|
||||||
strTabPtr_ = nullptr;
|
shStrTabPtr_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t ElfBuilder::GetShIndex(ElfSecName section) const
|
uint32_t ElfBuilder::GetShIndex(ElfSecName section) const
|
||||||
@ -220,7 +220,7 @@ void ElfBuilder::PackELFHeader(llvm::ELF::Elf64_Ehdr &header, uint32_t version,
|
|||||||
// number of section headers
|
// number of section headers
|
||||||
header.e_shnum = GetSecNum() + 1; // 1: skip null section and ark stackmap
|
header.e_shnum = GetSecNum() + 1; // 1: skip null section and ark stackmap
|
||||||
// section header string table index
|
// section header string table index
|
||||||
header.e_shstrndx = static_cast<llvm::ELF::Elf64_Half>(GetShIndex(ElfSecName::STRTAB));
|
header.e_shstrndx = static_cast<llvm::ELF::Elf64_Half>(GetShIndex(ElfSecName::SHSTRTAB));
|
||||||
// section header stub sec info index
|
// section header stub sec info index
|
||||||
header.e_flags = static_cast<llvm::ELF::Elf64_Word>(GetShIndex(ElfSecName::ARK_MODULEINFO));
|
header.e_flags = static_cast<llvm::ELF::Elf64_Word>(GetShIndex(ElfSecName::ARK_MODULEINFO));
|
||||||
// phr
|
// phr
|
||||||
@ -230,7 +230,7 @@ void ElfBuilder::PackELFHeader(llvm::ELF::Elf64_Ehdr &header, uint32_t version,
|
|||||||
|
|
||||||
int ElfBuilder::GetSegmentNum() const
|
int ElfBuilder::GetSegmentNum() const
|
||||||
{
|
{
|
||||||
const std::map<ElfSecName, std::pair<uint64_t, uint32_t>> §ions = GetCurrentSecInfo();
|
const std::map<ElfSecName, std::pair<uint64_t, uint32_t>> §ions = GetFullSecInfo();
|
||||||
std::set<ElfSecName> segments;
|
std::set<ElfSecName> segments;
|
||||||
for (auto &s: sections) {
|
for (auto &s: sections) {
|
||||||
ElfSection section = ElfSection(s.first);
|
ElfSection section = ElfSection(s.first);
|
||||||
@ -245,10 +245,9 @@ int ElfBuilder::GetSegmentNum() const
|
|||||||
return segments.size();
|
return segments.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
ElfSecName ElfBuilder::FindLastSection(ElfSecName segment) const
|
void ElfBuilder::SetLastSection()
|
||||||
{
|
{
|
||||||
ElfSecName ans = ElfSecName::NONE;
|
const std::map<ElfSecName, std::pair<uint64_t, uint32_t>> §ions = GetFullSecInfo();
|
||||||
const std::map<ElfSecName, std::pair<uint64_t, uint32_t>> §ions = GetCurrentSecInfo();
|
|
||||||
for (auto &s: sections) {
|
for (auto &s: sections) {
|
||||||
ElfSection section = ElfSection(s.first);
|
ElfSection section = ElfSection(s.first);
|
||||||
if (!section.ShouldDumpToAOTFile()) {
|
if (!section.ShouldDumpToAOTFile()) {
|
||||||
@ -257,12 +256,12 @@ ElfSecName ElfBuilder::FindLastSection(ElfSecName segment) const
|
|||||||
auto it = sectionToSegment_.find(s.first);
|
auto it = sectionToSegment_.find(s.first);
|
||||||
ASSERT(it != sectionToSegment_.end());
|
ASSERT(it != sectionToSegment_.end());
|
||||||
ElfSecName name = it->second;
|
ElfSecName name = it->second;
|
||||||
if (name != segment) {
|
if (name == ElfSecName::TEXT) {
|
||||||
continue;
|
lastCodeSection = std::max(lastCodeSection, s.first);
|
||||||
|
} else {
|
||||||
|
lastDataSection = std::max(lastDataSection, s.first);
|
||||||
}
|
}
|
||||||
ans = std::max(ans, s.first);
|
|
||||||
}
|
}
|
||||||
return ans;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
llvm::ELF::Elf64_Word ElfBuilder::FindShName(std::string name, uintptr_t strTabPtr, int strTabSize)
|
llvm::ELF::Elf64_Word ElfBuilder::FindShName(std::string name, uintptr_t strTabPtr, int strTabSize)
|
||||||
@ -282,21 +281,21 @@ llvm::ELF::Elf64_Word ElfBuilder::FindShName(std::string name, uintptr_t strTabP
|
|||||||
return ans;
|
return ans;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<uint64_t, uint32_t> ElfBuilder::FindStrTab() const
|
std::pair<uint64_t, uint32_t> ElfBuilder::FindShStrTab() const
|
||||||
{
|
{
|
||||||
const std::map<ElfSecName, std::pair<uint64_t, uint32_t>> §ions = GetCurrentSecInfo();
|
const std::map<ElfSecName, std::pair<uint64_t, uint32_t>> §ions = GetFullSecInfo();
|
||||||
uint64_t strTabAddr = 0;
|
uint64_t shStrTabAddr = 0;
|
||||||
uint32_t strTabSize = 0;
|
uint32_t shStrTabSize = 0;
|
||||||
for (auto &s: sections) {
|
for (auto &s: sections) {
|
||||||
uint32_t curSecSize = des_[0].GetSecSize(s.first);
|
uint32_t curSecSize = des_[ShStrTableModuleDesIndex].GetSecSize(s.first);
|
||||||
uint64_t curSecAddr = des_[0].GetSecAddr(s.first);
|
uint64_t curSecAddr = des_[ShStrTableModuleDesIndex].GetSecAddr(s.first);
|
||||||
if (s.first == ElfSecName::STRTAB) {
|
if (s.first == ElfSecName::SHSTRTAB) {
|
||||||
strTabSize = curSecSize;
|
shStrTabSize = curSecSize;
|
||||||
strTabAddr = curSecAddr;
|
shStrTabAddr = curSecAddr;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return std::make_pair(strTabAddr, strTabSize);
|
return std::make_pair(shStrTabAddr, shStrTabSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ElfBuilder::AllocateShdr(std::unique_ptr<llvm::ELF::Elf64_Shdr []> &shdr, const uint32_t &secNum)
|
void ElfBuilder::AllocateShdr(std::unique_ptr<llvm::ELF::Elf64_Shdr []> &shdr, const uint32_t &secNum)
|
||||||
@ -370,28 +369,30 @@ void ElfBuilder::MergeArkStackMapSections(std::ofstream &file,
|
|||||||
/*
|
/*
|
||||||
|
|
||||||
section of aot.an layout as follows:
|
section of aot.an layout as follows:
|
||||||
There are 5 section headers, starting at offset 0x40:
|
|
||||||
|
|
||||||
Section Headers:
|
|
||||||
[Nr] Name Type Address Offset Size EntSize Flags Link Info Align
|
|
||||||
[ 0] NULL 0000000000000000 00000000 0000000000000000 0000000000000000 0 0 0
|
|
||||||
[ 1] .text PROGBITS 0000000000001000 00001000 00000000000013a0 0000000000000000 AX 0 0 16
|
|
||||||
[ 2] .strtab STRTAB 0000000000003000 00003000 000000000000003d 0000000000000000 A 0 0 1
|
|
||||||
[ 3] .ark_funcentry PROGBITS 0000000000003040 00003040 00000000000007e0 0000000000000000 A 0 0 8
|
|
||||||
[ 4] .ark_stackmaps PROGBITS 0000000000003820 00003820 0000000000000892 0000000000000000 A 0 0 8
|
|
||||||
|
|
||||||
section of stub.an layout as follows:
|
|
||||||
There are 7 section headers, starting at offset 0x40:
|
There are 7 section headers, starting at offset 0x40:
|
||||||
|
|
||||||
Section Headers:
|
Section Headers:
|
||||||
[Nr] Name Type Address Offset Size EntSize Flags Link Info Align
|
[Nr] Name Type Address Offset Size EntSize Flags Link Info Align
|
||||||
[ 0] NULL 0000000000000000 00000000 0000000000000000 0000000000000000 0 0 0
|
[ 0] NULL 0000000000000000 00000000 0000000000000000 0000000000000000 0 0 0
|
||||||
[ 1] .text PROGBITS 0000000000001000 00001000 000000000008148e 0000000000000000 AX 0 0 16
|
[ 1] .text PROGBITS 0000000000001000 00001000 0000000000000f61 0000000000000000 AX 0 0 16
|
||||||
[ 2] .ark_asmstub PROGBITS 0000000000082490 00082490 0000000000002dc0 0000000000000000 AX 0 0 8
|
[ 2] .strtab STRTAB 0000000000002000 00002000 0000000000000187 0000000000000000 A 0 0 1
|
||||||
[ 3] .strtab STRTAB 0000000000086000 00086000 0000000000000048 0000000000000000 A 0 0 1
|
[ 3] .symtab SYMTAB 0000000000002188 00002188 00000000000001c8 0000000000000018 A 1 0 8
|
||||||
[ 4] .ark_funcentry PROGBITS 0000000000086048 00086048 0000000000023ca0 0000000000000000 A 0 0 8
|
[ 4] .shstrtab STRTAB 0000000000002350 00002350 000000000000003f 0000000000000000 A 0 0 8
|
||||||
[ 5] .ark_stackmaps PROGBITS 00000000000a9ce8 000a9ce8 00000000000119cc 0000000000000000 A 0 0 8
|
[ 5] .ark_funcentry PROGBITS 0000000000002390 00002390 00000000000006c0 0000000000000000 A 0 0 8
|
||||||
[ 6] .ark_moduleinfo PROGBITS 00000000000bb6b8 000bb6b8 000000000000003c 0000000000000000 A 0 0 8
|
[ 6] .ark_stackmaps PROGBITS 0000000000002a50 00002a50 000000000000070e 0000000000000000 A 0 0 8
|
||||||
|
|
||||||
|
section of stub.an layout as follows:
|
||||||
|
There are 7 section headers, starting at offset 0x40:
|
||||||
|
|
||||||
|
[Nr] Name Type Address Offset Size EntSize Flags Link Info Align
|
||||||
|
[ 0] NULL 0000000000000000 00000000 0000000000000000 0000000000000000 0 0 0
|
||||||
|
[ 1] .text PROGBITS 0000000000001000 00001000 000000000008225e 0000000000000000 AX 0 0 16
|
||||||
|
[ 2] .ark_asmstub PROGBITS 0000000000083260 00083260 0000000000002dc0 0000000000000000 AX 0 0 8
|
||||||
|
[ 3] .shstrtab STRTAB 0000000000087000 00087000 000000000000004c 0000000000000000 A 0 0 8
|
||||||
|
[ 4] .ark_funcentry PROGBITS 0000000000087050 00087050 0000000000023ca0 0000000000000000 A 0 0 8
|
||||||
|
[ 5] .ark_stackmaps PROGBITS 00000000000aacf0 000aacf0 0000000000011e90 0000000000000000 A 0 0 8
|
||||||
|
[ 6] .ark_moduleinfo PROGBITS 00000000000bcb80 000bcb80 000000000000003c 0000000000000000 A 0 0 8
|
||||||
|
|
||||||
Key to Flags:
|
Key to Flags:
|
||||||
W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
|
W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
|
||||||
L (link order), O (extra OS processing required), G (group), T (TLS),
|
L (link order), O (extra OS processing required), G (group), T (TLS),
|
||||||
@ -401,7 +402,7 @@ Key to Flags:
|
|||||||
void ElfBuilder::PackELFSections(std::ofstream &file)
|
void ElfBuilder::PackELFSections(std::ofstream &file)
|
||||||
{
|
{
|
||||||
uint32_t moduleNum = des_.size();
|
uint32_t moduleNum = des_.size();
|
||||||
const std::map<ElfSecName, std::pair<uint64_t, uint32_t>> §ions = GetCurrentSecInfo();
|
const std::map<ElfSecName, std::pair<uint64_t, uint32_t>> §ions = GetFullSecInfo();
|
||||||
uint32_t secNum = sections.size() + 1; // 1 : section id = 0 is null section
|
uint32_t secNum = sections.size() + 1; // 1 : section id = 0 is null section
|
||||||
std::unique_ptr<llvm::ELF::Elf64_Shdr []> shdr;
|
std::unique_ptr<llvm::ELF::Elf64_Shdr []> shdr;
|
||||||
AllocateShdr(shdr, secNum);
|
AllocateShdr(shdr, secNum);
|
||||||
@ -410,12 +411,12 @@ void ElfBuilder::PackELFSections(std::ofstream &file)
|
|||||||
file.seekp(curSecOffset);
|
file.seekp(curSecOffset);
|
||||||
|
|
||||||
int i = 1; // 1: skip null section
|
int i = 1; // 1: skip null section
|
||||||
auto strTab = FindStrTab();
|
auto shStrTab = FindShStrTab();
|
||||||
|
|
||||||
for (auto const &[secName, secInfo] : sections) {
|
for (auto const &[secName, secInfo] : sections) {
|
||||||
auto &curShdr = shdr[i];
|
auto &curShdr = shdr[i];
|
||||||
ElfSection section = ElfSection(secName);
|
ElfSection section = ElfSection(secName);
|
||||||
if (!section.ShouldDumpToStubFile()) {
|
if (!section.ShouldDumpToAOTFile()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
curShdr.sh_addralign = sectionToAlign_[secName];
|
curShdr.sh_addralign = sectionToAlign_[secName];
|
||||||
@ -429,7 +430,7 @@ void ElfBuilder::PackELFSections(std::ofstream &file)
|
|||||||
curSecOffset = AlignUp(curSecOffset, AOTFileInfo::TEXT_SEC_ALIGN);
|
curSecOffset = AlignUp(curSecOffset, AOTFileInfo::TEXT_SEC_ALIGN);
|
||||||
file.seekp(curSecOffset);
|
file.seekp(curSecOffset);
|
||||||
}
|
}
|
||||||
llvm::ELF::Elf64_Word shName = FindShName(secNameStr, strTab.first, strTab.second);
|
llvm::ELF::Elf64_Word shName = FindShName(secNameStr, shStrTab.first, shStrTab.second);
|
||||||
ASSERT(shName != static_cast<llvm::ELF::Elf64_Word>(-1));
|
ASSERT(shName != static_cast<llvm::ELF::Elf64_Word>(-1));
|
||||||
curShdr.sh_name = shName;
|
curShdr.sh_name = shName;
|
||||||
curShdr.sh_type = section.Type();
|
curShdr.sh_type = section.Type();
|
||||||
@ -458,24 +459,23 @@ void ElfBuilder::PackELFSections(std::ofstream &file)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ElfSecName::STRTAB:
|
case ElfSecName::STRTAB:
|
||||||
|
case ElfSecName::SYMTAB:
|
||||||
|
case ElfSecName::SHSTRTAB:
|
||||||
case ElfSecName::ARK_FUNCENTRY:
|
case ElfSecName::ARK_FUNCENTRY:
|
||||||
case ElfSecName::ARK_ASMSTUB: {
|
case ElfSecName::ARK_ASMSTUB: {
|
||||||
uint32_t curSecSize = GetCurrentDes().GetSecSize(secName);
|
uint32_t curSecSize = des_[FullSecIndex].GetSecSize(secName);
|
||||||
uint64_t curSecAddr = GetCurrentDes().GetSecAddr(secName);
|
uint64_t curSecAddr = des_[FullSecIndex].GetSecAddr(secName);
|
||||||
file.write(reinterpret_cast<char *>(curSecAddr), curSecSize);
|
file.write(reinterpret_cast<char *>(curSecAddr), curSecSize);
|
||||||
curSecOffset += curSecSize;
|
curSecOffset += curSecSize;
|
||||||
curShdr.sh_size = curSecSize;
|
curShdr.sh_size = curSecSize;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ElfSecName::RODATA_CST8: // dealt at the same time of ElfSecName::TEXT
|
|
||||||
break;
|
|
||||||
default: {
|
default: {
|
||||||
LOG_ECMA(FATAL) << "this section should not dump to stub file";
|
LOG_ECMA(FATAL) << "this section should not dump to an file";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ElfSecName lastSecName = FindLastSection(segName);
|
if (secName == lastDataSection || secName == lastCodeSection) {
|
||||||
if (secName == lastSecName) {
|
|
||||||
curSecOffset = AlignUp(curSecOffset, PageSize());
|
curSecOffset = AlignUp(curSecOffset, PageSize());
|
||||||
file.seekp(curSecOffset);
|
file.seekp(curSecOffset);
|
||||||
}
|
}
|
||||||
@ -505,13 +505,13 @@ There are 2 program headers, starting at offset 16384
|
|||||||
|
|
||||||
Program Headers:
|
Program Headers:
|
||||||
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flags Align
|
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flags Align
|
||||||
LOAD 0x0000000000001000 0x0000000000001000 0x0000000000001000 0x000000000000114a 0x0000000000002000 R E 0x1000
|
LOAD 0x0000000000001000 0x0000000000001000 0x0000000000001000 0x0000000000000f61 0x0000000000001000 R E 0x1000
|
||||||
LOAD 0x0000000000003000 0x0000000000003000 0x0000000000003000 0x0000000000000e54 0x0000000000001000 R 0x1000
|
LOAD 0x0000000000002000 0x0000000000002000 0x0000000000002000 0x000000000000115e 0x0000000000002000 R 0x1000
|
||||||
|
|
||||||
Section to Segment mapping:
|
Section to Segment mapping:
|
||||||
Segment Sections...
|
Segment Sections...
|
||||||
00 .rodata.cst8 .text
|
00 .text
|
||||||
01 .strtab .ark_funcentry .ark_stackmaps
|
01 .strtab .symtab .shstrtab .ark_funcentry .ark_stackmaps
|
||||||
------------------------------------------------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------------------------------------------
|
||||||
Stub Elf file
|
Stub Elf file
|
||||||
Entry point 0x0
|
Entry point 0x0
|
||||||
@ -519,13 +519,13 @@ There are 2 program headers, starting at offset 770048
|
|||||||
|
|
||||||
Program Headers:
|
Program Headers:
|
||||||
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flags Align
|
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flags Align
|
||||||
LOAD 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000085250 0x0000000000086000 R E 0x1000
|
LOAD 0x0000000000001000 0x0000000000001000 0x0000000000001000 0x0000000000085020 0x0000000000086000 R E 0x1000
|
||||||
LOAD 0x0000000000086000 0x0000000000086000 0x0000000000086000 0x00000000000356f4 0x0000000000036000 R 0x1000
|
LOAD 0x0000000000087000 0x0000000000087000 0x0000000000087000 0x0000000000035bbc 0x0000000000036000 R 0x1000
|
||||||
|
|
||||||
Section to Segment mapping:
|
Section to Segment mapping:
|
||||||
Segment Sections...
|
Segment Sections...
|
||||||
00 .text .ark_asmstub
|
00 .text .ark_asmstub
|
||||||
01 .strtab .ark_funcentry .ark_stackmaps .ark_moduleinfo
|
01 .shstrtab .ark_funcentry .ark_stackmaps .ark_moduleinfo
|
||||||
*/
|
*/
|
||||||
void ElfBuilder::PackELFSegment(std::ofstream &file)
|
void ElfBuilder::PackELFSegment(std::ofstream &file)
|
||||||
{
|
{
|
||||||
@ -542,7 +542,7 @@ void ElfBuilder::PackELFSegment(std::ofstream &file)
|
|||||||
std::map<ElfSecName, llvm::ELF::Elf64_Off> segmentToMaxAddress;
|
std::map<ElfSecName, llvm::ELF::Elf64_Off> segmentToMaxAddress;
|
||||||
std::set<ElfSecName> segments;
|
std::set<ElfSecName> segments;
|
||||||
// SecName -> addr & size
|
// SecName -> addr & size
|
||||||
const std::map<ElfSecName, std::pair<uint64_t, uint32_t>> §ions = GetCurrentSecInfo();
|
const std::map<ElfSecName, std::pair<uint64_t, uint32_t>> §ions = GetFullSecInfo();
|
||||||
llvm::ELF::Elf64_Off offset = e_phoff;
|
llvm::ELF::Elf64_Off offset = e_phoff;
|
||||||
for (auto &s: sections) {
|
for (auto &s: sections) {
|
||||||
ElfSection section = ElfSection(s.first);
|
ElfSection section = ElfSection(s.first);
|
||||||
|
@ -32,6 +32,7 @@ class ElfBuilder {
|
|||||||
public:
|
public:
|
||||||
ElfBuilder(const std::vector<ModuleSectionDes> &des, const std::vector<ElfSecName> §ions);
|
ElfBuilder(const std::vector<ModuleSectionDes> &des, const std::vector<ElfSecName> §ions);
|
||||||
~ElfBuilder();
|
~ElfBuilder();
|
||||||
|
static constexpr uint32_t FuncEntryModuleDesIndex = 0;
|
||||||
void PackELFHeader(llvm::ELF::Elf64_Ehdr &header, uint32_t version, Triple triple);
|
void PackELFHeader(llvm::ELF::Elf64_Ehdr &header, uint32_t version, Triple triple);
|
||||||
void PackELFSections(std::ofstream &elfFile);
|
void PackELFSections(std::ofstream &elfFile);
|
||||||
void PackELFSegment(std::ofstream &elfFile);
|
void PackELFSegment(std::ofstream &elfFile);
|
||||||
@ -40,13 +41,9 @@ public:
|
|||||||
void MergeArkStackMapSections(std::ofstream &elfFile,
|
void MergeArkStackMapSections(std::ofstream &elfFile,
|
||||||
std::vector<ModuleSectionDes::ModuleRegionInfo> &moduleInfo, llvm::ELF::Elf64_Off &curSecOffset);
|
std::vector<ModuleSectionDes::ModuleRegionInfo> &moduleInfo, llvm::ELF::Elf64_Off &curSecOffset);
|
||||||
static llvm::ELF::Elf64_Word FindShName(std::string name, uintptr_t strTabPtr, int strTabSize);
|
static llvm::ELF::Elf64_Word FindShName(std::string name, uintptr_t strTabPtr, int strTabSize);
|
||||||
std::map<ElfSecName, std::pair<uint64_t, uint32_t>> GetCurrentSecInfo() const
|
std::map<ElfSecName, std::pair<uint64_t, uint32_t>> GetFullSecInfo() const
|
||||||
{
|
{
|
||||||
return des_[0].GetSectionsInfo();
|
return des_[FullSecIndex].GetSectionsInfo();
|
||||||
}
|
|
||||||
ModuleSectionDes GetCurrentDes() const
|
|
||||||
{
|
|
||||||
return des_[0];
|
|
||||||
}
|
}
|
||||||
void SetEnableSecDump(bool flag)
|
void SetEnableSecDump(bool flag)
|
||||||
{
|
{
|
||||||
@ -55,23 +52,25 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
uint32_t GetShIndex(ElfSecName section) const;
|
uint32_t GetShIndex(ElfSecName section) const;
|
||||||
ElfSecName FindLastSection(ElfSecName segment) const;
|
|
||||||
int GetSegmentNum() const;
|
int GetSegmentNum() const;
|
||||||
int GetSecNum() const;
|
int GetSecNum() const;
|
||||||
unsigned GetPFlag(ElfSecName segment) const;
|
unsigned GetPFlag(ElfSecName segment) const;
|
||||||
ElfSecName GetSegmentName(const ElfSecName &secName) const;
|
ElfSecName GetSegmentName(const ElfSecName &secName) const;
|
||||||
std::pair<uint64_t, uint32_t> FindStrTab() const;
|
std::pair<uint64_t, uint32_t> FindShStrTab() const;
|
||||||
void AllocateShdr(std::unique_ptr<llvm::ELF::Elf64_Shdr []> &shdr, const uint32_t &secNum);
|
void AllocateShdr(std::unique_ptr<llvm::ELF::Elf64_Shdr []> &shdr, const uint32_t &secNum);
|
||||||
llvm::ELF::Elf64_Off ComputeEndAddrOfShdr(const uint32_t &secNum) const;
|
llvm::ELF::Elf64_Off ComputeEndAddrOfShdr(const uint32_t &secNum) const;
|
||||||
bool SupportELF();
|
bool SupportELF();
|
||||||
void AddArkStackMapSection();
|
|
||||||
void DumpSection() const;
|
void DumpSection() const;
|
||||||
void ModifyStrTabSection();
|
void AddShStrTabSection();
|
||||||
|
void Initialize();
|
||||||
|
void SetLastSection();
|
||||||
void RemoveNotNeedSection();
|
void RemoveNotNeedSection();
|
||||||
|
|
||||||
static constexpr uint32_t ASMSTUB_MODULE_NUM = 3;
|
static constexpr uint32_t ASMSTUB_MODULE_NUM = 3;
|
||||||
|
static constexpr uint32_t ShStrTableModuleDesIndex = 0;
|
||||||
|
static constexpr uint32_t FullSecIndex = 0;
|
||||||
std::vector<ModuleSectionDes> des_ {};
|
std::vector<ModuleSectionDes> des_ {};
|
||||||
std::unique_ptr<char []> strTabPtr_ {nullptr};
|
std::unique_ptr<char []> shStrTabPtr_ {nullptr};
|
||||||
std::map<ElfSecName, llvm::ELF::Elf64_Shdr> sectionToShdr_;
|
std::map<ElfSecName, llvm::ELF::Elf64_Shdr> sectionToShdr_;
|
||||||
std::map<ElfSecName, llvm::ELF::Elf64_Xword> sectionToAlign_;
|
std::map<ElfSecName, llvm::ELF::Elf64_Xword> sectionToAlign_;
|
||||||
std::map<ElfSecName, ElfSecName> sectionToSegment_;
|
std::map<ElfSecName, ElfSecName> sectionToSegment_;
|
||||||
@ -80,6 +79,8 @@ private:
|
|||||||
std::vector<ElfSecName> sections_ {};
|
std::vector<ElfSecName> sections_ {};
|
||||||
std::set<ElfSecName> segments_;
|
std::set<ElfSecName> segments_;
|
||||||
bool enableSecDump_ {false};
|
bool enableSecDump_ {false};
|
||||||
|
ElfSecName lastDataSection {ElfSecName::NONE};
|
||||||
|
ElfSecName lastCodeSection {ElfSecName::NONE};
|
||||||
};
|
};
|
||||||
} // namespace panda::ecmascript
|
} // namespace panda::ecmascript
|
||||||
#endif // ECMASCRIPT_COMPILER_AOT_FILE_ELF_BUILDER_H
|
#endif // ECMASCRIPT_COMPILER_AOT_FILE_ELF_BUILDER_H
|
||||||
|
@ -129,7 +129,7 @@ void ElfReader::ParseELFSections(std::vector<ModuleSectionDes> &des, std::vector
|
|||||||
ASSERT(static_cast<uint32_t>(secOffset) == secSize);
|
ASSERT(static_cast<uint32_t>(secOffset) == secSize);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ElfSecName::STRTAB:
|
case ElfSecName::SHSTRTAB:
|
||||||
case ElfSecName::ARK_FUNCENTRY:
|
case ElfSecName::ARK_FUNCENTRY:
|
||||||
case ElfSecName::ARK_ASMSTUB:
|
case ElfSecName::ARK_ASMSTUB:
|
||||||
case ElfSecName::ARK_MODULEINFO: {
|
case ElfSecName::ARK_MODULEINFO: {
|
||||||
@ -200,7 +200,7 @@ void ElfReader::ParseELFSections(BinaryBufferParser &parser,
|
|||||||
ASSERT(static_cast<uint32_t>(secOffset) == secSize);
|
ASSERT(static_cast<uint32_t>(secOffset) == secSize);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ElfSecName::STRTAB:
|
case ElfSecName::SHSTRTAB:
|
||||||
case ElfSecName::ARK_FUNCENTRY:
|
case ElfSecName::ARK_FUNCENTRY:
|
||||||
case ElfSecName::ARK_ASMSTUB:
|
case ElfSecName::ARK_ASMSTUB:
|
||||||
case ElfSecName::ARK_MODULEINFO: {
|
case ElfSecName::ARK_MODULEINFO: {
|
||||||
|
@ -43,6 +43,8 @@ std::string ModuleSectionDes::GetSecName(const ElfSecName idx)
|
|||||||
return ".strtab";
|
return ".strtab";
|
||||||
case ElfSecName::SYMTAB:
|
case ElfSecName::SYMTAB:
|
||||||
return ".symtab";
|
return ".symtab";
|
||||||
|
case ElfSecName::SHSTRTAB:
|
||||||
|
return ".shstrtab";
|
||||||
case ElfSecName::LLVM_STACKMAP:
|
case ElfSecName::LLVM_STACKMAP:
|
||||||
return ".llvm_stackmaps";
|
return ".llvm_stackmaps";
|
||||||
case ElfSecName::ARK_STACKMAP:
|
case ElfSecName::ARK_STACKMAP:
|
||||||
|
@ -130,6 +130,16 @@ public:
|
|||||||
return (pc >= stubStartAddr && pc <= stubEndAddr);
|
return (pc >= stubStartAddr && pc <= stubEndAddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AddArkStackMapSection()
|
||||||
|
{
|
||||||
|
std::shared_ptr<uint8_t> ptr = GetArkStackMapSharePtr();
|
||||||
|
uint64_t arkStackMapAddr = reinterpret_cast<uint64_t>(ptr.get());
|
||||||
|
uint32_t arkStackMapSize = GetArkStackMapSize();
|
||||||
|
if (arkStackMapSize > 0) {
|
||||||
|
sectionsInfo_[ElfSecName::ARK_STACKMAP] = std::pair(arkStackMapAddr, arkStackMapSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static constexpr int DECIMAL_LENS = 2;
|
static constexpr int DECIMAL_LENS = 2;
|
||||||
static constexpr int HUNDRED_TIME = 100;
|
static constexpr int HUNDRED_TIME = 100;
|
||||||
|
@ -154,7 +154,7 @@ const std::vector<ElfSecName> &StubFileInfo::GetDumpSectionNames()
|
|||||||
{
|
{
|
||||||
static const std::vector<ElfSecName> secNames = {
|
static const std::vector<ElfSecName> secNames = {
|
||||||
ElfSecName::TEXT,
|
ElfSecName::TEXT,
|
||||||
ElfSecName::STRTAB,
|
ElfSecName::SHSTRTAB,
|
||||||
ElfSecName::ARK_STACKMAP,
|
ElfSecName::ARK_STACKMAP,
|
||||||
ElfSecName::ARK_FUNCENTRY,
|
ElfSecName::ARK_FUNCENTRY,
|
||||||
ElfSecName::ARK_ASMSTUB,
|
ElfSecName::ARK_ASMSTUB,
|
||||||
|
@ -36,6 +36,7 @@ enum class ElfSecName : uint8_t {
|
|||||||
RELATEXT,
|
RELATEXT,
|
||||||
STRTAB,
|
STRTAB,
|
||||||
SYMTAB,
|
SYMTAB,
|
||||||
|
SHSTRTAB,
|
||||||
LLVM_STACKMAP,
|
LLVM_STACKMAP,
|
||||||
ARK_FUNCENTRY,
|
ARK_FUNCENTRY,
|
||||||
ARK_STACKMAP,
|
ARK_STACKMAP,
|
||||||
@ -90,7 +91,9 @@ public:
|
|||||||
value_ = ElfSecName::STRTAB;
|
value_ = ElfSecName::STRTAB;
|
||||||
} else if (str.compare(".symtab") == 0) {
|
} else if (str.compare(".symtab") == 0) {
|
||||||
value_ = ElfSecName::SYMTAB;
|
value_ = ElfSecName::SYMTAB;
|
||||||
} else if (str.compare(".llvm_stackmaps") == 0) {
|
} else if (str.compare(".shstrtab") == 0) {
|
||||||
|
value_ = ElfSecName::SHSTRTAB;
|
||||||
|
} else if (str.compare(".llvm_stackmaps") == 0) {
|
||||||
value_ = ElfSecName::LLVM_STACKMAP;
|
value_ = ElfSecName::LLVM_STACKMAP;
|
||||||
} else if (str.compare(".ark_stackmaps") == 0) {
|
} else if (str.compare(".ark_stackmaps") == 0) {
|
||||||
value_ = ElfSecName::ARK_STACKMAP;
|
value_ = ElfSecName::ARK_STACKMAP;
|
||||||
@ -108,13 +111,10 @@ public:
|
|||||||
{
|
{
|
||||||
bool saveForAot = false;
|
bool saveForAot = false;
|
||||||
switch (value_) {
|
switch (value_) {
|
||||||
case ElfSecName::RODATA:
|
|
||||||
case ElfSecName::RODATA_CST4:
|
|
||||||
case ElfSecName::RODATA_CST8:
|
|
||||||
case ElfSecName::RODATA_CST16:
|
|
||||||
case ElfSecName::RODATA_CST32:
|
|
||||||
case ElfSecName::TEXT:
|
case ElfSecName::TEXT:
|
||||||
case ElfSecName::STRTAB:
|
case ElfSecName::STRTAB:
|
||||||
|
case ElfSecName::SYMTAB:
|
||||||
|
case ElfSecName::SHSTRTAB:
|
||||||
case ElfSecName::ARK_FUNCENTRY:
|
case ElfSecName::ARK_FUNCENTRY:
|
||||||
case ElfSecName::ARK_ASMSTUB:
|
case ElfSecName::ARK_ASMSTUB:
|
||||||
case ElfSecName::ARK_STACKMAP:
|
case ElfSecName::ARK_STACKMAP:
|
||||||
@ -129,26 +129,6 @@ public:
|
|||||||
return saveForAot;
|
return saveForAot;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ShouldDumpToStubFile() const
|
|
||||||
{
|
|
||||||
bool saveForStub = false;
|
|
||||||
switch (value_) {
|
|
||||||
case ElfSecName::TEXT:
|
|
||||||
case ElfSecName::STRTAB:
|
|
||||||
case ElfSecName::ARK_FUNCENTRY:
|
|
||||||
case ElfSecName::ARK_ASMSTUB:
|
|
||||||
case ElfSecName::ARK_STACKMAP:
|
|
||||||
case ElfSecName::ARK_MODULEINFO: {
|
|
||||||
saveForStub = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return saveForStub;
|
|
||||||
}
|
|
||||||
|
|
||||||
ElfSecName Value() const
|
ElfSecName Value() const
|
||||||
{
|
{
|
||||||
return value_;
|
return value_;
|
||||||
@ -182,6 +162,7 @@ public:
|
|||||||
{ElfSecName::RELATEXT, {llvm::ELF::SHT_RELA, llvm::ELF::SHF_ALLOC | llvm::ELF::SHF_WRITE}},
|
{ElfSecName::RELATEXT, {llvm::ELF::SHT_RELA, llvm::ELF::SHF_ALLOC | llvm::ELF::SHF_WRITE}},
|
||||||
{ElfSecName::STRTAB, {llvm::ELF::SHT_STRTAB, llvm::ELF::SHF_ALLOC}},
|
{ElfSecName::STRTAB, {llvm::ELF::SHT_STRTAB, llvm::ELF::SHF_ALLOC}},
|
||||||
{ElfSecName::SYMTAB, {llvm::ELF::SHT_SYMTAB, llvm::ELF::SHF_ALLOC}},
|
{ElfSecName::SYMTAB, {llvm::ELF::SHT_SYMTAB, llvm::ELF::SHF_ALLOC}},
|
||||||
|
{ElfSecName::SHSTRTAB, {llvm::ELF::SHT_STRTAB, llvm::ELF::SHF_ALLOC}},
|
||||||
{ElfSecName::LLVM_STACKMAP, {llvm::ELF::SHT_RELA, llvm::ELF::SHF_ALLOC}},
|
{ElfSecName::LLVM_STACKMAP, {llvm::ELF::SHT_RELA, llvm::ELF::SHF_ALLOC}},
|
||||||
{ElfSecName::ARK_FUNCENTRY, {llvm::ELF::SHF_WRITE, llvm::ELF::SHF_ALLOC}},
|
{ElfSecName::ARK_FUNCENTRY, {llvm::ELF::SHF_WRITE, llvm::ELF::SHF_ALLOC}},
|
||||||
{ElfSecName::ARK_STACKMAP, {llvm::ELF::SHF_WRITE, llvm::ELF::SHF_ALLOC}},
|
{ElfSecName::ARK_STACKMAP, {llvm::ELF::SHF_WRITE, llvm::ELF::SHF_ALLOC}},
|
||||||
@ -252,6 +233,7 @@ private:
|
|||||||
ElfSecFeature::VALID_AND_SEQUENTIAL,
|
ElfSecFeature::VALID_AND_SEQUENTIAL,
|
||||||
ElfSecFeature::VALID_AND_SEQUENTIAL,
|
ElfSecFeature::VALID_AND_SEQUENTIAL,
|
||||||
ElfSecFeature::VALID_AND_SEQUENTIAL,
|
ElfSecFeature::VALID_AND_SEQUENTIAL,
|
||||||
|
ElfSecFeature::VALID_AND_SEQUENTIAL,
|
||||||
ElfSecFeature::VALID_NOT_SEQUENTIAL,
|
ElfSecFeature::VALID_NOT_SEQUENTIAL,
|
||||||
ElfSecFeature::VALID_NOT_SEQUENTIAL,
|
ElfSecFeature::VALID_NOT_SEQUENTIAL,
|
||||||
};
|
};
|
||||||
|
@ -87,7 +87,10 @@ void PageClearTag(void *mem, size_t size)
|
|||||||
|
|
||||||
void PageProtect(void *mem, size_t size, int prot)
|
void PageProtect(void *mem, size_t size, int prot)
|
||||||
{
|
{
|
||||||
mprotect(mem, size, prot);
|
int ret = mprotect(mem, size, prot);
|
||||||
|
if (ret != 0) {
|
||||||
|
LOG_ECMA(ERROR) << "PageProtect change to " << prot << " failed, error code is " << errno;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t PageSize()
|
size_t PageSize()
|
||||||
|
Loading…
Reference in New Issue
Block a user