!10290 fix aot codegen bug

Merge pull request !10290 from wpy111/master
This commit is contained in:
openharmony_ci 2024-11-22 06:58:01 +00:00 committed by Gitee
commit 98ef9ff01d
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
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);
}
}
@ -439,7 +439,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;
}