From 36215529b8a999c228b11796764ae5ac7f3269b2 Mon Sep 17 00:00:00 2001 From: t00595839 Date: Wed, 7 Feb 2024 22:34:22 -0800 Subject: [PATCH 1/7] support func symbol Signed-off-by: t00595839 Change-Id: Id6b0935f5df9c624cf608a6b492ce71ec19c84da --- ecmascript/compiler/aot_file/an_file_info.cpp | 4 +- ecmascript/compiler/aot_file/an_file_info.h | 2 +- ecmascript/compiler/aot_file/elf_builder.cpp | 56 +++++++++++++++++-- ecmascript/compiler/aot_file/elf_builder.h | 5 +- .../maple/maple_be/include/cg/cg_option.h | 16 ++++++ .../maple/maple_be/include/cg/cg_options.h | 1 + .../codegen/maple/maple_be/include/cg/ifile.h | 4 +- .../cg/x86_64/assembler/elf_assembler.h | 1 + .../include/cg/x86_64/assembler/elf_file.h | 10 +++- .../src/cg/aarch64/aarch64_obj_emitter.cpp | 6 -- .../maple/maple_be/src/cg/cg_option.cpp | 8 ++- .../maple/maple_be/src/cg/cg_options.cpp | 5 ++ .../maple/maple_be/src/cg/obj_emit.cpp | 18 ++++-- .../maple_be/src/cg/x86_64/elf_assembler.cpp | 29 +++++++--- .../maple_be/src/cg/x86_64/x64_emitter.cpp | 12 +--- ecmascript/compiler/file_generators.cpp | 2 +- 16 files changed, 137 insertions(+), 42 deletions(-) diff --git a/ecmascript/compiler/aot_file/an_file_info.cpp b/ecmascript/compiler/aot_file/an_file_info.cpp index 5d12a2e9a5..1e27a53ea5 100644 --- a/ecmascript/compiler/aot_file/an_file_info.cpp +++ b/ecmascript/compiler/aot_file/an_file_info.cpp @@ -26,7 +26,7 @@ #include "macros.h" namespace panda::ecmascript { -void AnFileInfo::Save(const std::string &filename, Triple triple) +void AnFileInfo::Save(const std::string &filename, Triple triple, bool useLiteCG) { std::string realPath; if (!RealPath(filename, realPath, false)) { @@ -39,7 +39,7 @@ void AnFileInfo::Save(const std::string &filename, Triple triple) SetStubNum(entries_.size()); AddFuncEntrySec(); - ElfBuilder builder(des_, GetDumpSectionNames()); + ElfBuilder builder(des_, GetDumpSectionNames(), useLiteCG); llvm::ELF::Elf64_Ehdr header; builder.PackELFHeader(header, base::FileHeaderBase::ToVersionNumber(AOTFileVersion::AN_VERSION), triple); file.write(reinterpret_cast(&header), sizeof(llvm::ELF::Elf64_Ehdr)); diff --git a/ecmascript/compiler/aot_file/an_file_info.h b/ecmascript/compiler/aot_file/an_file_info.h index 3caada9b21..6cf0050402 100644 --- a/ecmascript/compiler/aot_file/an_file_info.h +++ b/ecmascript/compiler/aot_file/an_file_info.h @@ -24,7 +24,7 @@ public: using FuncEntryIndexKey = std::pair; // (compilefileName, MethodID) AnFileInfo() = default; ~AnFileInfo() override = default; - void PUBLIC_API Save(const std::string &filename, Triple triple); + void PUBLIC_API Save(const std::string &filename, Triple triple, bool useLiteCG = false); void AddModuleDes(ModuleSectionDes &moduleDes) { des_.emplace_back(moduleDes); diff --git a/ecmascript/compiler/aot_file/elf_builder.cpp b/ecmascript/compiler/aot_file/elf_builder.cpp index 73ee2f3c07..39552088e4 100644 --- a/ecmascript/compiler/aot_file/elf_builder.cpp +++ b/ecmascript/compiler/aot_file/elf_builder.cpp @@ -101,7 +101,7 @@ void ElfBuilder::DumpSection() const } ElfBuilder::ElfBuilder(const std::vector &des, - const std::vector §ions): des_(des), sections_(sections) + const std::vector §ions, bool useLiteCG): des_(des), sections_(sections), useLiteCG_(useLiteCG) { Initialize(); AddShStrTabSection(); @@ -468,6 +468,44 @@ void ElfBuilder::MergeArkStackMapSections(std::ofstream &file, } } +void ElfBuilder::MergeSymTabSectionsForLiteCG(std::ofstream &file, + std::vector &moduleInfo, + llvm::ELF::Elf64_Off &curSecOffset) +{ + // here we only support func symbol here. + using Elf64_Sym = llvm::ELF::Elf64_Sym; + uint64_t lastStrIdx = 0; + // put und at first pos in sym tab. + Elf64_Sym und; + file.write(reinterpret_cast(&und), sizeof(und)); + curSecOffset += sizeof(und); + for (size_t i = 0; i < des_.size(); ++i) { + ModuleSectionDes &des = des_[i]; + ModuleSectionDes::ModuleRegionInfo &curInfo = moduleInfo[i]; + uint64_t textSecOffset = sectionToShdr_[ElfSecName::TEXT].sh_offset; + uint32_t curSecSize = des.GetSecSize(ElfSecName::SYMTAB); + uint64_t curSecAddr = des.GetSecAddr(ElfSecName::SYMTAB); + uint32_t index = des.GetStartIndex(); + uint32_t cnt = des.GetFuncCount(); + uint32_t textSecIndex = GetShIndex(ElfSecName::TEXT); + curInfo.startIndex = index; + curInfo.funcCount = cnt; + Elf64_Sym *syms = reinterpret_cast(curSecAddr); + size_t n = curSecSize / sizeof(Elf64_Sym); + for (size_t j = 0; j < n; ++j) { + Elf64_Sym* sy = &syms[j]; + if (sy->getType() == llvm::ELF::STT_FUNC) { + sy->st_value += textSecOffset; + sy->st_name += lastStrIdx; + sy->st_shndx = static_cast(textSecIndex); + } + } + lastStrIdx += des.GetSecSize(ElfSecName::STRTAB); + file.write(reinterpret_cast(curSecAddr), curSecSize); + curSecOffset += curSecSize; + } +} + void ElfBuilder::FixSymtab(llvm::ELF::Elf64_Shdr* shdr) { using Elf64_Sym = llvm::ELF::Elf64_Sym; @@ -611,11 +649,17 @@ void ElfBuilder::PackELFSections(std::ofstream &file) break; } case ElfSecName::SYMTAB: { - FixSymtab(&curShdr); - uint32_t curSize = curSecOffset; - uint32_t asmSecIndex = GetShIndex(ElfSecName::ARK_ASMSTUB); - MergeSymtabSections(file, moduleInfo, curSecOffset, shdr[asmSecIndex].sh_offset); - curShdr.sh_size = curSecOffset - curSize; + if (useLiteCG_) { + uint32_t curSize = curSecOffset; + MergeSymTabSectionsForLiteCG(file, moduleInfo, curSecOffset); + curShdr.sh_size = curSecOffset - curSize; + } else { + FixSymtab(&curShdr); + uint32_t curSize = curSecOffset; + uint32_t asmSecIndex = GetShIndex(ElfSecName::ARK_ASMSTUB); + MergeSymtabSections(file, moduleInfo, curSecOffset, shdr[asmSecIndex].sh_offset); + curShdr.sh_size = curSecOffset - curSize; + } break; } case ElfSecName::SHSTRTAB: diff --git a/ecmascript/compiler/aot_file/elf_builder.h b/ecmascript/compiler/aot_file/elf_builder.h index 6a74f995ad..6fd8630f6d 100644 --- a/ecmascript/compiler/aot_file/elf_builder.h +++ b/ecmascript/compiler/aot_file/elf_builder.h @@ -30,7 +30,7 @@ class ModuleSectionDes; class ElfBuilder { public: - ElfBuilder(const std::vector &des, const std::vector §ions); + ElfBuilder(const std::vector &des, const std::vector §ions, bool useLiteCG = false); ~ElfBuilder(); static constexpr uint32_t FuncEntryModuleDesIndex = 0; void PackELFHeader(llvm::ELF::Elf64_Ehdr &header, uint32_t version, Triple triple); @@ -40,6 +40,8 @@ public: std::vector &moduleInfo, llvm::ELF::Elf64_Off &curSecOffset); void MergeArkStackMapSections(std::ofstream &elfFile, std::vector &moduleInfo, llvm::ELF::Elf64_Off &curSecOffset); + void MergeSymTabSectionsForLiteCG(std::ofstream &file, + std::vector &moduleInfo, llvm::ELF::Elf64_Off &curSecOffset); void MergeStrtabSections(std::ofstream &elfFile, std::vector &moduleInfo, llvm::ELF::Elf64_Off &curSecOffset); void MergeSymtabSections(std::ofstream &elfFile, std::vector &moduleInfo, @@ -91,6 +93,7 @@ private: bool enableSecDump_ {false}; ElfSecName lastDataSection {ElfSecName::NONE}; ElfSecName lastCodeSection {ElfSecName::NONE}; + bool useLiteCG_ {false}; }; } // namespace panda::ecmascript #endif // ECMASCRIPT_COMPILER_AOT_FILE_ELF_BUILDER_H diff --git a/ecmascript/compiler/codegen/maple/maple_be/include/cg/cg_option.h b/ecmascript/compiler/codegen/maple/maple_be/include/cg/cg_option.h index 9071c4b050..4e72e9e8cb 100644 --- a/ecmascript/compiler/codegen/maple/maple_be/include/cg/cg_option.h +++ b/ecmascript/compiler/codegen/maple/maple_be/include/cg/cg_option.h @@ -793,6 +793,21 @@ public: doCGSSA = true; } + static void EnableSupportFuncSymbol() + { + supportFuncSymbol = true; + } + + static void DisableSupportFuncSymbol() + { + supportFuncSymbol = false; + } + + static bool addFuncSymbol() + { + return supportFuncSymbol; + } + static bool DoCGSSA() { return doCGSSA; @@ -1711,6 +1726,7 @@ private: static uint32 funcAlignPow; static bool doOptimizedFrameLayout; static bool doCgirVerify; + static bool supportFuncSymbol; }; } /* namespace maplebe */ diff --git a/ecmascript/compiler/codegen/maple/maple_be/include/cg/cg_options.h b/ecmascript/compiler/codegen/maple/maple_be/include/cg/cg_options.h index 2b971372db..6e38b7ad0f 100644 --- a/ecmascript/compiler/codegen/maple/maple_be/include/cg/cg_options.h +++ b/ecmascript/compiler/codegen/maple/maple_be/include/cg/cg_options.h @@ -131,6 +131,7 @@ extern maplecl::Option loopAlignPow; extern maplecl::Option jumpAlignPow; extern maplecl::Option funcAlignPow; extern maplecl::Option optimizedFrameLayout; +extern maplecl::Option supportFuncSymbol; } // namespace opts::cg diff --git a/ecmascript/compiler/codegen/maple/maple_be/include/cg/ifile.h b/ecmascript/compiler/codegen/maple/maple_be/include/cg/ifile.h index c8c9b9929b..99a8a22850 100644 --- a/ecmascript/compiler/codegen/maple/maple_be/include/cg/ifile.h +++ b/ecmascript/compiler/codegen/maple/maple_be/include/cg/ifile.h @@ -360,7 +360,6 @@ public: SetEntSize(sizeof(Symbol)); SetLink(link); SetInfo(1); - AppendSymbol({0, 0, 0, 0, 0, 0}); } ~SymbolSection() = default; @@ -400,6 +399,9 @@ public: return symbolIdxMap.count(symIdx) != 0; } + const char *GetAddr() { + return reinterpret_cast(symbols.data()); + } private: MapleAllocator alloc; MapleVector symbols; diff --git a/ecmascript/compiler/codegen/maple/maple_be/include/cg/x86_64/assembler/elf_assembler.h b/ecmascript/compiler/codegen/maple/maple_be/include/cg/x86_64/assembler/elf_assembler.h index 9b2753c78e..20dfc5c8cf 100644 --- a/ecmascript/compiler/codegen/maple/maple_be/include/cg/x86_64/assembler/elf_assembler.h +++ b/ecmascript/compiler/codegen/maple/maple_be/include/cg/x86_64/assembler/elf_assembler.h @@ -593,6 +593,7 @@ private: void WriteElfFile(); void AppendSecSymsToSymTabSec(); void AppendSymsToSymTabSec(); + void AppendGlobalSymsToSymTabSec(); private: std::vector codeBuff; diff --git a/ecmascript/compiler/codegen/maple/maple_be/include/cg/x86_64/assembler/elf_file.h b/ecmascript/compiler/codegen/maple/maple_be/include/cg/x86_64/assembler/elf_file.h index bc7a9e2e28..eb93dfb16d 100644 --- a/ecmascript/compiler/codegen/maple/maple_be/include/cg/x86_64/assembler/elf_file.h +++ b/ecmascript/compiler/codegen/maple/maple_be/include/cg/x86_64/assembler/elf_file.h @@ -249,7 +249,6 @@ public: SetEntSize(sizeof(Symbol)); SetLink(link); SetInfo(1); - AppendSymbol({0, 0, 0, 0, 0, 0}); } ~SymbolSection() = default; @@ -289,6 +288,15 @@ public: return symbolIdxMap.count(symIdx) != 0; } + uint32 GetDataSize() const + { + return symbols.size() * sizeof(Symbol); + } + + const char* GetAddr() { + return reinterpret_cast(symbols.data()); + } + private: std::vector symbols; std::unordered_map symbolIdxMap; diff --git a/ecmascript/compiler/codegen/maple/maple_be/src/cg/aarch64/aarch64_obj_emitter.cpp b/ecmascript/compiler/codegen/maple/maple_be/src/cg/aarch64/aarch64_obj_emitter.cpp index 423da6ae96..1c455d9e3f 100644 --- a/ecmascript/compiler/codegen/maple/maple_be/src/cg/aarch64/aarch64_obj_emitter.cpp +++ b/ecmascript/compiler/codegen/maple/maple_be/src/cg/aarch64/aarch64_obj_emitter.cpp @@ -284,12 +284,6 @@ void AArch64ObjEmitter::AppendGlobalLabel() void AArch64ObjEmitter::AppendSymsToSymTabSec() { - // section symbol - AddSymbol(".text", textSection->GetDataSize(), *textSection, 0); - /* Indexed by the inverse of the section index. */ - symbolTabSection->AppendIdxInSymbols(~textSection->GetIndex() + 1); - AddSymbol(".data", dataSection->GetDataSize(), *dataSection, 0); - symbolTabSection->AppendIdxInSymbols(~dataSection->GetIndex() + 1); Address offset = 0; auto &contents = GetContents(); diff --git a/ecmascript/compiler/codegen/maple/maple_be/src/cg/cg_option.cpp b/ecmascript/compiler/codegen/maple/maple_be/src/cg/cg_option.cpp index 59e50eaacd..96490552af 100644 --- a/ecmascript/compiler/codegen/maple/maple_be/src/cg/cg_option.cpp +++ b/ecmascript/compiler/codegen/maple/maple_be/src/cg/cg_option.cpp @@ -63,6 +63,7 @@ uint32 CGOptions::loopAlignPow = 4; uint32 CGOptions::jumpAlignPow = 5; uint32 CGOptions::funcAlignPow = 5; bool CGOptions::doOptimizedFrameLayout = true; +bool CGOptions::supportFuncSymbol = false; #if TARGAARCH64 || TARGRISCV64 bool CGOptions::useBarriersForVolatile = false; #else @@ -178,6 +179,10 @@ bool CGOptions::SolveOptions(bool isDebug) } } + if (opts::cg::supportFuncSymbol.IsEnabledByUser()) { + opts::cg::supportFuncSymbol ? EnableSupportFuncSymbol() : DisableSupportFuncSymbol(); + } + if (opts::cg::quiet.IsEnabledByUser()) { SetQuiet(true); } @@ -796,7 +801,8 @@ void CGOptions::EnableLiteCG() doWriteRefFieldOpt = false; doAlignAnalysis = false; doCondBrAlign = false; - + supportFuncSymbol = false; + ClearOption(kUseStackProtectorStrong); ClearOption(kUseStackProtectorAll); ClearOption(kConstFold); diff --git a/ecmascript/compiler/codegen/maple/maple_be/src/cg/cg_options.cpp b/ecmascript/compiler/codegen/maple/maple_be/src/cg/cg_options.cpp index 97330fe148..a390fc1936 100644 --- a/ecmascript/compiler/codegen/maple/maple_be/src/cg/cg_options.cpp +++ b/ecmascript/compiler/codegen/maple/maple_be/src/cg/cg_options.cpp @@ -60,6 +60,11 @@ maplecl::Option replaceAsm({"--replaceasm"}, " --no-replaceasm\n", {cgCategory}, maplecl::DisableWith("--no-replaceasm")); +maplecl::Option supportFuncSymbol({"--enable-func-symbol"}, + " --enable-func-symbol \tenable function symbols in symbol table\n" + " --disable-func-symbol\n", + {cgCategory}, maplecl::DisableWith("--disable-func-symbol")); + maplecl::Option generalRegOnly( {"--general-reg-only"}, " --general-reg-only \tdisable floating-point or Advanced SIMD registers\n" diff --git a/ecmascript/compiler/codegen/maple/maple_be/src/cg/obj_emit.cpp b/ecmascript/compiler/codegen/maple/maple_be/src/cg/obj_emit.cpp index 11d2a849c0..e18d46ecc9 100644 --- a/ecmascript/compiler/codegen/maple/maple_be/src/cg/obj_emit.cpp +++ b/ecmascript/compiler/codegen/maple/maple_be/src/cg/obj_emit.cpp @@ -115,9 +115,18 @@ void ObjEmitter::WriteObjFile() const auto &emitMemorymanager = CGOptions::GetInstance().GetEmitMemoryManager(); if (emitMemorymanager.codeSpace != nullptr) { DEBUG_ASSERT(textSection != nullptr, "textSection has not been initialized"); - uint8 *memSpace = emitMemorymanager.allocateDataSection(emitMemorymanager.codeSpace, - textSection->GetDataSize(), textSection->GetAlign(), textSection->GetName().c_str()); - memcpy_s(memSpace, textSection->GetDataSize(), textSection->GetData().data(), textSection->GetDataSize()); + uint8 *codeSpace = emitMemorymanager.allocateDataSection(emitMemorymanager.codeSpace, + textSection->GetDataSize(), textSection->GetAlign(), textSection->GetName().c_str()); + memcpy_s(codeSpace, textSection->GetDataSize(), textSection->GetData().data(), textSection->GetDataSize()); + if (CGOptions::addFuncSymbol()) { + uint8 *symtabSpace = emitMemorymanager.allocateDataSection(emitMemorymanager.codeSpace, + symbolTabSection->GetDataSize(), symbolTabSection->GetAlign(), symbolTabSection->GetName().c_str()); + memcpy_s(symtabSpace, symbolTabSection->GetDataSize() , symbolTabSection->GetAddr(), symbolTabSection->GetDataSize()); + uint8 *stringTabSpace = emitMemorymanager.allocateDataSection(emitMemorymanager.codeSpace, + strTabSection->GetDataSize(), strTabSection->GetAlign(), strTabSection->GetName().c_str()); + memcpy_s(stringTabSpace, strTabSection->GetDataSize(), strTabSection->GetData().data(), strTabSection->GetDataSize()); + } + return; } /* write header */ @@ -150,10 +159,11 @@ void ObjEmitter::AddSymbol(const std::string &name, Word size, const Section &se void ObjEmitter::AddFuncSymbol(const MapleString &name, Word size, Address value) { + uint32 lastModulePC = cg->GetMIRModule()->GetLastModulePC(); auto symbolStrIndex = strTabSection->AddString(name); symbolTabSection->AppendSymbol({static_cast(symbolStrIndex), static_cast((STB_GLOBAL << k4BitSize) + (STT_FUNC & 0xf)), 0, - textSection->GetIndex(), value, size}); + textSection->GetIndex(), value + lastModulePC, size}); } void ObjEmitter::ClearData() diff --git a/ecmascript/compiler/codegen/maple/maple_be/src/cg/x86_64/elf_assembler.cpp b/ecmascript/compiler/codegen/maple/maple_be/src/cg/x86_64/elf_assembler.cpp index 72ef07ebfd..05bd9b151e 100644 --- a/ecmascript/compiler/codegen/maple/maple_be/src/cg/x86_64/elf_assembler.cpp +++ b/ecmascript/compiler/codegen/maple/maple_be/src/cg/x86_64/elf_assembler.cpp @@ -180,7 +180,7 @@ void ElfAssembler::EmitFunctionFoot(int64 symIdx, SymbolAttr funcAttr) auto nameIndex = strTabSection->AddString(symbolName); AddSymToSymTab({static_cast(nameIndex), static_cast((funcSymType << kLeftShift4Bits) + (STT_FUNC & 0xf)), 0, textSection->GetIndex(), - funcSymValue, funcSymSize}, + funcSymValue + lastModulePC, funcSymSize}, symIdx); } @@ -309,7 +309,7 @@ void ElfAssembler::PostEmitVariable(int64 symIdx, SymbolAttr symAttr, uint64 siz void ElfAssembler::FinalizeFileInfo() { - AppendSymsToSymTabSec(); + AppendGlobalSymsToSymTabSec(); HandleTextSectionFixup(); HandleDataSectionFixup(); HandleRodataSectionFixup(); @@ -782,9 +782,6 @@ void ElfAssembler::AppendRela(const Label &label, const std::pairExistSymInSymbols(labelIdx)) { - symbolTabSection->AppendSymbol({static_cast(strTabSection->AddString(GetNameFromSymMap(labelIdx))), - static_cast((STB_GLOBAL << kLeftShift4Bits) + (STT_NOTYPE & 0xf)), 0, - 0, 0, 0}); symbolTabSection->AppendIdxInSymbols(labelIdx); } relaSection->AppendRela({offsetPair.first, @@ -950,9 +947,17 @@ void ElfAssembler::WriteElfFile() const auto &emitMemoryManager = maplebe::CGOptions::GetInstance().GetEmitMemoryManager(); if (emitMemoryManager.codeSpace != nullptr) { DEBUG_ASSERT(textSection != nullptr, "textSection has not been initialized"); - uint8 *memSpace = emitMemoryManager.allocateDataSection(emitMemoryManager.codeSpace, + uint8 *codeSpace = emitMemoryManager.allocateDataSection(emitMemoryManager.codeSpace, textSection->GetSectionSize(), textSection->GetAlign(), textSection->GetName()); - memcpy_s(memSpace, textSection->GetSectionSize(), textSection->GetData().data(), textSection->GetDataSize()); + memcpy_s(codeSpace, textSection->GetSectionSize(), textSection->GetData().data(), textSection->GetDataSize()); + if (CGOptions::addFuncSymbol()) { + uint8 *symtabSpace = emitMemoryManager.allocateDataSection(emitMemoryManager.codeSpace, + symbolTabSection->GetDataSize(), symbolTabSection->GetAlign(), symbolTabSection->GetName().c_str()); + memcpy_s(symtabSpace, symbolTabSection->GetDataSize() , symbolTabSection->GetAddr(), symbolTabSection->GetDataSize()); + uint8 *stringTabSpace = emitMemoryManager.allocateDataSection(emitMemoryManager.codeSpace, + strTabSection->GetDataSize(), strTabSection->GetAlign(), strTabSection->GetName().c_str()); + memcpy_s(stringTabSpace, strTabSection->GetDataSize(), strTabSection->GetData().data(), strTabSection->GetDataSize()); + } return; } @@ -996,6 +1001,16 @@ void ElfAssembler::AppendSecSymsToSymTabSec() } } +void ElfAssembler::AppendGlobalSymsToSymTabSec() +{ + for (auto elem : symTab) { + const Symbol &symbol = elem.first; + int64 symIdx = elem.second; + symbolTabSection->AppendSymbol(symbol); + symbolTabSection->AppendIdxInSymbols(symIdx); + } +} + void ElfAssembler::AppendSymsToSymTabSec() { /* emit local symbol */ diff --git a/ecmascript/compiler/codegen/maple/maple_be/src/cg/x86_64/x64_emitter.cpp b/ecmascript/compiler/codegen/maple/maple_be/src/cg/x86_64/x64_emitter.cpp index 30bc1b0906..24c035615f 100644 --- a/ecmascript/compiler/codegen/maple/maple_be/src/cg/x86_64/x64_emitter.cpp +++ b/ecmascript/compiler/codegen/maple/maple_be/src/cg/x86_64/x64_emitter.cpp @@ -1593,14 +1593,7 @@ void X64Emitter::EmitFunctionFoot(CGFunc &cgFunc) { const MIRSymbol *funcSymbol = cgFunc.GetFunction().GetFuncSymbol(); uint32 symIdx = funcSymbol->GetNameStrIdx().get(); - SymbolAttr funcAttr = kSALocal; - if (funcSymbol->GetFunction()->GetAttr(FUNCATTR_weak)) { - funcAttr = kSAWeak; - } else if (funcSymbol->GetFunction()->GetAttr(FUNCATTR_local)) { - funcAttr = kSALocal; - } else if (!funcSymbol->GetFunction()->GetAttr(FUNCATTR_static)) { - funcAttr = kSAGlobal; - } + SymbolAttr funcAttr = kSAGlobal; assmbler.EmitFunctionFoot(symIdx, funcAttr); } @@ -2158,9 +2151,6 @@ void X64Emitter::Run(CGFunc &cgFunc) assmbler.SetLastModulePC(cgFunc.GetMirModule().GetLastModulePC()); - /* emit local variable(s) if exists */ - EmitLocalVariable(cgFunc); - /* emit function header */ EmitFunctionHeader(cgFunc); diff --git a/ecmascript/compiler/file_generators.cpp b/ecmascript/compiler/file_generators.cpp index db57885dbf..e451c35f0d 100644 --- a/ecmascript/compiler/file_generators.cpp +++ b/ecmascript/compiler/file_generators.cpp @@ -584,7 +584,7 @@ void AOTFileGenerator::SaveAOTFile(const std::string &filename, const std::strin PrintMergedCodeComment(); GenerateMergedStackmapSection(); aotInfo_.GenerateMethodToEntryIndexMap(); - aotInfo_.Save(filename, cfg_.GetTriple()); + aotInfo_.Save(filename, cfg_.GetTriple(), useLiteCG_); if (!panda::ecmascript::SetFileModeAsDefault(filename)) { LOG_COMPILER(ERROR) << "Fail to set an file mode:" << filename; } -- Gitee From 9b110bed133ab3097e152264d5c560ec5c70b7ec Mon Sep 17 00:00:00 2001 From: t00595839 Date: Wed, 7 Feb 2024 23:14:22 -0800 Subject: [PATCH 2/7] clean code Signed-off-by: t00595839 Change-Id: I2832d37478a23febfc4df47b8ab4159f17b1bf92 --- ecmascript/compiler/aot_file/elf_builder.cpp | 6 +++--- ecmascript/compiler/aot_file/elf_builder.h | 3 ++- .../codegen/maple/maple_be/include/cg/ifile.h | 3 ++- .../maple_be/include/cg/x86_64/assembler/elf_file.h | 3 ++- .../maple_be/src/cg/aarch64/aarch64_obj_emitter.cpp | 1 - .../codegen/maple/maple_be/src/cg/obj_emit.cpp | 12 +++++++----- .../maple/maple_be/src/cg/x86_64/elf_assembler.cpp | 10 ++++++---- 7 files changed, 22 insertions(+), 16 deletions(-) diff --git a/ecmascript/compiler/aot_file/elf_builder.cpp b/ecmascript/compiler/aot_file/elf_builder.cpp index 39552088e4..9ab4b5d52d 100644 --- a/ecmascript/compiler/aot_file/elf_builder.cpp +++ b/ecmascript/compiler/aot_file/elf_builder.cpp @@ -101,7 +101,7 @@ void ElfBuilder::DumpSection() const } ElfBuilder::ElfBuilder(const std::vector &des, - const std::vector §ions, bool useLiteCG): des_(des), sections_(sections), useLiteCG_(useLiteCG) + const std::vector §ions, bool useLiteCG): des_(des), sections_(sections), useLiteCG_(useLiteCG) { Initialize(); AddShStrTabSection(); @@ -469,8 +469,8 @@ void ElfBuilder::MergeArkStackMapSections(std::ofstream &file, } void ElfBuilder::MergeSymTabSectionsForLiteCG(std::ofstream &file, - std::vector &moduleInfo, - llvm::ELF::Elf64_Off &curSecOffset) + std::vector &moduleInfo, + llvm::ELF::Elf64_Off &curSecOffset) { // here we only support func symbol here. using Elf64_Sym = llvm::ELF::Elf64_Sym; diff --git a/ecmascript/compiler/aot_file/elf_builder.h b/ecmascript/compiler/aot_file/elf_builder.h index 6fd8630f6d..10197fdff8 100644 --- a/ecmascript/compiler/aot_file/elf_builder.h +++ b/ecmascript/compiler/aot_file/elf_builder.h @@ -30,7 +30,8 @@ class ModuleSectionDes; class ElfBuilder { public: - ElfBuilder(const std::vector &des, const std::vector §ions, bool useLiteCG = false); + ElfBuilder(const std::vector &des, + const std::vector §ions, bool useLiteCG = false); ~ElfBuilder(); static constexpr uint32_t FuncEntryModuleDesIndex = 0; void PackELFHeader(llvm::ELF::Elf64_Ehdr &header, uint32_t version, Triple triple); diff --git a/ecmascript/compiler/codegen/maple/maple_be/include/cg/ifile.h b/ecmascript/compiler/codegen/maple/maple_be/include/cg/ifile.h index 99a8a22850..30e347d025 100644 --- a/ecmascript/compiler/codegen/maple/maple_be/include/cg/ifile.h +++ b/ecmascript/compiler/codegen/maple/maple_be/include/cg/ifile.h @@ -399,7 +399,8 @@ public: return symbolIdxMap.count(symIdx) != 0; } - const char *GetAddr() { + const char *GetAddr() + { return reinterpret_cast(symbols.data()); } private: diff --git a/ecmascript/compiler/codegen/maple/maple_be/include/cg/x86_64/assembler/elf_file.h b/ecmascript/compiler/codegen/maple/maple_be/include/cg/x86_64/assembler/elf_file.h index eb93dfb16d..1bbd6d7068 100644 --- a/ecmascript/compiler/codegen/maple/maple_be/include/cg/x86_64/assembler/elf_file.h +++ b/ecmascript/compiler/codegen/maple/maple_be/include/cg/x86_64/assembler/elf_file.h @@ -293,7 +293,8 @@ public: return symbols.size() * sizeof(Symbol); } - const char* GetAddr() { + const char* GetAddr() + { return reinterpret_cast(symbols.data()); } diff --git a/ecmascript/compiler/codegen/maple/maple_be/src/cg/aarch64/aarch64_obj_emitter.cpp b/ecmascript/compiler/codegen/maple/maple_be/src/cg/aarch64/aarch64_obj_emitter.cpp index 1c455d9e3f..c8a5904010 100644 --- a/ecmascript/compiler/codegen/maple/maple_be/src/cg/aarch64/aarch64_obj_emitter.cpp +++ b/ecmascript/compiler/codegen/maple/maple_be/src/cg/aarch64/aarch64_obj_emitter.cpp @@ -284,7 +284,6 @@ void AArch64ObjEmitter::AppendGlobalLabel() void AArch64ObjEmitter::AppendSymsToSymTabSec() { - Address offset = 0; auto &contents = GetContents(); for (auto *content : contents) { diff --git a/ecmascript/compiler/codegen/maple/maple_be/src/cg/obj_emit.cpp b/ecmascript/compiler/codegen/maple/maple_be/src/cg/obj_emit.cpp index e18d46ecc9..d5d1686160 100644 --- a/ecmascript/compiler/codegen/maple/maple_be/src/cg/obj_emit.cpp +++ b/ecmascript/compiler/codegen/maple/maple_be/src/cg/obj_emit.cpp @@ -116,15 +116,17 @@ void ObjEmitter::WriteObjFile() if (emitMemorymanager.codeSpace != nullptr) { DEBUG_ASSERT(textSection != nullptr, "textSection has not been initialized"); uint8 *codeSpace = emitMemorymanager.allocateDataSection(emitMemorymanager.codeSpace, - textSection->GetDataSize(), textSection->GetAlign(), textSection->GetName().c_str()); + textSection->GetDataSize(), textSection->GetAlign(), textSection->GetName().c_str()); memcpy_s(codeSpace, textSection->GetDataSize(), textSection->GetData().data(), textSection->GetDataSize()); if (CGOptions::addFuncSymbol()) { uint8 *symtabSpace = emitMemorymanager.allocateDataSection(emitMemorymanager.codeSpace, - symbolTabSection->GetDataSize(), symbolTabSection->GetAlign(), symbolTabSection->GetName().c_str()); - memcpy_s(symtabSpace, symbolTabSection->GetDataSize() , symbolTabSection->GetAddr(), symbolTabSection->GetDataSize()); + symbolTabSection->GetDataSize(), symbolTabSection->GetAlign(), symbolTabSection->GetName().c_str()); + memcpy_s(symtabSpace, symbolTabSection->GetDataSize(), + symbolTabSection->GetAddr(), symbolTabSection->GetDataSize()); uint8 *stringTabSpace = emitMemorymanager.allocateDataSection(emitMemorymanager.codeSpace, - strTabSection->GetDataSize(), strTabSection->GetAlign(), strTabSection->GetName().c_str()); - memcpy_s(stringTabSpace, strTabSection->GetDataSize(), strTabSection->GetData().data(), strTabSection->GetDataSize()); + strTabSection->GetDataSize(), strTabSection->GetAlign(), strTabSection->GetName().c_str()); + memcpy_s(stringTabSpace, strTabSection->GetDataSize(), + strTabSection->GetData().data(), strTabSection->GetDataSize()); } return; diff --git a/ecmascript/compiler/codegen/maple/maple_be/src/cg/x86_64/elf_assembler.cpp b/ecmascript/compiler/codegen/maple/maple_be/src/cg/x86_64/elf_assembler.cpp index 05bd9b151e..5f628c86f5 100644 --- a/ecmascript/compiler/codegen/maple/maple_be/src/cg/x86_64/elf_assembler.cpp +++ b/ecmascript/compiler/codegen/maple/maple_be/src/cg/x86_64/elf_assembler.cpp @@ -952,11 +952,13 @@ void ElfAssembler::WriteElfFile() memcpy_s(codeSpace, textSection->GetSectionSize(), textSection->GetData().data(), textSection->GetDataSize()); if (CGOptions::addFuncSymbol()) { uint8 *symtabSpace = emitMemoryManager.allocateDataSection(emitMemoryManager.codeSpace, - symbolTabSection->GetDataSize(), symbolTabSection->GetAlign(), symbolTabSection->GetName().c_str()); - memcpy_s(symtabSpace, symbolTabSection->GetDataSize() , symbolTabSection->GetAddr(), symbolTabSection->GetDataSize()); + symbolTabSection->GetDataSize(), symbolTabSection->GetAlign(), symbolTabSection->GetName().c_str()); + memcpy_s(symtabSpace, symbolTabSection->GetDataSize(), + symbolTabSection->GetAddr(), symbolTabSection->GetDataSize()); uint8 *stringTabSpace = emitMemoryManager.allocateDataSection(emitMemoryManager.codeSpace, - strTabSection->GetDataSize(), strTabSection->GetAlign(), strTabSection->GetName().c_str()); - memcpy_s(stringTabSpace, strTabSection->GetDataSize(), strTabSection->GetData().data(), strTabSection->GetDataSize()); + strTabSection->GetDataSize(), strTabSection->GetAlign(), strTabSection->GetName().c_str()); + memcpy_s(stringTabSpace, strTabSection->GetDataSize(), + strTabSection->GetData().data(), strTabSection->GetDataSize()); } return; } -- Gitee From e275136707b7c5eff1eb00a172c8cf1467d60d36 Mon Sep 17 00:00:00 2001 From: t00595839 Date: Thu, 8 Feb 2024 01:25:55 -0800 Subject: [PATCH 3/7] adapt to new change Signed-off-by: t00595839 Change-Id: I98f257cf5316f2468d6252106e2266d86e17f669 Signed-off-by: t00595839 --- ecmascript/compiler/aot_file/an_file_info.cpp | 4 +- ecmascript/compiler/aot_file/an_file_info.h | 2 +- ecmascript/compiler/aot_file/elf_builder.cpp | 56 ++----------------- ecmascript/compiler/aot_file/elf_builder.h | 3 +- .../codegen/maple/maple_be/include/cg/ifile.h | 1 + .../include/cg/x86_64/assembler/elf_file.h | 1 + .../maple/maple_be/src/cg/obj_emit.cpp | 3 +- .../maple_be/src/cg/x86_64/elf_assembler.cpp | 2 +- ecmascript/compiler/file_generators.cpp | 2 +- 9 files changed, 15 insertions(+), 59 deletions(-) diff --git a/ecmascript/compiler/aot_file/an_file_info.cpp b/ecmascript/compiler/aot_file/an_file_info.cpp index 1e27a53ea5..5d12a2e9a5 100644 --- a/ecmascript/compiler/aot_file/an_file_info.cpp +++ b/ecmascript/compiler/aot_file/an_file_info.cpp @@ -26,7 +26,7 @@ #include "macros.h" namespace panda::ecmascript { -void AnFileInfo::Save(const std::string &filename, Triple triple, bool useLiteCG) +void AnFileInfo::Save(const std::string &filename, Triple triple) { std::string realPath; if (!RealPath(filename, realPath, false)) { @@ -39,7 +39,7 @@ void AnFileInfo::Save(const std::string &filename, Triple triple, bool useLiteCG SetStubNum(entries_.size()); AddFuncEntrySec(); - ElfBuilder builder(des_, GetDumpSectionNames(), useLiteCG); + ElfBuilder builder(des_, GetDumpSectionNames()); llvm::ELF::Elf64_Ehdr header; builder.PackELFHeader(header, base::FileHeaderBase::ToVersionNumber(AOTFileVersion::AN_VERSION), triple); file.write(reinterpret_cast(&header), sizeof(llvm::ELF::Elf64_Ehdr)); diff --git a/ecmascript/compiler/aot_file/an_file_info.h b/ecmascript/compiler/aot_file/an_file_info.h index 6cf0050402..3caada9b21 100644 --- a/ecmascript/compiler/aot_file/an_file_info.h +++ b/ecmascript/compiler/aot_file/an_file_info.h @@ -24,7 +24,7 @@ public: using FuncEntryIndexKey = std::pair; // (compilefileName, MethodID) AnFileInfo() = default; ~AnFileInfo() override = default; - void PUBLIC_API Save(const std::string &filename, Triple triple, bool useLiteCG = false); + void PUBLIC_API Save(const std::string &filename, Triple triple); void AddModuleDes(ModuleSectionDes &moduleDes) { des_.emplace_back(moduleDes); diff --git a/ecmascript/compiler/aot_file/elf_builder.cpp b/ecmascript/compiler/aot_file/elf_builder.cpp index 9ab4b5d52d..e6492c3024 100644 --- a/ecmascript/compiler/aot_file/elf_builder.cpp +++ b/ecmascript/compiler/aot_file/elf_builder.cpp @@ -101,7 +101,7 @@ void ElfBuilder::DumpSection() const } ElfBuilder::ElfBuilder(const std::vector &des, - const std::vector §ions, bool useLiteCG): des_(des), sections_(sections), useLiteCG_(useLiteCG) + const std::vector §ions): des_(des), sections_(sections) { Initialize(); AddShStrTabSection(); @@ -468,44 +468,6 @@ void ElfBuilder::MergeArkStackMapSections(std::ofstream &file, } } -void ElfBuilder::MergeSymTabSectionsForLiteCG(std::ofstream &file, - std::vector &moduleInfo, - llvm::ELF::Elf64_Off &curSecOffset) -{ - // here we only support func symbol here. - using Elf64_Sym = llvm::ELF::Elf64_Sym; - uint64_t lastStrIdx = 0; - // put und at first pos in sym tab. - Elf64_Sym und; - file.write(reinterpret_cast(&und), sizeof(und)); - curSecOffset += sizeof(und); - for (size_t i = 0; i < des_.size(); ++i) { - ModuleSectionDes &des = des_[i]; - ModuleSectionDes::ModuleRegionInfo &curInfo = moduleInfo[i]; - uint64_t textSecOffset = sectionToShdr_[ElfSecName::TEXT].sh_offset; - uint32_t curSecSize = des.GetSecSize(ElfSecName::SYMTAB); - uint64_t curSecAddr = des.GetSecAddr(ElfSecName::SYMTAB); - uint32_t index = des.GetStartIndex(); - uint32_t cnt = des.GetFuncCount(); - uint32_t textSecIndex = GetShIndex(ElfSecName::TEXT); - curInfo.startIndex = index; - curInfo.funcCount = cnt; - Elf64_Sym *syms = reinterpret_cast(curSecAddr); - size_t n = curSecSize / sizeof(Elf64_Sym); - for (size_t j = 0; j < n; ++j) { - Elf64_Sym* sy = &syms[j]; - if (sy->getType() == llvm::ELF::STT_FUNC) { - sy->st_value += textSecOffset; - sy->st_name += lastStrIdx; - sy->st_shndx = static_cast(textSecIndex); - } - } - lastStrIdx += des.GetSecSize(ElfSecName::STRTAB); - file.write(reinterpret_cast(curSecAddr), curSecSize); - curSecOffset += curSecSize; - } -} - void ElfBuilder::FixSymtab(llvm::ELF::Elf64_Shdr* shdr) { using Elf64_Sym = llvm::ELF::Elf64_Sym; @@ -649,17 +611,11 @@ void ElfBuilder::PackELFSections(std::ofstream &file) break; } case ElfSecName::SYMTAB: { - if (useLiteCG_) { - uint32_t curSize = curSecOffset; - MergeSymTabSectionsForLiteCG(file, moduleInfo, curSecOffset); - curShdr.sh_size = curSecOffset - curSize; - } else { - FixSymtab(&curShdr); - uint32_t curSize = curSecOffset; - uint32_t asmSecIndex = GetShIndex(ElfSecName::ARK_ASMSTUB); - MergeSymtabSections(file, moduleInfo, curSecOffset, shdr[asmSecIndex].sh_offset); - curShdr.sh_size = curSecOffset - curSize; - } + FixSymtab(&curShdr); + uint32_t curSize = curSecOffset; + uint32_t asmSecIndex = GetShIndex(ElfSecName::ARK_ASMSTUB); + MergeSymtabSections(file, moduleInfo, curSecOffset, shdr[asmSecIndex].sh_offset); + curShdr.sh_size = curSecOffset - curSize; break; } case ElfSecName::SHSTRTAB: diff --git a/ecmascript/compiler/aot_file/elf_builder.h b/ecmascript/compiler/aot_file/elf_builder.h index 10197fdff8..ee7dc0eff6 100644 --- a/ecmascript/compiler/aot_file/elf_builder.h +++ b/ecmascript/compiler/aot_file/elf_builder.h @@ -31,7 +31,7 @@ class ModuleSectionDes; class ElfBuilder { public: ElfBuilder(const std::vector &des, - const std::vector §ions, bool useLiteCG = false); + const std::vector §ions); ~ElfBuilder(); static constexpr uint32_t FuncEntryModuleDesIndex = 0; void PackELFHeader(llvm::ELF::Elf64_Ehdr &header, uint32_t version, Triple triple); @@ -94,7 +94,6 @@ private: bool enableSecDump_ {false}; ElfSecName lastDataSection {ElfSecName::NONE}; ElfSecName lastCodeSection {ElfSecName::NONE}; - bool useLiteCG_ {false}; }; } // namespace panda::ecmascript #endif // ECMASCRIPT_COMPILER_AOT_FILE_ELF_BUILDER_H diff --git a/ecmascript/compiler/codegen/maple/maple_be/include/cg/ifile.h b/ecmascript/compiler/codegen/maple/maple_be/include/cg/ifile.h index 30e347d025..c4f0ef25b5 100644 --- a/ecmascript/compiler/codegen/maple/maple_be/include/cg/ifile.h +++ b/ecmascript/compiler/codegen/maple/maple_be/include/cg/ifile.h @@ -360,6 +360,7 @@ public: SetEntSize(sizeof(Symbol)); SetLink(link); SetInfo(1); + AppendSymbol({0, 0, 0, 0, 0, 0}); } ~SymbolSection() = default; diff --git a/ecmascript/compiler/codegen/maple/maple_be/include/cg/x86_64/assembler/elf_file.h b/ecmascript/compiler/codegen/maple/maple_be/include/cg/x86_64/assembler/elf_file.h index 1bbd6d7068..6118d9515f 100644 --- a/ecmascript/compiler/codegen/maple/maple_be/include/cg/x86_64/assembler/elf_file.h +++ b/ecmascript/compiler/codegen/maple/maple_be/include/cg/x86_64/assembler/elf_file.h @@ -249,6 +249,7 @@ public: SetEntSize(sizeof(Symbol)); SetLink(link); SetInfo(1); + AppendSymbol({0, 0, 0, 0, 0, 0}); } ~SymbolSection() = default; diff --git a/ecmascript/compiler/codegen/maple/maple_be/src/cg/obj_emit.cpp b/ecmascript/compiler/codegen/maple/maple_be/src/cg/obj_emit.cpp index d5d1686160..67b271dda2 100644 --- a/ecmascript/compiler/codegen/maple/maple_be/src/cg/obj_emit.cpp +++ b/ecmascript/compiler/codegen/maple/maple_be/src/cg/obj_emit.cpp @@ -161,11 +161,10 @@ void ObjEmitter::AddSymbol(const std::string &name, Word size, const Section &se void ObjEmitter::AddFuncSymbol(const MapleString &name, Word size, Address value) { - uint32 lastModulePC = cg->GetMIRModule()->GetLastModulePC(); auto symbolStrIndex = strTabSection->AddString(name); symbolTabSection->AppendSymbol({static_cast(symbolStrIndex), static_cast((STB_GLOBAL << k4BitSize) + (STT_FUNC & 0xf)), 0, - textSection->GetIndex(), value + lastModulePC, size}); + textSection->GetIndex(), value, size}); } void ObjEmitter::ClearData() diff --git a/ecmascript/compiler/codegen/maple/maple_be/src/cg/x86_64/elf_assembler.cpp b/ecmascript/compiler/codegen/maple/maple_be/src/cg/x86_64/elf_assembler.cpp index 5f628c86f5..37296e65ef 100644 --- a/ecmascript/compiler/codegen/maple/maple_be/src/cg/x86_64/elf_assembler.cpp +++ b/ecmascript/compiler/codegen/maple/maple_be/src/cg/x86_64/elf_assembler.cpp @@ -180,7 +180,7 @@ void ElfAssembler::EmitFunctionFoot(int64 symIdx, SymbolAttr funcAttr) auto nameIndex = strTabSection->AddString(symbolName); AddSymToSymTab({static_cast(nameIndex), static_cast((funcSymType << kLeftShift4Bits) + (STT_FUNC & 0xf)), 0, textSection->GetIndex(), - funcSymValue + lastModulePC, funcSymSize}, + funcSymValue, funcSymSize}, symIdx); } diff --git a/ecmascript/compiler/file_generators.cpp b/ecmascript/compiler/file_generators.cpp index e451c35f0d..db57885dbf 100644 --- a/ecmascript/compiler/file_generators.cpp +++ b/ecmascript/compiler/file_generators.cpp @@ -584,7 +584,7 @@ void AOTFileGenerator::SaveAOTFile(const std::string &filename, const std::strin PrintMergedCodeComment(); GenerateMergedStackmapSection(); aotInfo_.GenerateMethodToEntryIndexMap(); - aotInfo_.Save(filename, cfg_.GetTriple(), useLiteCG_); + aotInfo_.Save(filename, cfg_.GetTriple()); if (!panda::ecmascript::SetFileModeAsDefault(filename)) { LOG_COMPILER(ERROR) << "Fail to set an file mode:" << filename; } -- Gitee From 9d10a19fc204edff48707c8d9187659b078f7f28 Mon Sep 17 00:00:00 2001 From: t00595839 Date: Fri, 16 Feb 2024 20:41:59 -0800 Subject: [PATCH 4/7] fix x86 bug Signed-off-by: t00595839 Change-Id: I28ce1c5b7d8b30268e66294314f0d9f8904bfa9c --- .../codegen/maple/maple_be/src/cg/x86_64/x64_emitter.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ecmascript/compiler/codegen/maple/maple_be/src/cg/x86_64/x64_emitter.cpp b/ecmascript/compiler/codegen/maple/maple_be/src/cg/x86_64/x64_emitter.cpp index 24c035615f..7ae5308768 100644 --- a/ecmascript/compiler/codegen/maple/maple_be/src/cg/x86_64/x64_emitter.cpp +++ b/ecmascript/compiler/codegen/maple/maple_be/src/cg/x86_64/x64_emitter.cpp @@ -2151,6 +2151,9 @@ void X64Emitter::Run(CGFunc &cgFunc) assmbler.SetLastModulePC(cgFunc.GetMirModule().GetLastModulePC()); + /* emit local variable(s) if exists */ + EmitLocalVariable(cgFunc); + /* emit function header */ EmitFunctionHeader(cgFunc); -- Gitee From 1d50bb1d3fa93393cafe1a77e932a6a59e2d7582 Mon Sep 17 00:00:00 2001 From: t00595839 Date: Sat, 17 Feb 2024 17:49:27 -0800 Subject: [PATCH 5/7] clean code Signed-off-by: t00595839 Change-Id: I79295868807d6a0d9df246a6520a0730bb415019 --- ecmascript/compiler/aot_file/elf_builder.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/ecmascript/compiler/aot_file/elf_builder.h b/ecmascript/compiler/aot_file/elf_builder.h index ee7dc0eff6..bbcb24c0f8 100644 --- a/ecmascript/compiler/aot_file/elf_builder.h +++ b/ecmascript/compiler/aot_file/elf_builder.h @@ -41,8 +41,6 @@ public: std::vector &moduleInfo, llvm::ELF::Elf64_Off &curSecOffset); void MergeArkStackMapSections(std::ofstream &elfFile, std::vector &moduleInfo, llvm::ELF::Elf64_Off &curSecOffset); - void MergeSymTabSectionsForLiteCG(std::ofstream &file, - std::vector &moduleInfo, llvm::ELF::Elf64_Off &curSecOffset); void MergeStrtabSections(std::ofstream &elfFile, std::vector &moduleInfo, llvm::ELF::Elf64_Off &curSecOffset); void MergeSymtabSections(std::ofstream &elfFile, std::vector &moduleInfo, -- Gitee From aa8b38f19e14a0dae3934a3c15d5bf017045f154 Mon Sep 17 00:00:00 2001 From: t00595839 Date: Mon, 19 Feb 2024 01:50:56 -0800 Subject: [PATCH 6/7] clean code2 Signed-off-by: t00595839 Change-Id: I37f8bdb8bd7c3301ab4bfff15fc400315c80da6e --- ecmascript/compiler/codegen/maple/maple_be/include/cg/ifile.h | 2 +- .../maple/maple_be/include/cg/x86_64/assembler/elf_file.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ecmascript/compiler/codegen/maple/maple_be/include/cg/ifile.h b/ecmascript/compiler/codegen/maple/maple_be/include/cg/ifile.h index c4f0ef25b5..338e25662d 100644 --- a/ecmascript/compiler/codegen/maple/maple_be/include/cg/ifile.h +++ b/ecmascript/compiler/codegen/maple/maple_be/include/cg/ifile.h @@ -402,7 +402,7 @@ public: const char *GetAddr() { - return reinterpret_cast(symbols.data()); + return reinterpret_cast(symbols.data()); } private: MapleAllocator alloc; diff --git a/ecmascript/compiler/codegen/maple/maple_be/include/cg/x86_64/assembler/elf_file.h b/ecmascript/compiler/codegen/maple/maple_be/include/cg/x86_64/assembler/elf_file.h index 6118d9515f..937ffda1c8 100644 --- a/ecmascript/compiler/codegen/maple/maple_be/include/cg/x86_64/assembler/elf_file.h +++ b/ecmascript/compiler/codegen/maple/maple_be/include/cg/x86_64/assembler/elf_file.h @@ -294,9 +294,9 @@ public: return symbols.size() * sizeof(Symbol); } - const char* GetAddr() + const char *GetAddr() { - return reinterpret_cast(symbols.data()); + return reinterpret_cast(symbols.data()); } private: -- Gitee From f3acd218508cf6cb20c8dd5255444994fe342495 Mon Sep 17 00:00:00 2001 From: t00595839 Date: Mon, 19 Feb 2024 18:28:05 -0800 Subject: [PATCH 7/7] cleancode 3 Signed-off-by: t00595839 Change-Id: Ib77a5001ba68ad4690f4908553f906f2c44cb1d0 Signed-off-by: t00595839 --- ecmascript/compiler/aot_file/elf_builder.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ecmascript/compiler/aot_file/elf_builder.h b/ecmascript/compiler/aot_file/elf_builder.h index bbcb24c0f8..5c44de1484 100644 --- a/ecmascript/compiler/aot_file/elf_builder.h +++ b/ecmascript/compiler/aot_file/elf_builder.h @@ -31,7 +31,7 @@ class ModuleSectionDes; class ElfBuilder { public: ElfBuilder(const std::vector &des, - const std::vector §ions); + const std::vector §ions); ~ElfBuilder(); static constexpr uint32_t FuncEntryModuleDesIndex = 0; void PackELFHeader(llvm::ELF::Elf64_Ehdr &header, uint32_t version, Triple triple); -- Gitee