Reason:fix aot codegen bug

Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/IB586E?from=project-issue
Test: Build & Boot devices

Signed-off-by: wupengyong <wupengyong@huawei.com>
Change-Id: I23f0683f54e4e47843e1d4141a9329f3f096ed1f
This commit is contained in:
wupengyong 2024-11-19 21:38:54 +08:00
parent e404d38c69
commit ec19706fef
5 changed files with 11 additions and 8 deletions

View File

@ -36,6 +36,7 @@ public:
virtual ~AOTFileInfo() = default;
static constexpr uint32_t TEXT_SEC_ALIGN = 16;
static constexpr uint32_t RODATA_SEC_ALIGN = 16;
static constexpr uint32_t DATA_SEC_ALIGN = 8;
static constexpr uint32_t PAGE_ALIGN = 4096;

View File

@ -379,7 +379,7 @@ void ElfBuilder::MergeTextSections(std::ofstream &file,
curInfo.textSize = curSecSize;
curSecOffset += curSecSize;
if (rodataSizeAfterText != 0) {
curSecOffset = AlignUp(curSecOffset, AOTFileInfo::DATA_SEC_ALIGN);
curSecOffset = AlignUp(curSecOffset, AOTFileInfo::RODATA_SEC_ALIGN);
file.seekp(curSecOffset);
file.write(reinterpret_cast<char *>(rodataAddrAfterText), rodataSizeAfterText);
curInfo.rodataSizeAfterText = rodataSizeAfterText;

View File

@ -293,7 +293,7 @@ void ElfReader::SeparateTextSections(std::vector<ModuleSectionDes> &des,
des[i].SetSecAddrAndSize(ElfSecName::TEXT, secAddr + secOffset, textSize);
secOffset += textSize;
if (rodataSizeAfterText != 0) {
secOffset = AlignUp(secOffset, AOTFileInfo::DATA_SEC_ALIGN);
secOffset = AlignUp(secOffset, AOTFileInfo::RODATA_SEC_ALIGN);
secOffset += rodataSizeAfterText;
}
}
@ -365,7 +365,7 @@ void ElfReader::SeparateTextSections(BinaryBufferParser &parser,
des[i].SetSecAddrAndSize(ElfSecName::TEXT, secAddr + secOffset, textSize);
secOffset += textSize;
if (rodataSizeAfterText != 0) {
secOffset = AlignUp(secOffset, AOTFileInfo::DATA_SEC_ALIGN);
secOffset = AlignUp(secOffset, AOTFileInfo::RODATA_SEC_ALIGN);
parser.ParseBuffer(reinterpret_cast<void *>(secAddr + secOffset), rodataSizeAfterText,
curShOffset + secOffset);
secOffset += rodataSizeAfterText;

View File

@ -221,8 +221,10 @@ uint8_t *CodeInfo::AllocaDataSectionImp(uintptr_t size, const char *sectionName,
: (this->*allocaInNotReqSecBuffer)(size, AOTFileInfo::PAGE_ALIGN);
alreadyPageAlign_ = true;
} else {
addr = curSec.isSequentialAOTSec() ? (this->*allocaInReqSecBuffer)(size, AOTFileInfo::DATA_SEC_ALIGN)
: (this->*allocaInNotReqSecBuffer)(size, AOTFileInfo::DATA_SEC_ALIGN);
uint32_t alignedSize = curSec.InRodataSection() ? AOTFileInfo::RODATA_SEC_ALIGN
: AOTFileInfo::DATA_SEC_ALIGN;
addr = curSec.isSequentialAOTSec() ? (this->*allocaInReqSecBuffer)(size, alignedSize)
: (this->*allocaInNotReqSecBuffer)(size, alignedSize);
}
} else {
addr = curSec.isSequentialAOTSec() ? (this->*allocaInReqSecBuffer)(size, 0)

View File

@ -203,7 +203,7 @@ void Module::CollectFuncEntryInfo(std::map<uintptr_t, std::string> &addr2name, A
}
aotInfo.UpdateCurTextSecOffset(textSize);
if (rodataSizeAfterText != 0) {
aotInfo.AlignTextSec(AOTFileInfo::DATA_SEC_ALIGN);
aotInfo.AlignTextSec(AOTFileInfo::RODATA_SEC_ALIGN);
aotInfo.UpdateCurTextSecOffset(rodataSizeAfterText);
}
}
@ -267,7 +267,7 @@ void Module::CollectFuncEntryInfoByLiteCG(std::map<uintptr_t, std::string> &addr
}
aotInfo.UpdateCurTextSecOffset(textSize);
if (rodataSizeAfterText != 0) {
aotInfo.AlignTextSec(AOTFileInfo::DATA_SEC_ALIGN);
aotInfo.AlignTextSec(AOTFileInfo::RODATA_SEC_ALIGN);
aotInfo.UpdateCurTextSecOffset(rodataSizeAfterText);
}
}
@ -434,7 +434,7 @@ uint64_t AOTFileGenerator::RollbackTextSize(Module *module)
textStart = aotInfo_.GetCurTextSecOffset() - textSize;
} else {
textStart = aotInfo_.GetCurTextSecOffset() - textSize - rodataSizeAfterText;
textStart = AlignDown(textStart, AOTFileInfo::DATA_SEC_ALIGN);
textStart = AlignDown(textStart, AOTFileInfo::RODATA_SEC_ALIGN);
}
return textStart;
}