1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #include "ecmascript/compiler/aot_file/module_section_des.h" 16 #include "ecmascript/compiler/compiler_log.h" 17 #include "ecmascript/platform/file.h" 18 #include <iomanip> 19 20 namespace panda::ecmascript { GetSecName(const ElfSecName idx)21std::string ModuleSectionDes::GetSecName(const ElfSecName idx) 22 { 23 switch (idx) { 24 case ElfSecName::RODATA: 25 return ".rodata"; 26 case ElfSecName::RODATA_CST4: 27 return ".rodata.cst4"; 28 case ElfSecName::RODATA_CST8: 29 return ".rodata.cst8"; 30 case ElfSecName::RODATA_CST16: 31 return ".rodata.cst16"; 32 case ElfSecName::RODATA_CST32: 33 return ".rodata.cst32"; 34 case ElfSecName::TEXT: 35 return ".text"; 36 case ElfSecName::DATA: 37 return ".data"; 38 case ElfSecName::GOT: 39 return ".got"; 40 case ElfSecName::RELATEXT: 41 return ".rela.text"; 42 case ElfSecName::STRTAB: 43 return ".strtab"; 44 case ElfSecName::SYMTAB: 45 return ".symtab"; 46 case ElfSecName::SHSTRTAB: 47 return ".shstrtab"; 48 case ElfSecName::LLVM_STACKMAP: 49 return ".llvm_stackmaps"; 50 case ElfSecName::ARK_STACKMAP: 51 return ".ark_stackmaps"; 52 case ElfSecName::ARK_FUNCENTRY: 53 return ".ark_funcentry"; 54 case ElfSecName::ARK_ASMSTUB: 55 return ".ark_asmstub"; 56 case ElfSecName::ARK_MODULEINFO: 57 return ".ark_moduleinfo"; 58 default: { 59 LOG_ECMA(FATAL) << "this branch is unreachable"; 60 UNREACHABLE(); 61 } 62 } 63 } 64 } // namespace panda::ecmascript 65