2013-06-11 07:44:15 +08:00
|
|
|
//===- ELFYAML.cpp - ELF YAMLIO implementation ----------------------------===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2013-06-11 07:44:15 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines classes for handling the YAML representation of ELF.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2016-03-02 03:15:06 +08:00
|
|
|
#include "llvm/ObjectYAML/ELFYAML.h"
|
2021-06-01 00:49:34 +08:00
|
|
|
#include "llvm/ADT/APInt.h"
|
2019-08-30 21:39:22 +08:00
|
|
|
#include "llvm/ADT/MapVector.h"
|
2017-07-01 09:35:55 +08:00
|
|
|
#include "llvm/ADT/StringRef.h"
|
|
|
|
#include "llvm/BinaryFormat/ELF.h"
|
2020-09-23 23:00:32 +08:00
|
|
|
#include "llvm/Support/ARMEHABI.h"
|
2014-04-30 07:26:49 +08:00
|
|
|
#include "llvm/Support/Casting.h"
|
2017-07-01 09:35:55 +08:00
|
|
|
#include "llvm/Support/ErrorHandling.h"
|
2015-05-07 23:40:48 +08:00
|
|
|
#include "llvm/Support/MipsABIFlags.h"
|
2017-07-01 09:35:55 +08:00
|
|
|
#include "llvm/Support/YAMLTraits.h"
|
2019-08-30 21:39:22 +08:00
|
|
|
#include "llvm/Support/WithColor.h"
|
2017-07-01 09:35:55 +08:00
|
|
|
#include <cassert>
|
|
|
|
#include <cstdint>
|
2013-06-11 07:44:15 +08:00
|
|
|
|
|
|
|
namespace llvm {
|
2014-04-23 19:10:55 +08:00
|
|
|
|
2019-11-01 20:24:58 +08:00
|
|
|
ELFYAML::Chunk::~Chunk() = default;
|
2014-04-23 19:10:55 +08:00
|
|
|
|
2020-08-18 20:24:26 +08:00
|
|
|
namespace ELFYAML {
|
|
|
|
unsigned Object::getMachine() const {
|
|
|
|
if (Header.Machine)
|
|
|
|
return *Header.Machine;
|
|
|
|
return llvm::ELF::EM_NONE;
|
|
|
|
}
|
2021-01-25 18:23:58 +08:00
|
|
|
|
|
|
|
constexpr StringRef SectionHeaderTable::TypeStr;
|
2020-08-18 20:24:26 +08:00
|
|
|
} // namespace ELFYAML
|
|
|
|
|
2013-06-11 07:44:15 +08:00
|
|
|
namespace yaml {
|
|
|
|
|
2017-02-01 05:11:12 +08:00
|
|
|
void ScalarEnumerationTraits<ELFYAML::ELF_ET>::enumeration(
|
|
|
|
IO &IO, ELFYAML::ELF_ET &Value) {
|
|
|
|
#define ECase(X) IO.enumCase(Value, #X, ELF::X)
|
|
|
|
ECase(ET_NONE);
|
|
|
|
ECase(ET_REL);
|
|
|
|
ECase(ET_EXEC);
|
|
|
|
ECase(ET_DYN);
|
|
|
|
ECase(ET_CORE);
|
2013-06-11 07:44:15 +08:00
|
|
|
#undef ECase
|
2015-01-24 05:58:09 +08:00
|
|
|
IO.enumFallback<Hex16>(Value);
|
2013-06-11 07:44:15 +08:00
|
|
|
}
|
|
|
|
|
2017-07-20 04:38:46 +08:00
|
|
|
void ScalarEnumerationTraits<ELFYAML::ELF_PT>::enumeration(
|
|
|
|
IO &IO, ELFYAML::ELF_PT &Value) {
|
|
|
|
#define ECase(X) IO.enumCase(Value, #X, ELF::X)
|
|
|
|
ECase(PT_NULL);
|
|
|
|
ECase(PT_LOAD);
|
|
|
|
ECase(PT_DYNAMIC);
|
|
|
|
ECase(PT_INTERP);
|
|
|
|
ECase(PT_NOTE);
|
|
|
|
ECase(PT_SHLIB);
|
|
|
|
ECase(PT_PHDR);
|
|
|
|
ECase(PT_TLS);
|
2018-03-08 08:46:53 +08:00
|
|
|
ECase(PT_GNU_EH_FRAME);
|
2019-09-04 17:19:31 +08:00
|
|
|
ECase(PT_GNU_STACK);
|
|
|
|
ECase(PT_GNU_RELRO);
|
2019-11-30 03:12:49 +08:00
|
|
|
ECase(PT_GNU_PROPERTY);
|
2017-07-20 04:38:46 +08:00
|
|
|
#undef ECase
|
|
|
|
IO.enumFallback<Hex32>(Value);
|
|
|
|
}
|
|
|
|
|
2021-02-10 00:23:46 +08:00
|
|
|
void ScalarEnumerationTraits<ELFYAML::ELF_NT>::enumeration(
|
|
|
|
IO &IO, ELFYAML::ELF_NT &Value) {
|
|
|
|
#define ECase(X) IO.enumCase(Value, #X, ELF::X)
|
|
|
|
// Generic note types.
|
|
|
|
ECase(NT_VERSION);
|
|
|
|
ECase(NT_ARCH);
|
|
|
|
ECase(NT_GNU_BUILD_ATTRIBUTE_OPEN);
|
|
|
|
ECase(NT_GNU_BUILD_ATTRIBUTE_FUNC);
|
|
|
|
// Core note types.
|
|
|
|
ECase(NT_PRSTATUS);
|
|
|
|
ECase(NT_FPREGSET);
|
|
|
|
ECase(NT_PRPSINFO);
|
|
|
|
ECase(NT_TASKSTRUCT);
|
|
|
|
ECase(NT_AUXV);
|
|
|
|
ECase(NT_PSTATUS);
|
|
|
|
ECase(NT_FPREGS);
|
|
|
|
ECase(NT_PSINFO);
|
|
|
|
ECase(NT_LWPSTATUS);
|
|
|
|
ECase(NT_LWPSINFO);
|
|
|
|
ECase(NT_WIN32PSTATUS);
|
|
|
|
ECase(NT_PPC_VMX);
|
|
|
|
ECase(NT_PPC_VSX);
|
|
|
|
ECase(NT_PPC_TAR);
|
|
|
|
ECase(NT_PPC_PPR);
|
|
|
|
ECase(NT_PPC_DSCR);
|
|
|
|
ECase(NT_PPC_EBB);
|
|
|
|
ECase(NT_PPC_PMU);
|
|
|
|
ECase(NT_PPC_TM_CGPR);
|
|
|
|
ECase(NT_PPC_TM_CFPR);
|
|
|
|
ECase(NT_PPC_TM_CVMX);
|
|
|
|
ECase(NT_PPC_TM_CVSX);
|
|
|
|
ECase(NT_PPC_TM_SPR);
|
|
|
|
ECase(NT_PPC_TM_CTAR);
|
|
|
|
ECase(NT_PPC_TM_CPPR);
|
|
|
|
ECase(NT_PPC_TM_CDSCR);
|
|
|
|
ECase(NT_386_TLS);
|
|
|
|
ECase(NT_386_IOPERM);
|
|
|
|
ECase(NT_X86_XSTATE);
|
|
|
|
ECase(NT_S390_HIGH_GPRS);
|
|
|
|
ECase(NT_S390_TIMER);
|
|
|
|
ECase(NT_S390_TODCMP);
|
|
|
|
ECase(NT_S390_TODPREG);
|
|
|
|
ECase(NT_S390_CTRS);
|
|
|
|
ECase(NT_S390_PREFIX);
|
|
|
|
ECase(NT_S390_LAST_BREAK);
|
|
|
|
ECase(NT_S390_SYSTEM_CALL);
|
|
|
|
ECase(NT_S390_TDB);
|
|
|
|
ECase(NT_S390_VXRS_LOW);
|
|
|
|
ECase(NT_S390_VXRS_HIGH);
|
|
|
|
ECase(NT_S390_GS_CB);
|
|
|
|
ECase(NT_S390_GS_BC);
|
|
|
|
ECase(NT_ARM_VFP);
|
|
|
|
ECase(NT_ARM_TLS);
|
|
|
|
ECase(NT_ARM_HW_BREAK);
|
|
|
|
ECase(NT_ARM_HW_WATCH);
|
|
|
|
ECase(NT_ARM_SVE);
|
|
|
|
ECase(NT_ARM_PAC_MASK);
|
|
|
|
ECase(NT_FILE);
|
|
|
|
ECase(NT_PRXFPREG);
|
|
|
|
ECase(NT_SIGINFO);
|
|
|
|
// LLVM-specific notes.
|
|
|
|
ECase(NT_LLVM_HWASAN_GLOBALS);
|
|
|
|
// GNU note types
|
|
|
|
ECase(NT_GNU_ABI_TAG);
|
|
|
|
ECase(NT_GNU_HWCAP);
|
|
|
|
ECase(NT_GNU_BUILD_ID);
|
|
|
|
ECase(NT_GNU_GOLD_VERSION);
|
|
|
|
ECase(NT_GNU_PROPERTY_TYPE_0);
|
2021-02-10 00:46:29 +08:00
|
|
|
// FreeBSD note types.
|
|
|
|
ECase(NT_FREEBSD_ABI_TAG);
|
|
|
|
ECase(NT_FREEBSD_NOINIT_TAG);
|
|
|
|
ECase(NT_FREEBSD_ARCH_TAG);
|
|
|
|
ECase(NT_FREEBSD_FEATURE_CTL);
|
2021-02-10 00:23:46 +08:00
|
|
|
// FreeBSD core note types.
|
|
|
|
ECase(NT_FREEBSD_THRMISC);
|
|
|
|
ECase(NT_FREEBSD_PROCSTAT_PROC);
|
|
|
|
ECase(NT_FREEBSD_PROCSTAT_FILES);
|
|
|
|
ECase(NT_FREEBSD_PROCSTAT_VMMAP);
|
|
|
|
ECase(NT_FREEBSD_PROCSTAT_GROUPS);
|
|
|
|
ECase(NT_FREEBSD_PROCSTAT_UMASK);
|
|
|
|
ECase(NT_FREEBSD_PROCSTAT_RLIMIT);
|
|
|
|
ECase(NT_FREEBSD_PROCSTAT_OSREL);
|
|
|
|
ECase(NT_FREEBSD_PROCSTAT_PSSTRINGS);
|
|
|
|
ECase(NT_FREEBSD_PROCSTAT_AUXV);
|
|
|
|
// AMD specific notes. (Code Object V2)
|
2021-05-01 03:20:28 +08:00
|
|
|
ECase(NT_AMD_HSA_CODE_OBJECT_VERSION);
|
|
|
|
ECase(NT_AMD_HSA_HSAIL);
|
|
|
|
ECase(NT_AMD_HSA_ISA_VERSION);
|
2021-03-24 23:52:10 +08:00
|
|
|
ECase(NT_AMD_HSA_METADATA);
|
|
|
|
ECase(NT_AMD_HSA_ISA_NAME);
|
|
|
|
ECase(NT_AMD_PAL_METADATA);
|
2021-02-10 00:23:46 +08:00
|
|
|
// AMDGPU specific notes. (Code Object V3)
|
|
|
|
ECase(NT_AMDGPU_METADATA);
|
|
|
|
#undef ECase
|
|
|
|
IO.enumFallback<Hex32>(Value);
|
|
|
|
}
|
|
|
|
|
2017-02-01 05:11:12 +08:00
|
|
|
void ScalarEnumerationTraits<ELFYAML::ELF_EM>::enumeration(
|
|
|
|
IO &IO, ELFYAML::ELF_EM &Value) {
|
|
|
|
#define ECase(X) IO.enumCase(Value, #X, ELF::X)
|
|
|
|
ECase(EM_NONE);
|
|
|
|
ECase(EM_M32);
|
|
|
|
ECase(EM_SPARC);
|
|
|
|
ECase(EM_386);
|
|
|
|
ECase(EM_68K);
|
|
|
|
ECase(EM_88K);
|
|
|
|
ECase(EM_IAMCU);
|
|
|
|
ECase(EM_860);
|
|
|
|
ECase(EM_MIPS);
|
|
|
|
ECase(EM_S370);
|
|
|
|
ECase(EM_MIPS_RS3_LE);
|
|
|
|
ECase(EM_PARISC);
|
|
|
|
ECase(EM_VPP500);
|
|
|
|
ECase(EM_SPARC32PLUS);
|
|
|
|
ECase(EM_960);
|
|
|
|
ECase(EM_PPC);
|
|
|
|
ECase(EM_PPC64);
|
|
|
|
ECase(EM_S390);
|
|
|
|
ECase(EM_SPU);
|
|
|
|
ECase(EM_V800);
|
|
|
|
ECase(EM_FR20);
|
|
|
|
ECase(EM_RH32);
|
|
|
|
ECase(EM_RCE);
|
|
|
|
ECase(EM_ARM);
|
|
|
|
ECase(EM_ALPHA);
|
|
|
|
ECase(EM_SH);
|
|
|
|
ECase(EM_SPARCV9);
|
|
|
|
ECase(EM_TRICORE);
|
|
|
|
ECase(EM_ARC);
|
|
|
|
ECase(EM_H8_300);
|
|
|
|
ECase(EM_H8_300H);
|
|
|
|
ECase(EM_H8S);
|
|
|
|
ECase(EM_H8_500);
|
|
|
|
ECase(EM_IA_64);
|
|
|
|
ECase(EM_MIPS_X);
|
|
|
|
ECase(EM_COLDFIRE);
|
|
|
|
ECase(EM_68HC12);
|
|
|
|
ECase(EM_MMA);
|
|
|
|
ECase(EM_PCP);
|
|
|
|
ECase(EM_NCPU);
|
|
|
|
ECase(EM_NDR1);
|
|
|
|
ECase(EM_STARCORE);
|
|
|
|
ECase(EM_ME16);
|
|
|
|
ECase(EM_ST100);
|
|
|
|
ECase(EM_TINYJ);
|
|
|
|
ECase(EM_X86_64);
|
|
|
|
ECase(EM_PDSP);
|
|
|
|
ECase(EM_PDP10);
|
|
|
|
ECase(EM_PDP11);
|
|
|
|
ECase(EM_FX66);
|
|
|
|
ECase(EM_ST9PLUS);
|
|
|
|
ECase(EM_ST7);
|
|
|
|
ECase(EM_68HC16);
|
|
|
|
ECase(EM_68HC11);
|
|
|
|
ECase(EM_68HC08);
|
|
|
|
ECase(EM_68HC05);
|
|
|
|
ECase(EM_SVX);
|
|
|
|
ECase(EM_ST19);
|
|
|
|
ECase(EM_VAX);
|
|
|
|
ECase(EM_CRIS);
|
|
|
|
ECase(EM_JAVELIN);
|
|
|
|
ECase(EM_FIREPATH);
|
|
|
|
ECase(EM_ZSP);
|
|
|
|
ECase(EM_MMIX);
|
|
|
|
ECase(EM_HUANY);
|
|
|
|
ECase(EM_PRISM);
|
|
|
|
ECase(EM_AVR);
|
|
|
|
ECase(EM_FR30);
|
|
|
|
ECase(EM_D10V);
|
|
|
|
ECase(EM_D30V);
|
|
|
|
ECase(EM_V850);
|
|
|
|
ECase(EM_M32R);
|
|
|
|
ECase(EM_MN10300);
|
|
|
|
ECase(EM_MN10200);
|
|
|
|
ECase(EM_PJ);
|
|
|
|
ECase(EM_OPENRISC);
|
|
|
|
ECase(EM_ARC_COMPACT);
|
|
|
|
ECase(EM_XTENSA);
|
|
|
|
ECase(EM_VIDEOCORE);
|
|
|
|
ECase(EM_TMM_GPP);
|
|
|
|
ECase(EM_NS32K);
|
|
|
|
ECase(EM_TPC);
|
|
|
|
ECase(EM_SNP1K);
|
|
|
|
ECase(EM_ST200);
|
|
|
|
ECase(EM_IP2K);
|
|
|
|
ECase(EM_MAX);
|
|
|
|
ECase(EM_CR);
|
|
|
|
ECase(EM_F2MC16);
|
|
|
|
ECase(EM_MSP430);
|
|
|
|
ECase(EM_BLACKFIN);
|
|
|
|
ECase(EM_SE_C33);
|
|
|
|
ECase(EM_SEP);
|
|
|
|
ECase(EM_ARCA);
|
|
|
|
ECase(EM_UNICORE);
|
|
|
|
ECase(EM_EXCESS);
|
|
|
|
ECase(EM_DXP);
|
|
|
|
ECase(EM_ALTERA_NIOS2);
|
|
|
|
ECase(EM_CRX);
|
|
|
|
ECase(EM_XGATE);
|
|
|
|
ECase(EM_C166);
|
|
|
|
ECase(EM_M16C);
|
|
|
|
ECase(EM_DSPIC30F);
|
|
|
|
ECase(EM_CE);
|
|
|
|
ECase(EM_M32C);
|
|
|
|
ECase(EM_TSK3000);
|
|
|
|
ECase(EM_RS08);
|
|
|
|
ECase(EM_SHARC);
|
|
|
|
ECase(EM_ECOG2);
|
|
|
|
ECase(EM_SCORE7);
|
|
|
|
ECase(EM_DSP24);
|
|
|
|
ECase(EM_VIDEOCORE3);
|
|
|
|
ECase(EM_LATTICEMICO32);
|
|
|
|
ECase(EM_SE_C17);
|
|
|
|
ECase(EM_TI_C6000);
|
|
|
|
ECase(EM_TI_C2000);
|
|
|
|
ECase(EM_TI_C5500);
|
|
|
|
ECase(EM_MMDSP_PLUS);
|
|
|
|
ECase(EM_CYPRESS_M8C);
|
|
|
|
ECase(EM_R32C);
|
|
|
|
ECase(EM_TRIMEDIA);
|
|
|
|
ECase(EM_HEXAGON);
|
|
|
|
ECase(EM_8051);
|
|
|
|
ECase(EM_STXP7X);
|
|
|
|
ECase(EM_NDS32);
|
|
|
|
ECase(EM_ECOG1);
|
|
|
|
ECase(EM_ECOG1X);
|
|
|
|
ECase(EM_MAXQ30);
|
|
|
|
ECase(EM_XIMO16);
|
|
|
|
ECase(EM_MANIK);
|
|
|
|
ECase(EM_CRAYNV2);
|
|
|
|
ECase(EM_RX);
|
|
|
|
ECase(EM_METAG);
|
|
|
|
ECase(EM_MCST_ELBRUS);
|
|
|
|
ECase(EM_ECOG16);
|
|
|
|
ECase(EM_CR16);
|
|
|
|
ECase(EM_ETPU);
|
|
|
|
ECase(EM_SLE9X);
|
|
|
|
ECase(EM_L10M);
|
|
|
|
ECase(EM_K10M);
|
|
|
|
ECase(EM_AARCH64);
|
|
|
|
ECase(EM_AVR32);
|
|
|
|
ECase(EM_STM8);
|
|
|
|
ECase(EM_TILE64);
|
|
|
|
ECase(EM_TILEPRO);
|
2021-05-03 10:25:39 +08:00
|
|
|
ECase(EM_MICROBLAZE);
|
2017-02-01 05:11:12 +08:00
|
|
|
ECase(EM_CUDA);
|
|
|
|
ECase(EM_TILEGX);
|
|
|
|
ECase(EM_CLOUDSHIELD);
|
|
|
|
ECase(EM_COREA_1ST);
|
|
|
|
ECase(EM_COREA_2ND);
|
|
|
|
ECase(EM_ARC_COMPACT2);
|
|
|
|
ECase(EM_OPEN8);
|
|
|
|
ECase(EM_RL78);
|
|
|
|
ECase(EM_VIDEOCORE5);
|
|
|
|
ECase(EM_78KOR);
|
|
|
|
ECase(EM_56800EX);
|
|
|
|
ECase(EM_AMDGPU);
|
|
|
|
ECase(EM_RISCV);
|
|
|
|
ECase(EM_LANAI);
|
|
|
|
ECase(EM_BPF);
|
2020-05-28 16:07:21 +08:00
|
|
|
ECase(EM_VE);
|
2020-09-02 17:02:17 +08:00
|
|
|
ECase(EM_CSKY);
|
2013-06-11 07:44:15 +08:00
|
|
|
#undef ECase
|
2019-09-17 19:51:26 +08:00
|
|
|
IO.enumFallback<Hex16>(Value);
|
2013-06-11 07:44:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScalarEnumerationTraits<ELFYAML::ELF_ELFCLASS>::enumeration(
|
|
|
|
IO &IO, ELFYAML::ELF_ELFCLASS &Value) {
|
2017-02-01 05:11:12 +08:00
|
|
|
#define ECase(X) IO.enumCase(Value, #X, ELF::X)
|
2013-06-11 07:44:15 +08:00
|
|
|
// Since the semantics of ELFCLASSNONE is "invalid", just don't accept it
|
|
|
|
// here.
|
2017-02-01 05:11:12 +08:00
|
|
|
ECase(ELFCLASS32);
|
|
|
|
ECase(ELFCLASS64);
|
2013-06-11 07:44:15 +08:00
|
|
|
#undef ECase
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScalarEnumerationTraits<ELFYAML::ELF_ELFDATA>::enumeration(
|
|
|
|
IO &IO, ELFYAML::ELF_ELFDATA &Value) {
|
2017-02-01 05:11:12 +08:00
|
|
|
#define ECase(X) IO.enumCase(Value, #X, ELF::X)
|
2019-03-07 20:09:19 +08:00
|
|
|
// ELFDATANONE is an invalid data encoding, but we accept it because
|
|
|
|
// we want to be able to produce invalid binaries for the tests.
|
|
|
|
ECase(ELFDATANONE);
|
2017-02-01 05:11:12 +08:00
|
|
|
ECase(ELFDATA2LSB);
|
|
|
|
ECase(ELFDATA2MSB);
|
2013-06-11 07:44:15 +08:00
|
|
|
#undef ECase
|
|
|
|
}
|
|
|
|
|
2013-06-19 08:55:28 +08:00
|
|
|
void ScalarEnumerationTraits<ELFYAML::ELF_ELFOSABI>::enumeration(
|
|
|
|
IO &IO, ELFYAML::ELF_ELFOSABI &Value) {
|
2017-02-01 05:11:12 +08:00
|
|
|
#define ECase(X) IO.enumCase(Value, #X, ELF::X)
|
|
|
|
ECase(ELFOSABI_NONE);
|
|
|
|
ECase(ELFOSABI_HPUX);
|
|
|
|
ECase(ELFOSABI_NETBSD);
|
|
|
|
ECase(ELFOSABI_GNU);
|
2019-12-20 20:51:10 +08:00
|
|
|
ECase(ELFOSABI_LINUX);
|
2017-02-01 05:11:12 +08:00
|
|
|
ECase(ELFOSABI_HURD);
|
|
|
|
ECase(ELFOSABI_SOLARIS);
|
|
|
|
ECase(ELFOSABI_AIX);
|
|
|
|
ECase(ELFOSABI_IRIX);
|
|
|
|
ECase(ELFOSABI_FREEBSD);
|
|
|
|
ECase(ELFOSABI_TRU64);
|
|
|
|
ECase(ELFOSABI_MODESTO);
|
|
|
|
ECase(ELFOSABI_OPENBSD);
|
|
|
|
ECase(ELFOSABI_OPENVMS);
|
|
|
|
ECase(ELFOSABI_NSK);
|
|
|
|
ECase(ELFOSABI_AROS);
|
|
|
|
ECase(ELFOSABI_FENIXOS);
|
|
|
|
ECase(ELFOSABI_CLOUDABI);
|
|
|
|
ECase(ELFOSABI_AMDGPU_HSA);
|
2017-10-04 04:54:07 +08:00
|
|
|
ECase(ELFOSABI_AMDGPU_PAL);
|
2017-10-04 05:14:14 +08:00
|
|
|
ECase(ELFOSABI_AMDGPU_MESA3D);
|
2017-02-01 05:11:12 +08:00
|
|
|
ECase(ELFOSABI_ARM);
|
2017-10-04 04:54:07 +08:00
|
|
|
ECase(ELFOSABI_C6000_ELFABI);
|
|
|
|
ECase(ELFOSABI_C6000_LINUX);
|
2017-02-01 05:11:12 +08:00
|
|
|
ECase(ELFOSABI_STANDALONE);
|
2013-06-19 08:55:28 +08:00
|
|
|
#undef ECase
|
2019-12-20 22:02:43 +08:00
|
|
|
IO.enumFallback<Hex8>(Value);
|
2013-06-19 08:55:28 +08:00
|
|
|
}
|
|
|
|
|
2014-03-31 17:44:05 +08:00
|
|
|
void ScalarBitSetTraits<ELFYAML::ELF_EF>::bitset(IO &IO,
|
|
|
|
ELFYAML::ELF_EF &Value) {
|
2014-05-03 19:39:50 +08:00
|
|
|
const auto *Object = static_cast<ELFYAML::Object *>(IO.getContext());
|
|
|
|
assert(Object && "The IO context is not initialized");
|
2017-02-01 05:11:12 +08:00
|
|
|
#define BCase(X) IO.bitSetCase(Value, #X, ELF::X)
|
|
|
|
#define BCaseMask(X, M) IO.maskedBitSetCase(Value, #X, ELF::X, ELF::M)
|
2020-08-18 20:24:26 +08:00
|
|
|
switch (Object->getMachine()) {
|
2014-05-03 19:39:50 +08:00
|
|
|
case ELF::EM_ARM:
|
2017-02-01 05:11:12 +08:00
|
|
|
BCase(EF_ARM_SOFT_FLOAT);
|
|
|
|
BCase(EF_ARM_VFP_FLOAT);
|
|
|
|
BCaseMask(EF_ARM_EABI_UNKNOWN, EF_ARM_EABIMASK);
|
|
|
|
BCaseMask(EF_ARM_EABI_VER1, EF_ARM_EABIMASK);
|
|
|
|
BCaseMask(EF_ARM_EABI_VER2, EF_ARM_EABIMASK);
|
|
|
|
BCaseMask(EF_ARM_EABI_VER3, EF_ARM_EABIMASK);
|
|
|
|
BCaseMask(EF_ARM_EABI_VER4, EF_ARM_EABIMASK);
|
|
|
|
BCaseMask(EF_ARM_EABI_VER5, EF_ARM_EABIMASK);
|
2014-05-03 19:39:50 +08:00
|
|
|
break;
|
|
|
|
case ELF::EM_MIPS:
|
2017-02-01 05:11:12 +08:00
|
|
|
BCase(EF_MIPS_NOREORDER);
|
|
|
|
BCase(EF_MIPS_PIC);
|
|
|
|
BCase(EF_MIPS_CPIC);
|
|
|
|
BCase(EF_MIPS_ABI2);
|
|
|
|
BCase(EF_MIPS_32BITMODE);
|
|
|
|
BCase(EF_MIPS_FP64);
|
|
|
|
BCase(EF_MIPS_NAN2008);
|
|
|
|
BCase(EF_MIPS_MICROMIPS);
|
|
|
|
BCase(EF_MIPS_ARCH_ASE_M16);
|
|
|
|
BCase(EF_MIPS_ARCH_ASE_MDMX);
|
|
|
|
BCaseMask(EF_MIPS_ABI_O32, EF_MIPS_ABI);
|
|
|
|
BCaseMask(EF_MIPS_ABI_O64, EF_MIPS_ABI);
|
|
|
|
BCaseMask(EF_MIPS_ABI_EABI32, EF_MIPS_ABI);
|
|
|
|
BCaseMask(EF_MIPS_ABI_EABI64, EF_MIPS_ABI);
|
|
|
|
BCaseMask(EF_MIPS_MACH_3900, EF_MIPS_MACH);
|
|
|
|
BCaseMask(EF_MIPS_MACH_4010, EF_MIPS_MACH);
|
|
|
|
BCaseMask(EF_MIPS_MACH_4100, EF_MIPS_MACH);
|
|
|
|
BCaseMask(EF_MIPS_MACH_4650, EF_MIPS_MACH);
|
|
|
|
BCaseMask(EF_MIPS_MACH_4120, EF_MIPS_MACH);
|
|
|
|
BCaseMask(EF_MIPS_MACH_4111, EF_MIPS_MACH);
|
|
|
|
BCaseMask(EF_MIPS_MACH_SB1, EF_MIPS_MACH);
|
|
|
|
BCaseMask(EF_MIPS_MACH_OCTEON, EF_MIPS_MACH);
|
|
|
|
BCaseMask(EF_MIPS_MACH_XLR, EF_MIPS_MACH);
|
|
|
|
BCaseMask(EF_MIPS_MACH_OCTEON2, EF_MIPS_MACH);
|
|
|
|
BCaseMask(EF_MIPS_MACH_OCTEON3, EF_MIPS_MACH);
|
|
|
|
BCaseMask(EF_MIPS_MACH_5400, EF_MIPS_MACH);
|
|
|
|
BCaseMask(EF_MIPS_MACH_5900, EF_MIPS_MACH);
|
|
|
|
BCaseMask(EF_MIPS_MACH_5500, EF_MIPS_MACH);
|
|
|
|
BCaseMask(EF_MIPS_MACH_9000, EF_MIPS_MACH);
|
|
|
|
BCaseMask(EF_MIPS_MACH_LS2E, EF_MIPS_MACH);
|
|
|
|
BCaseMask(EF_MIPS_MACH_LS2F, EF_MIPS_MACH);
|
|
|
|
BCaseMask(EF_MIPS_MACH_LS3A, EF_MIPS_MACH);
|
|
|
|
BCaseMask(EF_MIPS_ARCH_1, EF_MIPS_ARCH);
|
|
|
|
BCaseMask(EF_MIPS_ARCH_2, EF_MIPS_ARCH);
|
|
|
|
BCaseMask(EF_MIPS_ARCH_3, EF_MIPS_ARCH);
|
|
|
|
BCaseMask(EF_MIPS_ARCH_4, EF_MIPS_ARCH);
|
|
|
|
BCaseMask(EF_MIPS_ARCH_5, EF_MIPS_ARCH);
|
|
|
|
BCaseMask(EF_MIPS_ARCH_32, EF_MIPS_ARCH);
|
|
|
|
BCaseMask(EF_MIPS_ARCH_64, EF_MIPS_ARCH);
|
|
|
|
BCaseMask(EF_MIPS_ARCH_32R2, EF_MIPS_ARCH);
|
|
|
|
BCaseMask(EF_MIPS_ARCH_64R2, EF_MIPS_ARCH);
|
|
|
|
BCaseMask(EF_MIPS_ARCH_32R6, EF_MIPS_ARCH);
|
|
|
|
BCaseMask(EF_MIPS_ARCH_64R6, EF_MIPS_ARCH);
|
2014-05-03 19:39:50 +08:00
|
|
|
break;
|
|
|
|
case ELF::EM_HEXAGON:
|
2017-02-01 05:11:12 +08:00
|
|
|
BCase(EF_HEXAGON_MACH_V2);
|
|
|
|
BCase(EF_HEXAGON_MACH_V3);
|
|
|
|
BCase(EF_HEXAGON_MACH_V4);
|
|
|
|
BCase(EF_HEXAGON_MACH_V5);
|
2018-11-29 00:25:47 +08:00
|
|
|
BCase(EF_HEXAGON_MACH_V55);
|
|
|
|
BCase(EF_HEXAGON_MACH_V60);
|
|
|
|
BCase(EF_HEXAGON_MACH_V62);
|
|
|
|
BCase(EF_HEXAGON_MACH_V65);
|
2020-01-17 04:46:03 +08:00
|
|
|
BCase(EF_HEXAGON_MACH_V66);
|
2020-01-18 06:29:40 +08:00
|
|
|
BCase(EF_HEXAGON_MACH_V67);
|
2020-01-14 06:07:30 +08:00
|
|
|
BCase(EF_HEXAGON_MACH_V67T);
|
2021-03-18 10:37:40 +08:00
|
|
|
BCase(EF_HEXAGON_MACH_V68);
|
2017-02-01 05:11:12 +08:00
|
|
|
BCase(EF_HEXAGON_ISA_V2);
|
|
|
|
BCase(EF_HEXAGON_ISA_V3);
|
|
|
|
BCase(EF_HEXAGON_ISA_V4);
|
|
|
|
BCase(EF_HEXAGON_ISA_V5);
|
2018-11-29 00:25:47 +08:00
|
|
|
BCase(EF_HEXAGON_ISA_V55);
|
|
|
|
BCase(EF_HEXAGON_ISA_V60);
|
|
|
|
BCase(EF_HEXAGON_ISA_V62);
|
|
|
|
BCase(EF_HEXAGON_ISA_V65);
|
2020-01-17 04:46:03 +08:00
|
|
|
BCase(EF_HEXAGON_ISA_V66);
|
2020-01-18 06:29:40 +08:00
|
|
|
BCase(EF_HEXAGON_ISA_V67);
|
2021-03-18 10:37:40 +08:00
|
|
|
BCase(EF_HEXAGON_ISA_V68);
|
2014-05-03 19:39:50 +08:00
|
|
|
break;
|
2015-10-23 14:05:55 +08:00
|
|
|
case ELF::EM_AVR:
|
2021-04-15 21:52:54 +08:00
|
|
|
BCaseMask(EF_AVR_ARCH_AVR1, EF_AVR_ARCH_MASK);
|
|
|
|
BCaseMask(EF_AVR_ARCH_AVR2, EF_AVR_ARCH_MASK);
|
|
|
|
BCaseMask(EF_AVR_ARCH_AVR25, EF_AVR_ARCH_MASK);
|
|
|
|
BCaseMask(EF_AVR_ARCH_AVR3, EF_AVR_ARCH_MASK);
|
|
|
|
BCaseMask(EF_AVR_ARCH_AVR31, EF_AVR_ARCH_MASK);
|
|
|
|
BCaseMask(EF_AVR_ARCH_AVR35, EF_AVR_ARCH_MASK);
|
|
|
|
BCaseMask(EF_AVR_ARCH_AVR4, EF_AVR_ARCH_MASK);
|
|
|
|
BCaseMask(EF_AVR_ARCH_AVR5, EF_AVR_ARCH_MASK);
|
|
|
|
BCaseMask(EF_AVR_ARCH_AVR51, EF_AVR_ARCH_MASK);
|
|
|
|
BCaseMask(EF_AVR_ARCH_AVR6, EF_AVR_ARCH_MASK);
|
|
|
|
BCaseMask(EF_AVR_ARCH_AVRTINY, EF_AVR_ARCH_MASK);
|
|
|
|
BCaseMask(EF_AVR_ARCH_XMEGA1, EF_AVR_ARCH_MASK);
|
|
|
|
BCaseMask(EF_AVR_ARCH_XMEGA2, EF_AVR_ARCH_MASK);
|
|
|
|
BCaseMask(EF_AVR_ARCH_XMEGA3, EF_AVR_ARCH_MASK);
|
|
|
|
BCaseMask(EF_AVR_ARCH_XMEGA4, EF_AVR_ARCH_MASK);
|
|
|
|
BCaseMask(EF_AVR_ARCH_XMEGA5, EF_AVR_ARCH_MASK);
|
|
|
|
BCaseMask(EF_AVR_ARCH_XMEGA6, EF_AVR_ARCH_MASK);
|
|
|
|
BCaseMask(EF_AVR_ARCH_XMEGA7, EF_AVR_ARCH_MASK);
|
|
|
|
BCase(EF_AVR_LINKRELAX_PREPARED);
|
2015-10-23 14:05:55 +08:00
|
|
|
break;
|
2017-10-03 16:00:47 +08:00
|
|
|
case ELF::EM_RISCV:
|
|
|
|
BCase(EF_RISCV_RVC);
|
|
|
|
BCaseMask(EF_RISCV_FLOAT_ABI_SOFT, EF_RISCV_FLOAT_ABI);
|
|
|
|
BCaseMask(EF_RISCV_FLOAT_ABI_SINGLE, EF_RISCV_FLOAT_ABI);
|
|
|
|
BCaseMask(EF_RISCV_FLOAT_ABI_DOUBLE, EF_RISCV_FLOAT_ABI);
|
|
|
|
BCaseMask(EF_RISCV_FLOAT_ABI_QUAD, EF_RISCV_FLOAT_ABI);
|
|
|
|
BCase(EF_RISCV_RVE);
|
|
|
|
break;
|
2016-01-21 03:15:18 +08:00
|
|
|
case ELF::EM_AMDGPU:
|
2018-02-17 06:33:59 +08:00
|
|
|
BCaseMask(EF_AMDGPU_MACH_NONE, EF_AMDGPU_MACH);
|
|
|
|
BCaseMask(EF_AMDGPU_MACH_R600_R600, EF_AMDGPU_MACH);
|
|
|
|
BCaseMask(EF_AMDGPU_MACH_R600_R630, EF_AMDGPU_MACH);
|
|
|
|
BCaseMask(EF_AMDGPU_MACH_R600_RS880, EF_AMDGPU_MACH);
|
|
|
|
BCaseMask(EF_AMDGPU_MACH_R600_RV670, EF_AMDGPU_MACH);
|
|
|
|
BCaseMask(EF_AMDGPU_MACH_R600_RV710, EF_AMDGPU_MACH);
|
|
|
|
BCaseMask(EF_AMDGPU_MACH_R600_RV730, EF_AMDGPU_MACH);
|
|
|
|
BCaseMask(EF_AMDGPU_MACH_R600_RV770, EF_AMDGPU_MACH);
|
|
|
|
BCaseMask(EF_AMDGPU_MACH_R600_CEDAR, EF_AMDGPU_MACH);
|
|
|
|
BCaseMask(EF_AMDGPU_MACH_R600_CYPRESS, EF_AMDGPU_MACH);
|
|
|
|
BCaseMask(EF_AMDGPU_MACH_R600_JUNIPER, EF_AMDGPU_MACH);
|
|
|
|
BCaseMask(EF_AMDGPU_MACH_R600_REDWOOD, EF_AMDGPU_MACH);
|
|
|
|
BCaseMask(EF_AMDGPU_MACH_R600_SUMO, EF_AMDGPU_MACH);
|
|
|
|
BCaseMask(EF_AMDGPU_MACH_R600_BARTS, EF_AMDGPU_MACH);
|
|
|
|
BCaseMask(EF_AMDGPU_MACH_R600_CAICOS, EF_AMDGPU_MACH);
|
|
|
|
BCaseMask(EF_AMDGPU_MACH_R600_CAYMAN, EF_AMDGPU_MACH);
|
|
|
|
BCaseMask(EF_AMDGPU_MACH_R600_TURKS, EF_AMDGPU_MACH);
|
|
|
|
BCaseMask(EF_AMDGPU_MACH_AMDGCN_GFX600, EF_AMDGPU_MACH);
|
|
|
|
BCaseMask(EF_AMDGPU_MACH_AMDGCN_GFX601, EF_AMDGPU_MACH);
|
2020-10-07 01:23:59 +08:00
|
|
|
BCaseMask(EF_AMDGPU_MACH_AMDGCN_GFX602, EF_AMDGPU_MACH);
|
2018-02-17 06:33:59 +08:00
|
|
|
BCaseMask(EF_AMDGPU_MACH_AMDGCN_GFX700, EF_AMDGPU_MACH);
|
|
|
|
BCaseMask(EF_AMDGPU_MACH_AMDGCN_GFX701, EF_AMDGPU_MACH);
|
|
|
|
BCaseMask(EF_AMDGPU_MACH_AMDGCN_GFX702, EF_AMDGPU_MACH);
|
|
|
|
BCaseMask(EF_AMDGPU_MACH_AMDGCN_GFX703, EF_AMDGPU_MACH);
|
|
|
|
BCaseMask(EF_AMDGPU_MACH_AMDGCN_GFX704, EF_AMDGPU_MACH);
|
2020-10-07 01:23:59 +08:00
|
|
|
BCaseMask(EF_AMDGPU_MACH_AMDGCN_GFX705, EF_AMDGPU_MACH);
|
2018-02-17 06:33:59 +08:00
|
|
|
BCaseMask(EF_AMDGPU_MACH_AMDGCN_GFX801, EF_AMDGPU_MACH);
|
|
|
|
BCaseMask(EF_AMDGPU_MACH_AMDGCN_GFX802, EF_AMDGPU_MACH);
|
|
|
|
BCaseMask(EF_AMDGPU_MACH_AMDGCN_GFX803, EF_AMDGPU_MACH);
|
2020-10-07 01:23:59 +08:00
|
|
|
BCaseMask(EF_AMDGPU_MACH_AMDGCN_GFX805, EF_AMDGPU_MACH);
|
2018-02-17 06:33:59 +08:00
|
|
|
BCaseMask(EF_AMDGPU_MACH_AMDGCN_GFX810, EF_AMDGPU_MACH);
|
|
|
|
BCaseMask(EF_AMDGPU_MACH_AMDGCN_GFX900, EF_AMDGPU_MACH);
|
|
|
|
BCaseMask(EF_AMDGPU_MACH_AMDGCN_GFX902, EF_AMDGPU_MACH);
|
2018-05-01 03:08:16 +08:00
|
|
|
BCaseMask(EF_AMDGPU_MACH_AMDGCN_GFX904, EF_AMDGPU_MACH);
|
|
|
|
BCaseMask(EF_AMDGPU_MACH_AMDGCN_GFX906, EF_AMDGPU_MACH);
|
2019-07-10 02:10:06 +08:00
|
|
|
BCaseMask(EF_AMDGPU_MACH_AMDGCN_GFX908, EF_AMDGPU_MACH);
|
2018-10-24 16:14:07 +08:00
|
|
|
BCaseMask(EF_AMDGPU_MACH_AMDGCN_GFX909, EF_AMDGPU_MACH);
|
2021-02-18 05:37:46 +08:00
|
|
|
BCaseMask(EF_AMDGPU_MACH_AMDGCN_GFX90A, EF_AMDGPU_MACH);
|
2020-10-07 01:23:59 +08:00
|
|
|
BCaseMask(EF_AMDGPU_MACH_AMDGCN_GFX90C, EF_AMDGPU_MACH);
|
2019-04-25 01:03:15 +08:00
|
|
|
BCaseMask(EF_AMDGPU_MACH_AMDGCN_GFX1010, EF_AMDGPU_MACH);
|
2019-06-14 08:33:31 +08:00
|
|
|
BCaseMask(EF_AMDGPU_MACH_AMDGCN_GFX1011, EF_AMDGPU_MACH);
|
|
|
|
BCaseMask(EF_AMDGPU_MACH_AMDGCN_GFX1012, EF_AMDGPU_MACH);
|
2021-06-09 04:54:42 +08:00
|
|
|
BCaseMask(EF_AMDGPU_MACH_AMDGCN_GFX1013, EF_AMDGPU_MACH);
|
2020-06-16 05:10:39 +08:00
|
|
|
BCaseMask(EF_AMDGPU_MACH_AMDGCN_GFX1030, EF_AMDGPU_MACH);
|
2020-08-06 03:00:52 +08:00
|
|
|
BCaseMask(EF_AMDGPU_MACH_AMDGCN_GFX1031, EF_AMDGPU_MACH);
|
2020-10-16 01:48:46 +08:00
|
|
|
BCaseMask(EF_AMDGPU_MACH_AMDGCN_GFX1032, EF_AMDGPU_MACH);
|
2020-10-30 16:21:12 +08:00
|
|
|
BCaseMask(EF_AMDGPU_MACH_AMDGCN_GFX1033, EF_AMDGPU_MACH);
|
2021-05-14 02:21:40 +08:00
|
|
|
BCaseMask(EF_AMDGPU_MACH_AMDGCN_GFX1034, EF_AMDGPU_MACH);
|
2021-06-25 02:32:41 +08:00
|
|
|
BCaseMask(EF_AMDGPU_MACH_AMDGCN_GFX1035, EF_AMDGPU_MACH);
|
2021-03-24 23:52:10 +08:00
|
|
|
switch (Object->Header.ABIVersion) {
|
|
|
|
default:
|
|
|
|
// ELFOSABI_AMDGPU_PAL, ELFOSABI_AMDGPU_MESA3D support *_V3 flags.
|
|
|
|
LLVM_FALLTHROUGH;
|
|
|
|
case ELF::ELFABIVERSION_AMDGPU_HSA_V3:
|
|
|
|
BCase(EF_AMDGPU_FEATURE_XNACK_V3);
|
|
|
|
BCase(EF_AMDGPU_FEATURE_SRAMECC_V3);
|
|
|
|
break;
|
|
|
|
case ELF::ELFABIVERSION_AMDGPU_HSA_V4:
|
|
|
|
BCaseMask(EF_AMDGPU_FEATURE_XNACK_UNSUPPORTED_V4,
|
|
|
|
EF_AMDGPU_FEATURE_XNACK_V4);
|
|
|
|
BCaseMask(EF_AMDGPU_FEATURE_XNACK_ANY_V4,
|
|
|
|
EF_AMDGPU_FEATURE_XNACK_V4);
|
|
|
|
BCaseMask(EF_AMDGPU_FEATURE_XNACK_OFF_V4,
|
|
|
|
EF_AMDGPU_FEATURE_XNACK_V4);
|
|
|
|
BCaseMask(EF_AMDGPU_FEATURE_XNACK_ON_V4,
|
|
|
|
EF_AMDGPU_FEATURE_XNACK_V4);
|
|
|
|
BCaseMask(EF_AMDGPU_FEATURE_SRAMECC_UNSUPPORTED_V4,
|
|
|
|
EF_AMDGPU_FEATURE_SRAMECC_V4);
|
|
|
|
BCaseMask(EF_AMDGPU_FEATURE_SRAMECC_ANY_V4,
|
|
|
|
EF_AMDGPU_FEATURE_SRAMECC_V4);
|
|
|
|
BCaseMask(EF_AMDGPU_FEATURE_SRAMECC_OFF_V4,
|
|
|
|
EF_AMDGPU_FEATURE_SRAMECC_V4);
|
|
|
|
BCaseMask(EF_AMDGPU_FEATURE_SRAMECC_ON_V4,
|
|
|
|
EF_AMDGPU_FEATURE_SRAMECC_V4);
|
|
|
|
break;
|
|
|
|
}
|
2017-10-06 00:19:18 +08:00
|
|
|
break;
|
2014-05-03 19:39:50 +08:00
|
|
|
default:
|
2020-08-18 20:52:09 +08:00
|
|
|
break;
|
2014-05-03 19:39:50 +08:00
|
|
|
}
|
2014-03-31 17:44:05 +08:00
|
|
|
#undef BCase
|
2014-05-23 16:07:09 +08:00
|
|
|
#undef BCaseMask
|
2014-03-31 17:44:05 +08:00
|
|
|
}
|
|
|
|
|
2013-06-14 06:19:48 +08:00
|
|
|
void ScalarEnumerationTraits<ELFYAML::ELF_SHT>::enumeration(
|
|
|
|
IO &IO, ELFYAML::ELF_SHT &Value) {
|
2014-07-13 02:25:08 +08:00
|
|
|
const auto *Object = static_cast<ELFYAML::Object *>(IO.getContext());
|
|
|
|
assert(Object && "The IO context is not initialized");
|
2017-02-01 05:11:12 +08:00
|
|
|
#define ECase(X) IO.enumCase(Value, #X, ELF::X)
|
|
|
|
ECase(SHT_NULL);
|
|
|
|
ECase(SHT_PROGBITS);
|
2017-11-09 22:53:43 +08:00
|
|
|
ECase(SHT_SYMTAB);
|
2013-06-22 09:38:00 +08:00
|
|
|
// FIXME: Issue a diagnostic with this information.
|
2017-02-01 05:11:12 +08:00
|
|
|
ECase(SHT_STRTAB);
|
|
|
|
ECase(SHT_RELA);
|
|
|
|
ECase(SHT_HASH);
|
|
|
|
ECase(SHT_DYNAMIC);
|
|
|
|
ECase(SHT_NOTE);
|
|
|
|
ECase(SHT_NOBITS);
|
|
|
|
ECase(SHT_REL);
|
|
|
|
ECase(SHT_SHLIB);
|
|
|
|
ECase(SHT_DYNSYM);
|
|
|
|
ECase(SHT_INIT_ARRAY);
|
|
|
|
ECase(SHT_FINI_ARRAY);
|
|
|
|
ECase(SHT_PREINIT_ARRAY);
|
|
|
|
ECase(SHT_GROUP);
|
|
|
|
ECase(SHT_SYMTAB_SHNDX);
|
2018-06-29 05:07:34 +08:00
|
|
|
ECase(SHT_RELR);
|
2017-10-25 11:37:12 +08:00
|
|
|
ECase(SHT_ANDROID_REL);
|
|
|
|
ECase(SHT_ANDROID_RELA);
|
2018-06-29 05:07:34 +08:00
|
|
|
ECase(SHT_ANDROID_RELR);
|
2017-06-15 02:52:12 +08:00
|
|
|
ECase(SHT_LLVM_ODRTAB);
|
2018-01-31 00:29:29 +08:00
|
|
|
ECase(SHT_LLVM_LINKER_OPTIONS);
|
[MC] Add assembler support for .cg_profile.
Object FIle Representation
At codegen time this is emitted into the ELF file a pair of symbol indices and a weight. In assembly it looks like:
.cg_profile a, b, 32
.cg_profile freq, a, 11
.cg_profile freq, b, 20
When writing an ELF file these are put into a SHT_LLVM_CALL_GRAPH_PROFILE (0x6fff4c02) section as (uint32_t, uint32_t, uint64_t) tuples as (from symbol index, to symbol index, weight).
Differential Revision: https://reviews.llvm.org/D44965
llvm-svn: 333823
2018-06-03 00:33:01 +08:00
|
|
|
ECase(SHT_LLVM_CALL_GRAPH_PROFILE);
|
2018-07-18 06:17:18 +08:00
|
|
|
ECase(SHT_LLVM_ADDRSIG);
|
[ELF] Implement Dependent Libraries Feature
This patch implements a limited form of autolinking primarily designed to allow
either the --dependent-library compiler option, or "comment lib" pragmas (
https://docs.microsoft.com/en-us/cpp/preprocessor/comment-c-cpp?view=vs-2017) in
C/C++ e.g. #pragma comment(lib, "foo"), to cause an ELF linker to automatically
add the specified library to the link when processing the input file generated
by the compiler.
Currently this extension is unique to LLVM and LLD. However, care has been taken
to design this feature so that it could be supported by other ELF linkers.
The design goals were to provide:
- A simple linking model for developers to reason about.
- The ability to to override autolinking from the linker command line.
- Source code compatibility, where possible, with "comment lib" pragmas in other
environments (MSVC in particular).
Dependent library support is implemented differently for ELF platforms than on
the other platforms. Primarily this difference is that on ELF we pass the
dependent library specifiers directly to the linker without manipulating them.
This is in contrast to other platforms where they are mapped to a specific
linker option by the compiler. This difference is a result of the greater
variety of ELF linkers and the fact that ELF linkers tend to handle libraries in
a more complicated fashion than on other platforms. This forces us to defer
handling the specifiers to the linker.
In order to achieve a level of source code compatibility with other platforms
we have restricted this feature to work with libraries that meet the following
"reasonable" requirements:
1. There are no competing defined symbols in a given set of libraries, or
if they exist, the program owner doesn't care which is linked to their
program.
2. There may be circular dependencies between libraries.
The binary representation is a mergeable string section (SHF_MERGE,
SHF_STRINGS), called .deplibs, with custom type SHT_LLVM_DEPENDENT_LIBRARIES
(0x6fff4c04). The compiler forms this section by concatenating the arguments of
the "comment lib" pragmas and --dependent-library options in the order they are
encountered. Partial (-r, -Ur) links are handled by concatenating .deplibs
sections with the normal mergeable string section rules. As an example, #pragma
comment(lib, "foo") would result in:
.section ".deplibs","MS",@llvm_dependent_libraries,1
.asciz "foo"
For LTO, equivalent information to the contents of a the .deplibs section can be
retrieved by the LLD for bitcode input files.
LLD processes the dependent library specifiers in the following way:
1. Dependent libraries which are found from the specifiers in .deplibs sections
of relocatable object files are added when the linker decides to include that
file (which could itself be in a library) in the link. Dependent libraries
behave as if they were appended to the command line after all other options. As
a consequence the set of dependent libraries are searched last to resolve
symbols.
2. It is an error if a file cannot be found for a given specifier.
3. Any command line options in effect at the end of the command line parsing apply
to the dependent libraries, e.g. --whole-archive.
4. The linker tries to add a library or relocatable object file from each of the
strings in a .deplibs section by; first, handling the string as if it was
specified on the command line; second, by looking for the string in each of the
library search paths in turn; third, by looking for a lib<string>.a or
lib<string>.so (depending on the current mode of the linker) in each of the
library search paths.
5. A new command line option --no-dependent-libraries tells LLD to ignore the
dependent libraries.
Rationale for the above points:
1. Adding the dependent libraries last makes the process simple to understand
from a developers perspective. All linkers are able to implement this scheme.
2. Error-ing for libraries that are not found seems like better behavior than
failing the link during symbol resolution.
3. It seems useful for the user to be able to apply command line options which
will affect all of the dependent libraries. There is a potential problem of
surprise for developers, who might not realize that these options would apply
to these "invisible" input files; however, despite the potential for surprise,
this is easy for developers to reason about and gives developers the control
that they may require.
4. This algorithm takes into account all of the different ways that ELF linkers
find input files. The different search methods are tried by the linker in most
obvious to least obvious order.
5. I considered adding finer grained control over which dependent libraries were
ignored (e.g. MSVC has /nodefaultlib:<library>); however, I concluded that this
is not necessary: if finer control is required developers can fall back to using
the command line directly.
RFC thread: http://lists.llvm.org/pipermail/llvm-dev/2019-March/131004.html.
Differential Revision: https://reviews.llvm.org/D60274
llvm-svn: 360984
2019-05-17 11:44:15 +08:00
|
|
|
ECase(SHT_LLVM_DEPENDENT_LIBRARIES);
|
2019-09-06 08:53:28 +08:00
|
|
|
ECase(SHT_LLVM_SYMPART);
|
|
|
|
ECase(SHT_LLVM_PART_EHDR);
|
|
|
|
ECase(SHT_LLVM_PART_PHDR);
|
2020-11-07 04:44:24 +08:00
|
|
|
ECase(SHT_LLVM_BB_ADDR_MAP);
|
2017-02-01 05:11:12 +08:00
|
|
|
ECase(SHT_GNU_ATTRIBUTES);
|
|
|
|
ECase(SHT_GNU_HASH);
|
|
|
|
ECase(SHT_GNU_verdef);
|
|
|
|
ECase(SHT_GNU_verneed);
|
|
|
|
ECase(SHT_GNU_versym);
|
2020-08-18 20:24:26 +08:00
|
|
|
switch (Object->getMachine()) {
|
2014-07-13 02:25:08 +08:00
|
|
|
case ELF::EM_ARM:
|
2017-02-01 05:11:12 +08:00
|
|
|
ECase(SHT_ARM_EXIDX);
|
|
|
|
ECase(SHT_ARM_PREEMPTMAP);
|
|
|
|
ECase(SHT_ARM_ATTRIBUTES);
|
|
|
|
ECase(SHT_ARM_DEBUGOVERLAY);
|
|
|
|
ECase(SHT_ARM_OVERLAYSECTION);
|
2014-07-13 02:25:08 +08:00
|
|
|
break;
|
|
|
|
case ELF::EM_HEXAGON:
|
2017-02-01 05:11:12 +08:00
|
|
|
ECase(SHT_HEX_ORDERED);
|
2014-07-13 02:25:08 +08:00
|
|
|
break;
|
|
|
|
case ELF::EM_X86_64:
|
2017-02-01 05:11:12 +08:00
|
|
|
ECase(SHT_X86_64_UNWIND);
|
2014-07-13 02:25:08 +08:00
|
|
|
break;
|
|
|
|
case ELF::EM_MIPS:
|
2017-02-01 05:11:12 +08:00
|
|
|
ECase(SHT_MIPS_REGINFO);
|
|
|
|
ECase(SHT_MIPS_OPTIONS);
|
2019-02-21 18:19:08 +08:00
|
|
|
ECase(SHT_MIPS_DWARF);
|
2017-02-01 05:11:12 +08:00
|
|
|
ECase(SHT_MIPS_ABIFLAGS);
|
2014-07-14 00:18:56 +08:00
|
|
|
break;
|
2020-02-04 22:20:10 +08:00
|
|
|
case ELF::EM_RISCV:
|
|
|
|
ECase(SHT_RISCV_ATTRIBUTES);
|
|
|
|
break;
|
2014-07-13 02:25:08 +08:00
|
|
|
default:
|
|
|
|
// Nothing to do.
|
|
|
|
break;
|
|
|
|
}
|
2013-06-14 06:19:48 +08:00
|
|
|
#undef ECase
|
2019-02-20 00:22:21 +08:00
|
|
|
IO.enumFallback<Hex32>(Value);
|
2013-06-14 06:19:48 +08:00
|
|
|
}
|
|
|
|
|
2017-07-20 04:38:46 +08:00
|
|
|
void ScalarBitSetTraits<ELFYAML::ELF_PF>::bitset(IO &IO,
|
|
|
|
ELFYAML::ELF_PF &Value) {
|
|
|
|
#define BCase(X) IO.bitSetCase(Value, #X, ELF::X)
|
|
|
|
BCase(PF_X);
|
|
|
|
BCase(PF_W);
|
|
|
|
BCase(PF_R);
|
|
|
|
}
|
|
|
|
|
2013-06-14 06:19:48 +08:00
|
|
|
void ScalarBitSetTraits<ELFYAML::ELF_SHF>::bitset(IO &IO,
|
|
|
|
ELFYAML::ELF_SHF &Value) {
|
2015-11-14 01:06:29 +08:00
|
|
|
const auto *Object = static_cast<ELFYAML::Object *>(IO.getContext());
|
2017-02-01 05:11:12 +08:00
|
|
|
#define BCase(X) IO.bitSetCase(Value, #X, ELF::X)
|
|
|
|
BCase(SHF_WRITE);
|
|
|
|
BCase(SHF_ALLOC);
|
|
|
|
BCase(SHF_EXCLUDE);
|
|
|
|
BCase(SHF_EXECINSTR);
|
|
|
|
BCase(SHF_MERGE);
|
|
|
|
BCase(SHF_STRINGS);
|
|
|
|
BCase(SHF_INFO_LINK);
|
|
|
|
BCase(SHF_LINK_ORDER);
|
|
|
|
BCase(SHF_OS_NONCONFORMING);
|
|
|
|
BCase(SHF_GROUP);
|
|
|
|
BCase(SHF_TLS);
|
2017-10-03 14:35:55 +08:00
|
|
|
BCase(SHF_COMPRESSED);
|
2021-02-03 01:19:53 +08:00
|
|
|
BCase(SHF_GNU_RETAIN);
|
2020-08-18 20:24:26 +08:00
|
|
|
switch (Object->getMachine()) {
|
2016-12-15 15:59:08 +08:00
|
|
|
case ELF::EM_ARM:
|
2017-02-01 05:11:12 +08:00
|
|
|
BCase(SHF_ARM_PURECODE);
|
2016-12-15 15:59:08 +08:00
|
|
|
break;
|
2016-01-21 03:15:18 +08:00
|
|
|
case ELF::EM_HEXAGON:
|
2017-02-01 05:11:12 +08:00
|
|
|
BCase(SHF_HEX_GPREL);
|
2016-01-21 03:15:18 +08:00
|
|
|
break;
|
|
|
|
case ELF::EM_MIPS:
|
2017-02-01 05:11:12 +08:00
|
|
|
BCase(SHF_MIPS_NODUPES);
|
|
|
|
BCase(SHF_MIPS_NAMES);
|
|
|
|
BCase(SHF_MIPS_LOCAL);
|
|
|
|
BCase(SHF_MIPS_NOSTRIP);
|
|
|
|
BCase(SHF_MIPS_GPREL);
|
|
|
|
BCase(SHF_MIPS_MERGE);
|
|
|
|
BCase(SHF_MIPS_ADDR);
|
|
|
|
BCase(SHF_MIPS_STRING);
|
2016-01-21 03:15:18 +08:00
|
|
|
break;
|
|
|
|
case ELF::EM_X86_64:
|
2017-02-01 05:11:12 +08:00
|
|
|
BCase(SHF_X86_64_LARGE);
|
2016-01-21 03:15:18 +08:00
|
|
|
break;
|
2015-11-14 01:06:29 +08:00
|
|
|
default:
|
|
|
|
// Nothing to do.
|
|
|
|
break;
|
|
|
|
}
|
2013-06-14 06:19:48 +08:00
|
|
|
#undef BCase
|
|
|
|
}
|
|
|
|
|
2017-09-08 04:44:16 +08:00
|
|
|
void ScalarEnumerationTraits<ELFYAML::ELF_SHN>::enumeration(
|
|
|
|
IO &IO, ELFYAML::ELF_SHN &Value) {
|
|
|
|
#define ECase(X) IO.enumCase(Value, #X, ELF::X)
|
|
|
|
ECase(SHN_UNDEF);
|
|
|
|
ECase(SHN_LORESERVE);
|
|
|
|
ECase(SHN_LOPROC);
|
|
|
|
ECase(SHN_HIPROC);
|
|
|
|
ECase(SHN_LOOS);
|
|
|
|
ECase(SHN_HIOS);
|
|
|
|
ECase(SHN_ABS);
|
|
|
|
ECase(SHN_COMMON);
|
|
|
|
ECase(SHN_XINDEX);
|
|
|
|
ECase(SHN_HIRESERVE);
|
AMDGPU/MC: Add .amdgpu_lds directive
Summary:
The directive defines a symbol as an group/local memory (LDS) symbol.
LDS symbols behave similar to common symbols for the purposes of ELF,
using the processor-specific SHN_AMDGPU_LDS as section index.
It is the linker and/or runtime loader's job to "instantiate" LDS symbols
and resolve relocations that reference them.
It is not possible to initialize LDS memory (not even zero-initialize
as for .bss).
We want to be able to link together objects -- starting with relocatable
objects, but possible expanding to shared objects in the future -- that
access LDS memory in a flexible way.
LDS memory is in an address space that is entirely separate from the
address space that contains the program image (code and normal data),
so having program segments for it doesn't really make sense.
Furthermore, we want to be able to compile multiple kernels in a
compilation unit which have disjoint use of LDS memory. In that case,
we may want to place LDS symbols differently for different kernels
to save memory (LDS memory is very limited and physically private to
each kernel invocation), so we can't simply place LDS symbols in a
.lds section.
Hence this solution where LDS symbols always stay undefined.
Change-Id: I08cbc37a7c0c32f53f7b6123aa0afc91dbc1748f
Reviewers: arsenm, rampitec, t-tye, b-sumner, jsjodin
Subscribers: kzhuravl, jvesely, wdng, yaxunl, dstuttard, tpr, rupprecht, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D61493
llvm-svn: 364296
2019-06-25 19:51:35 +08:00
|
|
|
ECase(SHN_AMDGPU_LDS);
|
2017-09-08 04:44:16 +08:00
|
|
|
ECase(SHN_HEXAGON_SCOMMON);
|
|
|
|
ECase(SHN_HEXAGON_SCOMMON_1);
|
|
|
|
ECase(SHN_HEXAGON_SCOMMON_2);
|
|
|
|
ECase(SHN_HEXAGON_SCOMMON_4);
|
|
|
|
ECase(SHN_HEXAGON_SCOMMON_8);
|
|
|
|
#undef ECase
|
2019-08-08 17:49:05 +08:00
|
|
|
IO.enumFallback<Hex16>(Value);
|
2017-09-08 04:44:16 +08:00
|
|
|
}
|
|
|
|
|
2019-04-03 22:53:42 +08:00
|
|
|
void ScalarEnumerationTraits<ELFYAML::ELF_STB>::enumeration(
|
|
|
|
IO &IO, ELFYAML::ELF_STB &Value) {
|
|
|
|
#define ECase(X) IO.enumCase(Value, #X, ELF::X)
|
|
|
|
ECase(STB_LOCAL);
|
|
|
|
ECase(STB_GLOBAL);
|
|
|
|
ECase(STB_WEAK);
|
|
|
|
ECase(STB_GNU_UNIQUE);
|
|
|
|
#undef ECase
|
|
|
|
IO.enumFallback<Hex8>(Value);
|
|
|
|
}
|
|
|
|
|
2013-06-19 08:11:59 +08:00
|
|
|
void ScalarEnumerationTraits<ELFYAML::ELF_STT>::enumeration(
|
|
|
|
IO &IO, ELFYAML::ELF_STT &Value) {
|
2017-02-01 05:11:12 +08:00
|
|
|
#define ECase(X) IO.enumCase(Value, #X, ELF::X)
|
|
|
|
ECase(STT_NOTYPE);
|
|
|
|
ECase(STT_OBJECT);
|
|
|
|
ECase(STT_FUNC);
|
|
|
|
ECase(STT_SECTION);
|
|
|
|
ECase(STT_FILE);
|
|
|
|
ECase(STT_COMMON);
|
|
|
|
ECase(STT_TLS);
|
|
|
|
ECase(STT_GNU_IFUNC);
|
2013-06-19 08:11:59 +08:00
|
|
|
#undef ECase
|
2019-02-07 01:16:33 +08:00
|
|
|
IO.enumFallback<Hex8>(Value);
|
2013-06-19 08:11:59 +08:00
|
|
|
}
|
|
|
|
|
2014-11-07 06:46:24 +08:00
|
|
|
|
2015-01-25 21:29:25 +08:00
|
|
|
void ScalarEnumerationTraits<ELFYAML::ELF_RSS>::enumeration(
|
|
|
|
IO &IO, ELFYAML::ELF_RSS &Value) {
|
2017-02-01 05:11:12 +08:00
|
|
|
#define ECase(X) IO.enumCase(Value, #X, ELF::X)
|
|
|
|
ECase(RSS_UNDEF);
|
|
|
|
ECase(RSS_GP);
|
|
|
|
ECase(RSS_GP0);
|
|
|
|
ECase(RSS_LOC);
|
2015-01-25 21:29:25 +08:00
|
|
|
#undef ECase
|
|
|
|
}
|
|
|
|
|
2014-04-11 12:13:39 +08:00
|
|
|
void ScalarEnumerationTraits<ELFYAML::ELF_REL>::enumeration(
|
|
|
|
IO &IO, ELFYAML::ELF_REL &Value) {
|
|
|
|
const auto *Object = static_cast<ELFYAML::Object *>(IO.getContext());
|
|
|
|
assert(Object && "The IO context is not initialized");
|
2014-11-22 04:16:09 +08:00
|
|
|
#define ELF_RELOC(X, Y) IO.enumCase(Value, #X, ELF::X);
|
2020-08-18 20:24:26 +08:00
|
|
|
switch (Object->getMachine()) {
|
2014-04-11 12:13:39 +08:00
|
|
|
case ELF::EM_X86_64:
|
2017-06-07 11:48:56 +08:00
|
|
|
#include "llvm/BinaryFormat/ELFRelocs/x86_64.def"
|
2014-04-11 12:13:39 +08:00
|
|
|
break;
|
|
|
|
case ELF::EM_MIPS:
|
2017-06-07 11:48:56 +08:00
|
|
|
#include "llvm/BinaryFormat/ELFRelocs/Mips.def"
|
2014-04-11 12:13:39 +08:00
|
|
|
break;
|
|
|
|
case ELF::EM_HEXAGON:
|
2017-06-07 11:48:56 +08:00
|
|
|
#include "llvm/BinaryFormat/ELFRelocs/Hexagon.def"
|
2014-04-11 12:13:39 +08:00
|
|
|
break;
|
2014-05-08 01:06:38 +08:00
|
|
|
case ELF::EM_386:
|
2015-11-04 19:21:50 +08:00
|
|
|
case ELF::EM_IAMCU:
|
2017-06-07 11:48:56 +08:00
|
|
|
#include "llvm/BinaryFormat/ELFRelocs/i386.def"
|
2014-05-08 01:06:38 +08:00
|
|
|
break;
|
2014-11-11 07:02:03 +08:00
|
|
|
case ELF::EM_AARCH64:
|
2017-06-07 11:48:56 +08:00
|
|
|
#include "llvm/BinaryFormat/ELFRelocs/AArch64.def"
|
2014-11-11 07:02:03 +08:00
|
|
|
break;
|
2014-12-02 17:49:09 +08:00
|
|
|
case ELF::EM_ARM:
|
2017-06-07 11:48:56 +08:00
|
|
|
#include "llvm/BinaryFormat/ELFRelocs/ARM.def"
|
2014-12-02 17:49:09 +08:00
|
|
|
break;
|
2017-09-13 09:49:49 +08:00
|
|
|
case ELF::EM_ARC:
|
|
|
|
#include "llvm/BinaryFormat/ELFRelocs/ARC.def"
|
|
|
|
break;
|
2016-11-02 00:59:37 +08:00
|
|
|
case ELF::EM_RISCV:
|
2017-06-07 11:48:56 +08:00
|
|
|
#include "llvm/BinaryFormat/ELFRelocs/RISCV.def"
|
2016-11-02 00:59:37 +08:00
|
|
|
break;
|
2016-03-28 21:09:54 +08:00
|
|
|
case ELF::EM_LANAI:
|
2017-06-07 11:48:56 +08:00
|
|
|
#include "llvm/BinaryFormat/ELFRelocs/Lanai.def"
|
2016-03-28 21:09:54 +08:00
|
|
|
break;
|
2016-06-18 06:38:08 +08:00
|
|
|
case ELF::EM_AMDGPU:
|
2017-06-07 11:48:56 +08:00
|
|
|
#include "llvm/BinaryFormat/ELFRelocs/AMDGPU.def"
|
2016-06-18 06:38:08 +08:00
|
|
|
break;
|
2016-07-16 06:27:55 +08:00
|
|
|
case ELF::EM_BPF:
|
2017-06-07 11:48:56 +08:00
|
|
|
#include "llvm/BinaryFormat/ELFRelocs/BPF.def"
|
2016-07-16 06:27:55 +08:00
|
|
|
break;
|
2020-05-28 16:07:21 +08:00
|
|
|
case ELF::EM_VE:
|
|
|
|
#include "llvm/BinaryFormat/ELFRelocs/VE.def"
|
|
|
|
break;
|
2020-09-02 17:02:17 +08:00
|
|
|
case ELF::EM_CSKY:
|
|
|
|
#include "llvm/BinaryFormat/ELFRelocs/CSKY.def"
|
|
|
|
break;
|
2019-09-17 20:00:55 +08:00
|
|
|
case ELF::EM_PPC64:
|
|
|
|
#include "llvm/BinaryFormat/ELFRelocs/PowerPC64.def"
|
|
|
|
break;
|
2021-03-08 08:32:03 +08:00
|
|
|
case ELF::EM_68K:
|
|
|
|
#include "llvm/BinaryFormat/ELFRelocs/M68k.def"
|
|
|
|
break;
|
2014-04-11 12:13:39 +08:00
|
|
|
default:
|
2019-09-20 17:15:36 +08:00
|
|
|
// Nothing to do.
|
|
|
|
break;
|
2014-04-11 12:13:39 +08:00
|
|
|
}
|
2014-11-22 04:16:09 +08:00
|
|
|
#undef ELF_RELOC
|
2017-06-30 18:31:03 +08:00
|
|
|
IO.enumFallback<Hex32>(Value);
|
2014-04-11 12:13:39 +08:00
|
|
|
}
|
|
|
|
|
2019-02-09 19:34:28 +08:00
|
|
|
void ScalarEnumerationTraits<ELFYAML::ELF_DYNTAG>::enumeration(
|
|
|
|
IO &IO, ELFYAML::ELF_DYNTAG &Value) {
|
2019-02-26 22:14:49 +08:00
|
|
|
const auto *Object = static_cast<ELFYAML::Object *>(IO.getContext());
|
|
|
|
assert(Object && "The IO context is not initialized");
|
2019-02-09 19:34:28 +08:00
|
|
|
|
2019-02-26 22:14:49 +08:00
|
|
|
// Disable architecture specific tags by default. We might enable them below.
|
2019-06-04 19:44:33 +08:00
|
|
|
#define AARCH64_DYNAMIC_TAG(name, value)
|
2019-02-09 19:34:28 +08:00
|
|
|
#define MIPS_DYNAMIC_TAG(name, value)
|
|
|
|
#define HEXAGON_DYNAMIC_TAG(name, value)
|
2019-06-05 09:36:48 +08:00
|
|
|
#define PPC_DYNAMIC_TAG(name, value)
|
2019-02-09 19:34:28 +08:00
|
|
|
#define PPC64_DYNAMIC_TAG(name, value)
|
2019-02-26 22:14:49 +08:00
|
|
|
// Ignore marker tags such as DT_HIOS (maps to DT_VERNEEDNUM), etc.
|
2019-02-09 19:34:28 +08:00
|
|
|
#define DYNAMIC_TAG_MARKER(name, value)
|
|
|
|
|
|
|
|
#define STRINGIFY(X) (#X)
|
|
|
|
#define DYNAMIC_TAG(X, Y) IO.enumCase(Value, STRINGIFY(DT_##X), ELF::DT_##X);
|
2020-08-18 20:24:26 +08:00
|
|
|
switch (Object->getMachine()) {
|
2019-06-04 19:44:33 +08:00
|
|
|
case ELF::EM_AARCH64:
|
|
|
|
#undef AARCH64_DYNAMIC_TAG
|
|
|
|
#define AARCH64_DYNAMIC_TAG(name, value) DYNAMIC_TAG(name, value)
|
|
|
|
#include "llvm/BinaryFormat/DynamicTags.def"
|
|
|
|
#undef AARCH64_DYNAMIC_TAG
|
|
|
|
#define AARCH64_DYNAMIC_TAG(name, value)
|
|
|
|
break;
|
2019-02-26 22:14:49 +08:00
|
|
|
case ELF::EM_MIPS:
|
|
|
|
#undef MIPS_DYNAMIC_TAG
|
|
|
|
#define MIPS_DYNAMIC_TAG(name, value) DYNAMIC_TAG(name, value)
|
|
|
|
#include "llvm/BinaryFormat/DynamicTags.def"
|
|
|
|
#undef MIPS_DYNAMIC_TAG
|
|
|
|
#define MIPS_DYNAMIC_TAG(name, value)
|
|
|
|
break;
|
|
|
|
case ELF::EM_HEXAGON:
|
|
|
|
#undef HEXAGON_DYNAMIC_TAG
|
|
|
|
#define HEXAGON_DYNAMIC_TAG(name, value) DYNAMIC_TAG(name, value)
|
2019-02-09 19:34:28 +08:00
|
|
|
#include "llvm/BinaryFormat/DynamicTags.def"
|
2019-02-26 22:14:49 +08:00
|
|
|
#undef HEXAGON_DYNAMIC_TAG
|
|
|
|
#define HEXAGON_DYNAMIC_TAG(name, value)
|
|
|
|
break;
|
2019-06-05 09:36:48 +08:00
|
|
|
case ELF::EM_PPC:
|
|
|
|
#undef PPC_DYNAMIC_TAG
|
|
|
|
#define PPC_DYNAMIC_TAG(name, value) DYNAMIC_TAG(name, value)
|
|
|
|
#include "llvm/BinaryFormat/DynamicTags.def"
|
|
|
|
#undef PPC_DYNAMIC_TAG
|
|
|
|
#define PPC_DYNAMIC_TAG(name, value)
|
|
|
|
break;
|
2019-02-26 22:14:49 +08:00
|
|
|
case ELF::EM_PPC64:
|
|
|
|
#undef PPC64_DYNAMIC_TAG
|
|
|
|
#define PPC64_DYNAMIC_TAG(name, value) DYNAMIC_TAG(name, value)
|
|
|
|
#include "llvm/BinaryFormat/DynamicTags.def"
|
|
|
|
#undef PPC64_DYNAMIC_TAG
|
|
|
|
#define PPC64_DYNAMIC_TAG(name, value)
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
#include "llvm/BinaryFormat/DynamicTags.def"
|
|
|
|
break;
|
|
|
|
}
|
2019-06-04 19:44:33 +08:00
|
|
|
#undef AARCH64_DYNAMIC_TAG
|
2019-02-09 19:34:28 +08:00
|
|
|
#undef MIPS_DYNAMIC_TAG
|
|
|
|
#undef HEXAGON_DYNAMIC_TAG
|
2019-06-05 09:36:48 +08:00
|
|
|
#undef PPC_DYNAMIC_TAG
|
2019-02-09 19:34:28 +08:00
|
|
|
#undef PPC64_DYNAMIC_TAG
|
|
|
|
#undef DYNAMIC_TAG_MARKER
|
|
|
|
#undef STRINGIFY
|
|
|
|
#undef DYNAMIC_TAG
|
|
|
|
|
|
|
|
IO.enumFallback<Hex64>(Value);
|
|
|
|
}
|
|
|
|
|
2015-05-07 23:40:48 +08:00
|
|
|
void ScalarEnumerationTraits<ELFYAML::MIPS_AFL_REG>::enumeration(
|
|
|
|
IO &IO, ELFYAML::MIPS_AFL_REG &Value) {
|
2017-02-01 05:11:12 +08:00
|
|
|
#define ECase(X) IO.enumCase(Value, #X, Mips::AFL_##X)
|
|
|
|
ECase(REG_NONE);
|
|
|
|
ECase(REG_32);
|
|
|
|
ECase(REG_64);
|
|
|
|
ECase(REG_128);
|
2015-05-07 23:40:48 +08:00
|
|
|
#undef ECase
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScalarEnumerationTraits<ELFYAML::MIPS_ABI_FP>::enumeration(
|
|
|
|
IO &IO, ELFYAML::MIPS_ABI_FP &Value) {
|
2017-02-01 05:11:12 +08:00
|
|
|
#define ECase(X) IO.enumCase(Value, #X, Mips::Val_GNU_MIPS_ABI_##X)
|
|
|
|
ECase(FP_ANY);
|
|
|
|
ECase(FP_DOUBLE);
|
|
|
|
ECase(FP_SINGLE);
|
|
|
|
ECase(FP_SOFT);
|
|
|
|
ECase(FP_OLD_64);
|
|
|
|
ECase(FP_XX);
|
|
|
|
ECase(FP_64);
|
|
|
|
ECase(FP_64A);
|
2015-05-07 23:40:48 +08:00
|
|
|
#undef ECase
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScalarEnumerationTraits<ELFYAML::MIPS_AFL_EXT>::enumeration(
|
|
|
|
IO &IO, ELFYAML::MIPS_AFL_EXT &Value) {
|
2017-02-01 05:11:12 +08:00
|
|
|
#define ECase(X) IO.enumCase(Value, #X, Mips::AFL_##X)
|
|
|
|
ECase(EXT_NONE);
|
|
|
|
ECase(EXT_XLR);
|
|
|
|
ECase(EXT_OCTEON2);
|
|
|
|
ECase(EXT_OCTEONP);
|
|
|
|
ECase(EXT_LOONGSON_3A);
|
|
|
|
ECase(EXT_OCTEON);
|
|
|
|
ECase(EXT_5900);
|
|
|
|
ECase(EXT_4650);
|
|
|
|
ECase(EXT_4010);
|
|
|
|
ECase(EXT_4100);
|
|
|
|
ECase(EXT_3900);
|
|
|
|
ECase(EXT_10000);
|
|
|
|
ECase(EXT_SB1);
|
|
|
|
ECase(EXT_4111);
|
|
|
|
ECase(EXT_4120);
|
|
|
|
ECase(EXT_5400);
|
|
|
|
ECase(EXT_5500);
|
|
|
|
ECase(EXT_LOONGSON_2E);
|
|
|
|
ECase(EXT_LOONGSON_2F);
|
|
|
|
ECase(EXT_OCTEON3);
|
2015-05-07 23:40:48 +08:00
|
|
|
#undef ECase
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScalarEnumerationTraits<ELFYAML::MIPS_ISA>::enumeration(
|
|
|
|
IO &IO, ELFYAML::MIPS_ISA &Value) {
|
|
|
|
IO.enumCase(Value, "MIPS1", 1);
|
|
|
|
IO.enumCase(Value, "MIPS2", 2);
|
|
|
|
IO.enumCase(Value, "MIPS3", 3);
|
|
|
|
IO.enumCase(Value, "MIPS4", 4);
|
|
|
|
IO.enumCase(Value, "MIPS5", 5);
|
|
|
|
IO.enumCase(Value, "MIPS32", 32);
|
|
|
|
IO.enumCase(Value, "MIPS64", 64);
|
2020-09-25 19:57:00 +08:00
|
|
|
IO.enumFallback<Hex32>(Value);
|
2015-05-07 23:40:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScalarBitSetTraits<ELFYAML::MIPS_AFL_ASE>::bitset(
|
|
|
|
IO &IO, ELFYAML::MIPS_AFL_ASE &Value) {
|
2017-02-01 05:11:12 +08:00
|
|
|
#define BCase(X) IO.bitSetCase(Value, #X, Mips::AFL_ASE_##X)
|
|
|
|
BCase(DSP);
|
|
|
|
BCase(DSPR2);
|
|
|
|
BCase(EVA);
|
|
|
|
BCase(MCU);
|
|
|
|
BCase(MDMX);
|
|
|
|
BCase(MIPS3D);
|
|
|
|
BCase(MT);
|
|
|
|
BCase(SMARTMIPS);
|
|
|
|
BCase(VIRT);
|
|
|
|
BCase(MSA);
|
|
|
|
BCase(MIPS16);
|
|
|
|
BCase(MICROMIPS);
|
|
|
|
BCase(XPA);
|
2020-07-16 23:07:33 +08:00
|
|
|
BCase(CRC);
|
|
|
|
BCase(GINV);
|
2015-05-07 23:40:48 +08:00
|
|
|
#undef BCase
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScalarBitSetTraits<ELFYAML::MIPS_AFL_FLAGS1>::bitset(
|
|
|
|
IO &IO, ELFYAML::MIPS_AFL_FLAGS1 &Value) {
|
2017-02-01 05:11:12 +08:00
|
|
|
#define BCase(X) IO.bitSetCase(Value, #X, Mips::AFL_FLAGS1_##X)
|
|
|
|
BCase(ODDSPREG);
|
2015-05-07 23:40:48 +08:00
|
|
|
#undef BCase
|
|
|
|
}
|
|
|
|
|
2020-05-14 19:15:40 +08:00
|
|
|
void MappingTraits<ELFYAML::SectionHeader>::mapping(
|
|
|
|
IO &IO, ELFYAML::SectionHeader &SHdr) {
|
|
|
|
IO.mapRequired("Name", SHdr.Name);
|
|
|
|
}
|
|
|
|
|
2013-06-12 08:01:22 +08:00
|
|
|
void MappingTraits<ELFYAML::FileHeader>::mapping(IO &IO,
|
|
|
|
ELFYAML::FileHeader &FileHdr) {
|
2013-06-11 08:13:52 +08:00
|
|
|
IO.mapRequired("Class", FileHdr.Class);
|
|
|
|
IO.mapRequired("Data", FileHdr.Data);
|
2013-06-19 08:55:28 +08:00
|
|
|
IO.mapOptional("OSABI", FileHdr.OSABI, ELFYAML::ELF_ELFOSABI(0));
|
2018-12-20 18:43:49 +08:00
|
|
|
IO.mapOptional("ABIVersion", FileHdr.ABIVersion, Hex8(0));
|
2013-06-11 08:13:52 +08:00
|
|
|
IO.mapRequired("Type", FileHdr.Type);
|
2020-08-18 20:24:26 +08:00
|
|
|
IO.mapOptional("Machine", FileHdr.Machine);
|
2014-03-31 17:44:05 +08:00
|
|
|
IO.mapOptional("Flags", FileHdr.Flags, ELFYAML::ELF_EF(0));
|
2013-06-11 08:13:52 +08:00
|
|
|
IO.mapOptional("Entry", FileHdr.Entry, Hex64(0));
|
2021-06-10 22:33:41 +08:00
|
|
|
IO.mapOptional("SectionHeaderStringTable", FileHdr.SectionHeaderStringTable);
|
2019-06-27 19:08:42 +08:00
|
|
|
|
2020-07-09 15:55:44 +08:00
|
|
|
// obj2yaml does not dump these fields.
|
|
|
|
assert(!IO.outputting() ||
|
|
|
|
(!FileHdr.EPhOff && !FileHdr.EPhEntSize && !FileHdr.EPhNum));
|
|
|
|
IO.mapOptional("EPhOff", FileHdr.EPhOff);
|
|
|
|
IO.mapOptional("EPhEntSize", FileHdr.EPhEntSize);
|
|
|
|
IO.mapOptional("EPhNum", FileHdr.EPhNum);
|
2020-07-14 20:48:03 +08:00
|
|
|
IO.mapOptional("EShEntSize", FileHdr.EShEntSize);
|
|
|
|
IO.mapOptional("EShOff", FileHdr.EShOff);
|
|
|
|
IO.mapOptional("EShNum", FileHdr.EShNum);
|
|
|
|
IO.mapOptional("EShStrNdx", FileHdr.EShStrNdx);
|
2013-06-11 07:44:15 +08:00
|
|
|
}
|
|
|
|
|
2017-07-20 04:38:46 +08:00
|
|
|
void MappingTraits<ELFYAML::ProgramHeader>::mapping(
|
|
|
|
IO &IO, ELFYAML::ProgramHeader &Phdr) {
|
|
|
|
IO.mapRequired("Type", Phdr.Type);
|
|
|
|
IO.mapOptional("Flags", Phdr.Flags, ELFYAML::ELF_PF(0));
|
2020-10-30 20:54:03 +08:00
|
|
|
IO.mapOptional("FirstSec", Phdr.FirstSec);
|
|
|
|
IO.mapOptional("LastSec", Phdr.LastSec);
|
2017-07-20 04:38:46 +08:00
|
|
|
IO.mapOptional("VAddr", Phdr.VAddr, Hex64(0));
|
2020-03-13 21:31:16 +08:00
|
|
|
IO.mapOptional("PAddr", Phdr.PAddr, Phdr.VAddr);
|
2017-11-02 07:14:48 +08:00
|
|
|
IO.mapOptional("Align", Phdr.Align);
|
2019-03-15 18:35:27 +08:00
|
|
|
IO.mapOptional("FileSize", Phdr.FileSize);
|
|
|
|
IO.mapOptional("MemSize", Phdr.MemSize);
|
|
|
|
IO.mapOptional("Offset", Phdr.Offset);
|
2017-07-20 04:38:46 +08:00
|
|
|
}
|
|
|
|
|
2020-10-30 20:54:03 +08:00
|
|
|
std::string MappingTraits<ELFYAML::ProgramHeader>::validate(
|
|
|
|
IO &IO, ELFYAML::ProgramHeader &FileHdr) {
|
|
|
|
if (!FileHdr.FirstSec && FileHdr.LastSec)
|
|
|
|
return "the \"LastSec\" key can't be used without the \"FirstSec\" key";
|
|
|
|
if (FileHdr.FirstSec && !FileHdr.LastSec)
|
|
|
|
return "the \"FirstSec\" key can't be used without the \"LastSec\" key";
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2019-08-30 21:39:22 +08:00
|
|
|
LLVM_YAML_STRONG_TYPEDEF(StringRef, StOtherPiece)
|
|
|
|
|
|
|
|
template <> struct ScalarTraits<StOtherPiece> {
|
|
|
|
static void output(const StOtherPiece &Val, void *, raw_ostream &Out) {
|
|
|
|
Out << Val;
|
|
|
|
}
|
|
|
|
static StringRef input(StringRef Scalar, void *, StOtherPiece &Val) {
|
|
|
|
Val = Scalar;
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
static QuotingType mustQuote(StringRef) { return QuotingType::None; }
|
|
|
|
};
|
|
|
|
template <> struct SequenceElementTraits<StOtherPiece> {
|
|
|
|
static const bool flow = true;
|
|
|
|
};
|
|
|
|
|
2019-11-22 22:18:34 +08:00
|
|
|
template <> struct ScalarTraits<ELFYAML::YAMLFlowString> {
|
|
|
|
static void output(const ELFYAML::YAMLFlowString &Val, void *,
|
|
|
|
raw_ostream &Out) {
|
|
|
|
Out << Val;
|
|
|
|
}
|
|
|
|
static StringRef input(StringRef Scalar, void *,
|
|
|
|
ELFYAML::YAMLFlowString &Val) {
|
|
|
|
Val = Scalar;
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
static QuotingType mustQuote(StringRef S) {
|
|
|
|
return ScalarTraits<StringRef>::mustQuote(S);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
template <> struct SequenceElementTraits<ELFYAML::YAMLFlowString> {
|
|
|
|
static const bool flow = true;
|
|
|
|
};
|
|
|
|
|
2014-11-07 06:46:24 +08:00
|
|
|
namespace {
|
2017-07-01 09:35:55 +08:00
|
|
|
|
2014-11-07 06:46:24 +08:00
|
|
|
struct NormalizedOther {
|
2019-08-30 21:39:22 +08:00
|
|
|
NormalizedOther(IO &IO) : YamlIO(IO) {}
|
|
|
|
NormalizedOther(IO &IO, Optional<uint8_t> Original) : YamlIO(IO) {
|
|
|
|
assert(Original && "This constructor is only used for outputting YAML and "
|
|
|
|
"assumes a non-empty Original");
|
|
|
|
std::vector<StOtherPiece> Ret;
|
|
|
|
const auto *Object = static_cast<ELFYAML::Object *>(YamlIO.getContext());
|
|
|
|
for (std::pair<StringRef, uint8_t> &P :
|
2020-08-18 20:24:26 +08:00
|
|
|
getFlags(Object->getMachine()).takeVector()) {
|
2019-08-30 21:39:22 +08:00
|
|
|
uint8_t FlagValue = P.second;
|
|
|
|
if ((*Original & FlagValue) != FlagValue)
|
|
|
|
continue;
|
|
|
|
*Original &= ~FlagValue;
|
|
|
|
Ret.push_back({P.first});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*Original != 0) {
|
|
|
|
UnknownFlagsHolder = std::to_string(*Original);
|
|
|
|
Ret.push_back({UnknownFlagsHolder});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!Ret.empty())
|
|
|
|
Other = std::move(Ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t toValue(StringRef Name) {
|
|
|
|
const auto *Object = static_cast<ELFYAML::Object *>(YamlIO.getContext());
|
2020-08-18 20:24:26 +08:00
|
|
|
MapVector<StringRef, uint8_t> Flags = getFlags(Object->getMachine());
|
2019-08-30 21:39:22 +08:00
|
|
|
|
|
|
|
auto It = Flags.find(Name);
|
|
|
|
if (It != Flags.end())
|
|
|
|
return It->second;
|
|
|
|
|
|
|
|
uint8_t Val;
|
|
|
|
if (to_integer(Name, Val))
|
|
|
|
return Val;
|
|
|
|
|
2019-09-05 16:52:26 +08:00
|
|
|
YamlIO.setError("an unknown value is used for symbol's 'Other' field: " +
|
|
|
|
Name);
|
|
|
|
return 0;
|
2019-08-28 22:04:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
Optional<uint8_t> denormalize(IO &) {
|
2019-08-30 21:39:22 +08:00
|
|
|
if (!Other)
|
2019-08-28 22:04:09 +08:00
|
|
|
return None;
|
|
|
|
uint8_t Ret = 0;
|
2019-08-30 21:39:22 +08:00
|
|
|
for (StOtherPiece &Val : *Other)
|
|
|
|
Ret |= toValue(Val);
|
2019-08-28 22:04:09 +08:00
|
|
|
return Ret;
|
|
|
|
}
|
2014-11-07 06:46:24 +08:00
|
|
|
|
2019-08-30 21:39:22 +08:00
|
|
|
// st_other field is used to encode symbol visibility and platform-dependent
|
|
|
|
// flags and values. This method returns a name to value map that is used for
|
|
|
|
// parsing and encoding this field.
|
|
|
|
MapVector<StringRef, uint8_t> getFlags(unsigned EMachine) {
|
|
|
|
MapVector<StringRef, uint8_t> Map;
|
|
|
|
// STV_* values are just enumeration values. We add them in a reversed order
|
|
|
|
// because when we convert the st_other to named constants when printing
|
|
|
|
// YAML we want to use a maximum number of bits on each step:
|
|
|
|
// when we have st_other == 3, we want to print it as STV_PROTECTED (3), but
|
|
|
|
// not as STV_HIDDEN (2) + STV_INTERNAL (1).
|
|
|
|
Map["STV_PROTECTED"] = ELF::STV_PROTECTED;
|
|
|
|
Map["STV_HIDDEN"] = ELF::STV_HIDDEN;
|
|
|
|
Map["STV_INTERNAL"] = ELF::STV_INTERNAL;
|
|
|
|
// STV_DEFAULT is used to represent the default visibility and has a value
|
|
|
|
// 0. We want to be able to read it from YAML documents, but there is no
|
|
|
|
// reason to print it.
|
|
|
|
if (!YamlIO.outputting())
|
|
|
|
Map["STV_DEFAULT"] = ELF::STV_DEFAULT;
|
|
|
|
|
|
|
|
// MIPS is not consistent. All of the STO_MIPS_* values are bit flags,
|
|
|
|
// except STO_MIPS_MIPS16 which overlaps them. It should be checked and
|
|
|
|
// consumed first when we print the output, because we do not want to print
|
|
|
|
// any other flags that have the same bits instead.
|
|
|
|
if (EMachine == ELF::EM_MIPS) {
|
|
|
|
Map["STO_MIPS_MIPS16"] = ELF::STO_MIPS_MIPS16;
|
|
|
|
Map["STO_MIPS_MICROMIPS"] = ELF::STO_MIPS_MICROMIPS;
|
|
|
|
Map["STO_MIPS_PIC"] = ELF::STO_MIPS_PIC;
|
|
|
|
Map["STO_MIPS_PLT"] = ELF::STO_MIPS_PLT;
|
|
|
|
Map["STO_MIPS_OPTIONAL"] = ELF::STO_MIPS_OPTIONAL;
|
|
|
|
}
|
2020-12-15 01:24:53 +08:00
|
|
|
|
|
|
|
if (EMachine == ELF::EM_AARCH64)
|
|
|
|
Map["STO_AARCH64_VARIANT_PCS"] = ELF::STO_AARCH64_VARIANT_PCS;
|
2019-08-30 21:39:22 +08:00
|
|
|
return Map;
|
|
|
|
}
|
|
|
|
|
2019-09-05 16:52:26 +08:00
|
|
|
IO &YamlIO;
|
2019-08-30 21:39:22 +08:00
|
|
|
Optional<std::vector<StOtherPiece>> Other;
|
|
|
|
std::string UnknownFlagsHolder;
|
2014-11-07 06:46:24 +08:00
|
|
|
};
|
2017-07-01 09:35:55 +08:00
|
|
|
|
|
|
|
} // end anonymous namespace
|
2014-11-07 06:46:24 +08:00
|
|
|
|
2020-03-03 15:54:55 +08:00
|
|
|
void ScalarTraits<ELFYAML::YAMLIntUInt>::output(const ELFYAML::YAMLIntUInt &Val,
|
|
|
|
void *Ctx, raw_ostream &Out) {
|
|
|
|
Out << Val;
|
|
|
|
}
|
|
|
|
|
|
|
|
StringRef ScalarTraits<ELFYAML::YAMLIntUInt>::input(StringRef Scalar, void *Ctx,
|
|
|
|
ELFYAML::YAMLIntUInt &Val) {
|
|
|
|
const bool Is64 = static_cast<ELFYAML::Object *>(Ctx)->Header.Class ==
|
|
|
|
ELFYAML::ELF_ELFCLASS(ELF::ELFCLASS64);
|
|
|
|
StringRef ErrMsg = "invalid number";
|
|
|
|
// We do not accept negative hex numbers because their meaning is ambiguous.
|
|
|
|
// For example, would -0xfffffffff mean 1 or INT32_MIN?
|
|
|
|
if (Scalar.empty() || Scalar.startswith("-0x"))
|
|
|
|
return ErrMsg;
|
|
|
|
|
|
|
|
if (Scalar.startswith("-")) {
|
|
|
|
const int64_t MinVal = Is64 ? INT64_MIN : INT32_MIN;
|
|
|
|
long long Int;
|
|
|
|
if (getAsSignedInteger(Scalar, /*Radix=*/0, Int) || (Int < MinVal))
|
|
|
|
return ErrMsg;
|
|
|
|
Val = Int;
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
const uint64_t MaxVal = Is64 ? UINT64_MAX : UINT32_MAX;
|
|
|
|
unsigned long long UInt;
|
|
|
|
if (getAsUnsignedInteger(Scalar, /*Radix=*/0, UInt) || (UInt > MaxVal))
|
|
|
|
return ErrMsg;
|
|
|
|
Val = UInt;
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2013-06-19 07:14:03 +08:00
|
|
|
void MappingTraits<ELFYAML::Symbol>::mapping(IO &IO, ELFYAML::Symbol &Symbol) {
|
|
|
|
IO.mapOptional("Name", Symbol.Name, StringRef());
|
2020-02-05 18:54:57 +08:00
|
|
|
IO.mapOptional("StName", Symbol.StName);
|
2013-06-19 08:11:59 +08:00
|
|
|
IO.mapOptional("Type", Symbol.Type, ELFYAML::ELF_STT(0));
|
2020-12-03 19:40:06 +08:00
|
|
|
IO.mapOptional("Section", Symbol.Section);
|
2017-09-08 04:44:16 +08:00
|
|
|
IO.mapOptional("Index", Symbol.Index);
|
2019-04-03 22:53:42 +08:00
|
|
|
IO.mapOptional("Binding", Symbol.Binding, ELFYAML::ELF_STB(0));
|
2020-12-09 21:46:42 +08:00
|
|
|
IO.mapOptional("Value", Symbol.Value);
|
|
|
|
IO.mapOptional("Size", Symbol.Size);
|
2019-08-23 17:31:07 +08:00
|
|
|
|
2019-08-30 21:39:22 +08:00
|
|
|
// Symbol's Other field is a bit special. It is usually a field that
|
|
|
|
// represents st_other and holds the symbol visibility. However, on some
|
|
|
|
// platforms, it can contain bit fields and regular values, or even sometimes a
|
|
|
|
// crazy mix of them (see comments for NormalizedOther). Because of this, we
|
|
|
|
// need special handling.
|
2019-08-28 22:04:09 +08:00
|
|
|
MappingNormalization<NormalizedOther, Optional<uint8_t>> Keys(IO,
|
|
|
|
Symbol.Other);
|
|
|
|
IO.mapOptional("Other", Keys->Other);
|
2013-06-19 07:14:03 +08:00
|
|
|
}
|
|
|
|
|
2020-10-20 21:01:01 +08:00
|
|
|
std::string MappingTraits<ELFYAML::Symbol>::validate(IO &IO,
|
|
|
|
ELFYAML::Symbol &Symbol) {
|
2020-12-03 19:40:06 +08:00
|
|
|
if (Symbol.Index && Symbol.Section)
|
2017-09-08 04:44:16 +08:00
|
|
|
return "Index and Section cannot both be specified for Symbol";
|
2020-10-20 21:01:01 +08:00
|
|
|
return "";
|
2017-09-08 04:44:16 +08:00
|
|
|
}
|
|
|
|
|
2014-04-11 12:13:39 +08:00
|
|
|
static void commonSectionMapping(IO &IO, ELFYAML::Section &Section) {
|
2013-06-14 06:19:48 +08:00
|
|
|
IO.mapOptional("Name", Section.Name, StringRef());
|
|
|
|
IO.mapRequired("Type", Section.Type);
|
2019-06-14 19:01:14 +08:00
|
|
|
IO.mapOptional("Flags", Section.Flags);
|
2020-02-18 21:49:12 +08:00
|
|
|
IO.mapOptional("Address", Section.Address);
|
2020-10-29 21:04:45 +08:00
|
|
|
IO.mapOptional("Link", Section.Link);
|
2013-06-14 08:38:02 +08:00
|
|
|
IO.mapOptional("AddressAlign", Section.AddressAlign, Hex64(0));
|
2018-08-07 16:11:38 +08:00
|
|
|
IO.mapOptional("EntSize", Section.EntSize);
|
2020-04-27 16:46:49 +08:00
|
|
|
IO.mapOptional("Offset", Section.Offset);
|
2019-07-02 18:20:12 +08:00
|
|
|
|
2020-10-06 20:48:15 +08:00
|
|
|
IO.mapOptional("Content", Section.Content);
|
|
|
|
IO.mapOptional("Size", Section.Size);
|
|
|
|
|
2019-07-11 20:59:29 +08:00
|
|
|
// obj2yaml does not dump these fields. They are expected to be empty when we
|
2019-09-02 17:47:17 +08:00
|
|
|
// are producing YAML, because yaml2obj sets appropriate values for them
|
|
|
|
// automatically when they are not explicitly defined.
|
2019-07-11 20:59:29 +08:00
|
|
|
assert(!IO.outputting() ||
|
2020-10-23 17:50:48 +08:00
|
|
|
(!Section.ShOffset && !Section.ShSize && !Section.ShName &&
|
|
|
|
!Section.ShFlags && !Section.ShType && !Section.ShAddrAlign));
|
|
|
|
IO.mapOptional("ShAddrAlign", Section.ShAddrAlign);
|
2019-09-02 17:47:17 +08:00
|
|
|
IO.mapOptional("ShName", Section.ShName);
|
2019-07-02 18:20:12 +08:00
|
|
|
IO.mapOptional("ShOffset", Section.ShOffset);
|
2019-07-11 20:59:29 +08:00
|
|
|
IO.mapOptional("ShSize", Section.ShSize);
|
2019-12-12 20:47:29 +08:00
|
|
|
IO.mapOptional("ShFlags", Section.ShFlags);
|
2020-07-28 17:53:06 +08:00
|
|
|
IO.mapOptional("ShType", Section.ShType);
|
2013-06-14 06:19:48 +08:00
|
|
|
}
|
|
|
|
|
2019-02-09 19:34:28 +08:00
|
|
|
static void sectionMapping(IO &IO, ELFYAML::DynamicSection &Section) {
|
|
|
|
commonSectionMapping(IO, Section);
|
|
|
|
IO.mapOptional("Entries", Section.Entries);
|
|
|
|
}
|
|
|
|
|
2014-04-11 12:13:39 +08:00
|
|
|
static void sectionMapping(IO &IO, ELFYAML::RawContentSection &Section) {
|
|
|
|
commonSectionMapping(IO, Section);
|
[yaml2obj] - Support reading a content as an array of bytes using the new 'ContentArray' key.
It implements the way to describe a section content using a multi line description. E.g:
```
- Name: .foo
Type: SHT_PROGBITS
ContentArray: [ 0x11, 0x22, 0x33, 0x44, ## .long 11223344
0x55, 0x66, ## .short 5566.
0x77, ## .byte 0x77
0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF, 0x00 ] ## .quad 0x8899aabbccddeeff
```
It was briefly discussed in D75123 thread previously.
Differential revision: https://reviews.llvm.org/D82366
2020-06-23 16:16:19 +08:00
|
|
|
|
|
|
|
// We also support reading a content as array of bytes using the ContentArray
|
|
|
|
// key. obj2yaml never prints this field.
|
|
|
|
assert(!IO.outputting() || !Section.ContentBuf.hasValue());
|
|
|
|
IO.mapOptional("ContentArray", Section.ContentBuf);
|
|
|
|
if (Section.ContentBuf) {
|
|
|
|
if (Section.Content)
|
|
|
|
IO.setError("Content and ContentArray can't be used together");
|
|
|
|
Section.Content = yaml::BinaryRef(*Section.ContentBuf);
|
|
|
|
}
|
|
|
|
|
2019-06-19 16:57:38 +08:00
|
|
|
IO.mapOptional("Info", Section.Info);
|
2014-04-11 12:13:39 +08:00
|
|
|
}
|
|
|
|
|
2020-11-07 04:44:24 +08:00
|
|
|
static void sectionMapping(IO &IO, ELFYAML::BBAddrMapSection &Section) {
|
|
|
|
commonSectionMapping(IO, Section);
|
|
|
|
IO.mapOptional("Content", Section.Content);
|
|
|
|
IO.mapOptional("Entries", Section.Entries);
|
|
|
|
}
|
|
|
|
|
2019-09-24 22:22:37 +08:00
|
|
|
static void sectionMapping(IO &IO, ELFYAML::StackSizesSection &Section) {
|
|
|
|
commonSectionMapping(IO, Section);
|
|
|
|
IO.mapOptional("Entries", Section.Entries);
|
|
|
|
}
|
|
|
|
|
2019-10-01 17:45:59 +08:00
|
|
|
static void sectionMapping(IO &IO, ELFYAML::HashSection &Section) {
|
|
|
|
commonSectionMapping(IO, Section);
|
|
|
|
IO.mapOptional("Bucket", Section.Bucket);
|
|
|
|
IO.mapOptional("Chain", Section.Chain);
|
2020-03-26 18:13:39 +08:00
|
|
|
|
|
|
|
// obj2yaml does not dump these fields. They can be used to override nchain
|
|
|
|
// and nbucket values for creating broken sections.
|
|
|
|
assert(!IO.outputting() ||
|
|
|
|
(!Section.NBucket.hasValue() && !Section.NChain.hasValue()));
|
|
|
|
IO.mapOptional("NChain", Section.NChain);
|
|
|
|
IO.mapOptional("NBucket", Section.NBucket);
|
2019-10-01 17:45:59 +08:00
|
|
|
}
|
|
|
|
|
[yaml2obj, obj2yaml] - Add support for SHT_NOTE sections.
SHT_NOTE is the section that consists of
namesz, descsz, type, name + padding, desc + padding data.
This patch teaches yaml2obj, obj2yaml to dump and parse them.
This patch implements the section how it is described here:
https://docs.oracle.com/cd/E23824_01/html/819-0690/chapter6-18048.html
Which says: "For 64–bit objects and 32–bit objects, each entry is an array of 4-byte words in
the format of the target processor"
The official specification is different
http://www.sco.com/developers/gabi/latest/ch5.pheader.html#note_section
And says: "n 64-bit objects (files with e_ident[EI_CLASS] equal to ELFCLASS64), each entry is an array
of 8-byte words in the format of the target processor. In 32-bit objects (files with e_ident[EI_CLASS]
equal to ELFCLASS32), each entry is an array of 4-byte words in the format of the target processor"
Since LLVM uses the first, 32-bit way, this patch follows it.
Differential revision: https://reviews.llvm.org/D68983
2019-10-25 18:03:19 +08:00
|
|
|
static void sectionMapping(IO &IO, ELFYAML::NoteSection &Section) {
|
|
|
|
commonSectionMapping(IO, Section);
|
|
|
|
IO.mapOptional("Notes", Section.Notes);
|
|
|
|
}
|
|
|
|
|
2019-10-24 20:38:53 +08:00
|
|
|
|
|
|
|
static void sectionMapping(IO &IO, ELFYAML::GnuHashSection &Section) {
|
|
|
|
commonSectionMapping(IO, Section);
|
|
|
|
IO.mapOptional("Header", Section.Header);
|
|
|
|
IO.mapOptional("BloomFilter", Section.BloomFilter);
|
|
|
|
IO.mapOptional("HashBuckets", Section.HashBuckets);
|
|
|
|
IO.mapOptional("HashValues", Section.HashValues);
|
|
|
|
}
|
2015-07-04 07:00:54 +08:00
|
|
|
static void sectionMapping(IO &IO, ELFYAML::NoBitsSection &Section) {
|
|
|
|
commonSectionMapping(IO, Section);
|
|
|
|
}
|
|
|
|
|
2019-02-21 20:21:43 +08:00
|
|
|
static void sectionMapping(IO &IO, ELFYAML::VerdefSection &Section) {
|
|
|
|
commonSectionMapping(IO, Section);
|
2021-01-18 22:42:49 +08:00
|
|
|
IO.mapOptional("Info", Section.Info);
|
2019-11-26 18:59:37 +08:00
|
|
|
IO.mapOptional("Entries", Section.Entries);
|
2019-02-21 20:21:43 +08:00
|
|
|
}
|
|
|
|
|
2019-02-19 23:29:07 +08:00
|
|
|
static void sectionMapping(IO &IO, ELFYAML::SymverSection &Section) {
|
|
|
|
commonSectionMapping(IO, Section);
|
2020-10-06 20:48:15 +08:00
|
|
|
IO.mapOptional("Entries", Section.Entries);
|
2019-02-19 23:29:07 +08:00
|
|
|
}
|
|
|
|
|
2019-02-19 22:53:48 +08:00
|
|
|
static void sectionMapping(IO &IO, ELFYAML::VerneedSection &Section) {
|
|
|
|
commonSectionMapping(IO, Section);
|
2021-01-18 22:42:49 +08:00
|
|
|
IO.mapOptional("Info", Section.Info);
|
2019-11-28 21:27:01 +08:00
|
|
|
IO.mapOptional("Dependencies", Section.VerneedV);
|
2019-02-19 22:53:48 +08:00
|
|
|
}
|
|
|
|
|
2014-04-11 12:13:39 +08:00
|
|
|
static void sectionMapping(IO &IO, ELFYAML::RelocationSection &Section) {
|
|
|
|
commonSectionMapping(IO, Section);
|
2019-02-12 17:08:59 +08:00
|
|
|
IO.mapOptional("Info", Section.RelocatableSec, StringRef());
|
2014-04-11 12:13:39 +08:00
|
|
|
IO.mapOptional("Relocations", Section.Relocations);
|
|
|
|
}
|
|
|
|
|
2020-01-15 19:29:29 +08:00
|
|
|
static void sectionMapping(IO &IO, ELFYAML::RelrSection &Section) {
|
|
|
|
commonSectionMapping(IO, Section);
|
|
|
|
IO.mapOptional("Entries", Section.Entries);
|
|
|
|
}
|
|
|
|
|
2020-10-06 21:04:15 +08:00
|
|
|
static void groupSectionMapping(IO &IO, ELFYAML::GroupSection &Group) {
|
2019-02-12 17:08:59 +08:00
|
|
|
commonSectionMapping(IO, Group);
|
2019-10-28 18:30:05 +08:00
|
|
|
IO.mapOptional("Info", Group.Signature);
|
2020-10-06 20:48:15 +08:00
|
|
|
IO.mapOptional("Members", Group.Members);
|
2015-02-21 12:28:26 +08:00
|
|
|
}
|
|
|
|
|
2019-08-08 17:49:05 +08:00
|
|
|
static void sectionMapping(IO &IO, ELFYAML::SymtabShndxSection &Section) {
|
|
|
|
commonSectionMapping(IO, Section);
|
2020-10-06 20:48:15 +08:00
|
|
|
IO.mapOptional("Entries", Section.Entries);
|
2019-08-08 17:49:05 +08:00
|
|
|
}
|
|
|
|
|
2019-10-03 22:52:33 +08:00
|
|
|
static void sectionMapping(IO &IO, ELFYAML::AddrsigSection &Section) {
|
|
|
|
commonSectionMapping(IO, Section);
|
|
|
|
IO.mapOptional("Symbols", Section.Symbols);
|
|
|
|
}
|
|
|
|
|
2019-11-01 20:24:58 +08:00
|
|
|
static void fillMapping(IO &IO, ELFYAML::Fill &Fill) {
|
|
|
|
IO.mapOptional("Name", Fill.Name, StringRef());
|
|
|
|
IO.mapOptional("Pattern", Fill.Pattern);
|
2020-05-19 01:46:28 +08:00
|
|
|
IO.mapOptional("Offset", Fill.Offset);
|
2019-11-01 20:24:58 +08:00
|
|
|
IO.mapRequired("Size", Fill.Size);
|
|
|
|
}
|
|
|
|
|
2021-01-19 22:02:08 +08:00
|
|
|
static void sectionHeaderTableMapping(IO &IO,
|
|
|
|
ELFYAML::SectionHeaderTable &SHT) {
|
|
|
|
IO.mapOptional("Offset", SHT.Offset);
|
|
|
|
IO.mapOptional("Sections", SHT.Sections);
|
|
|
|
IO.mapOptional("Excluded", SHT.Excluded);
|
|
|
|
IO.mapOptional("NoHeaders", SHT.NoHeaders);
|
|
|
|
}
|
|
|
|
|
2019-11-06 23:14:12 +08:00
|
|
|
static void sectionMapping(IO &IO, ELFYAML::LinkerOptionsSection &Section) {
|
|
|
|
commonSectionMapping(IO, Section);
|
|
|
|
IO.mapOptional("Options", Section.Options);
|
|
|
|
}
|
|
|
|
|
2019-11-22 22:18:34 +08:00
|
|
|
static void sectionMapping(IO &IO,
|
|
|
|
ELFYAML::DependentLibrariesSection &Section) {
|
|
|
|
commonSectionMapping(IO, Section);
|
|
|
|
IO.mapOptional("Libraries", Section.Libs);
|
|
|
|
}
|
|
|
|
|
2020-01-31 17:43:09 +08:00
|
|
|
static void sectionMapping(IO &IO, ELFYAML::CallGraphProfileSection &Section) {
|
|
|
|
commonSectionMapping(IO, Section);
|
|
|
|
IO.mapOptional("Entries", Section.Entries);
|
|
|
|
}
|
|
|
|
|
2015-02-21 12:28:26 +08:00
|
|
|
void MappingTraits<ELFYAML::SectionOrType>::mapping(
|
|
|
|
IO &IO, ELFYAML::SectionOrType §ionOrType) {
|
|
|
|
IO.mapRequired("SectionOrType", sectionOrType.sectionNameOrType);
|
|
|
|
}
|
|
|
|
|
2020-09-23 23:00:32 +08:00
|
|
|
static void sectionMapping(IO &IO, ELFYAML::ARMIndexTableSection &Section) {
|
|
|
|
commonSectionMapping(IO, Section);
|
|
|
|
IO.mapOptional("Entries", Section.Entries);
|
|
|
|
}
|
|
|
|
|
2015-05-07 23:40:48 +08:00
|
|
|
static void sectionMapping(IO &IO, ELFYAML::MipsABIFlags &Section) {
|
|
|
|
commonSectionMapping(IO, Section);
|
|
|
|
IO.mapOptional("Version", Section.Version, Hex16(0));
|
|
|
|
IO.mapRequired("ISA", Section.ISALevel);
|
|
|
|
IO.mapOptional("ISARevision", Section.ISARevision, Hex8(0));
|
|
|
|
IO.mapOptional("ISAExtension", Section.ISAExtension,
|
|
|
|
ELFYAML::MIPS_AFL_EXT(Mips::AFL_EXT_NONE));
|
|
|
|
IO.mapOptional("ASEs", Section.ASEs, ELFYAML::MIPS_AFL_ASE(0));
|
|
|
|
IO.mapOptional("FpABI", Section.FpABI,
|
|
|
|
ELFYAML::MIPS_ABI_FP(Mips::Val_GNU_MIPS_ABI_FP_ANY));
|
|
|
|
IO.mapOptional("GPRSize", Section.GPRSize,
|
|
|
|
ELFYAML::MIPS_AFL_REG(Mips::AFL_REG_NONE));
|
|
|
|
IO.mapOptional("CPR1Size", Section.CPR1Size,
|
|
|
|
ELFYAML::MIPS_AFL_REG(Mips::AFL_REG_NONE));
|
|
|
|
IO.mapOptional("CPR2Size", Section.CPR2Size,
|
|
|
|
ELFYAML::MIPS_AFL_REG(Mips::AFL_REG_NONE));
|
|
|
|
IO.mapOptional("Flags1", Section.Flags1, ELFYAML::MIPS_AFL_FLAGS1(0));
|
|
|
|
IO.mapOptional("Flags2", Section.Flags2, Hex32(0));
|
|
|
|
}
|
|
|
|
|
2020-09-23 23:00:32 +08:00
|
|
|
static StringRef getStringValue(IO &IO, const char *Key) {
|
|
|
|
StringRef Val;
|
|
|
|
IO.mapRequired(Key, Val);
|
|
|
|
return Val;
|
|
|
|
}
|
|
|
|
|
2021-01-19 22:02:08 +08:00
|
|
|
static void setStringValue(IO &IO, const char *Key, StringRef Val) {
|
|
|
|
IO.mapRequired(Key, Val);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool isInteger(StringRef Val) {
|
|
|
|
APInt Tmp;
|
|
|
|
return !Val.getAsInteger(0, Tmp);
|
|
|
|
}
|
|
|
|
|
2019-11-01 20:24:58 +08:00
|
|
|
void MappingTraits<std::unique_ptr<ELFYAML::Chunk>>::mapping(
|
|
|
|
IO &IO, std::unique_ptr<ELFYAML::Chunk> &Section) {
|
|
|
|
ELFYAML::ELF_SHT Type;
|
2021-01-19 22:02:08 +08:00
|
|
|
StringRef TypeStr;
|
2019-11-01 20:24:58 +08:00
|
|
|
if (IO.outputting()) {
|
2021-01-19 22:02:08 +08:00
|
|
|
if (auto *S = dyn_cast<ELFYAML::Section>(Section.get()))
|
|
|
|
Type = S->Type;
|
|
|
|
else if (auto *SHT = dyn_cast<ELFYAML::SectionHeaderTable>(Section.get()))
|
|
|
|
TypeStr = SHT->TypeStr;
|
2019-11-01 20:24:58 +08:00
|
|
|
} else {
|
|
|
|
// When the Type string does not have a "SHT_" prefix, we know it is not a
|
2021-01-19 22:02:08 +08:00
|
|
|
// description of a regular ELF output section.
|
|
|
|
TypeStr = getStringValue(IO, "Type");
|
|
|
|
if (TypeStr.startswith("SHT_") || isInteger(TypeStr))
|
|
|
|
IO.mapRequired("Type", Type);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (TypeStr == "Fill") {
|
|
|
|
assert(!IO.outputting()); // We don't dump fills currently.
|
|
|
|
Section.reset(new ELFYAML::Fill());
|
|
|
|
fillMapping(IO, *cast<ELFYAML::Fill>(Section.get()));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (TypeStr == ELFYAML::SectionHeaderTable::TypeStr) {
|
|
|
|
if (IO.outputting())
|
|
|
|
setStringValue(IO, "Type", TypeStr);
|
|
|
|
else
|
|
|
|
Section.reset(new ELFYAML::SectionHeaderTable(/*IsImplicit=*/false));
|
2019-11-01 20:24:58 +08:00
|
|
|
|
2021-01-19 22:02:08 +08:00
|
|
|
sectionHeaderTableMapping(
|
|
|
|
IO, *cast<ELFYAML::SectionHeaderTable>(Section.get()));
|
|
|
|
return;
|
2019-11-01 20:24:58 +08:00
|
|
|
}
|
2014-04-11 12:13:39 +08:00
|
|
|
|
2020-09-25 19:57:00 +08:00
|
|
|
const auto &Obj = *static_cast<ELFYAML::Object *>(IO.getContext());
|
|
|
|
if (Obj.getMachine() == ELF::EM_MIPS && Type == ELF::SHT_MIPS_ABIFLAGS) {
|
|
|
|
if (!IO.outputting())
|
|
|
|
Section.reset(new ELFYAML::MipsABIFlags());
|
|
|
|
sectionMapping(IO, *cast<ELFYAML::MipsABIFlags>(Section.get()));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-09-23 23:00:32 +08:00
|
|
|
if (Obj.getMachine() == ELF::EM_ARM && Type == ELF::SHT_ARM_EXIDX) {
|
|
|
|
if (!IO.outputting())
|
|
|
|
Section.reset(new ELFYAML::ARMIndexTableSection());
|
|
|
|
sectionMapping(IO, *cast<ELFYAML::ARMIndexTableSection>(Section.get()));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-11-01 20:24:58 +08:00
|
|
|
switch (Type) {
|
2019-02-09 19:34:28 +08:00
|
|
|
case ELF::SHT_DYNAMIC:
|
|
|
|
if (!IO.outputting())
|
|
|
|
Section.reset(new ELFYAML::DynamicSection());
|
|
|
|
sectionMapping(IO, *cast<ELFYAML::DynamicSection>(Section.get()));
|
|
|
|
break;
|
2014-04-11 12:13:39 +08:00
|
|
|
case ELF::SHT_REL:
|
|
|
|
case ELF::SHT_RELA:
|
|
|
|
if (!IO.outputting())
|
|
|
|
Section.reset(new ELFYAML::RelocationSection());
|
|
|
|
sectionMapping(IO, *cast<ELFYAML::RelocationSection>(Section.get()));
|
|
|
|
break;
|
2020-01-15 19:29:29 +08:00
|
|
|
case ELF::SHT_RELR:
|
|
|
|
if (!IO.outputting())
|
|
|
|
Section.reset(new ELFYAML::RelrSection());
|
|
|
|
sectionMapping(IO, *cast<ELFYAML::RelrSection>(Section.get()));
|
|
|
|
break;
|
2015-02-21 12:28:26 +08:00
|
|
|
case ELF::SHT_GROUP:
|
|
|
|
if (!IO.outputting())
|
2020-10-06 21:04:15 +08:00
|
|
|
Section.reset(new ELFYAML::GroupSection());
|
|
|
|
groupSectionMapping(IO, *cast<ELFYAML::GroupSection>(Section.get()));
|
2015-07-04 07:00:54 +08:00
|
|
|
break;
|
|
|
|
case ELF::SHT_NOBITS:
|
|
|
|
if (!IO.outputting())
|
|
|
|
Section.reset(new ELFYAML::NoBitsSection());
|
|
|
|
sectionMapping(IO, *cast<ELFYAML::NoBitsSection>(Section.get()));
|
2015-02-21 12:28:26 +08:00
|
|
|
break;
|
2019-10-01 17:45:59 +08:00
|
|
|
case ELF::SHT_HASH:
|
|
|
|
if (!IO.outputting())
|
|
|
|
Section.reset(new ELFYAML::HashSection());
|
|
|
|
sectionMapping(IO, *cast<ELFYAML::HashSection>(Section.get()));
|
|
|
|
break;
|
[yaml2obj, obj2yaml] - Add support for SHT_NOTE sections.
SHT_NOTE is the section that consists of
namesz, descsz, type, name + padding, desc + padding data.
This patch teaches yaml2obj, obj2yaml to dump and parse them.
This patch implements the section how it is described here:
https://docs.oracle.com/cd/E23824_01/html/819-0690/chapter6-18048.html
Which says: "For 64–bit objects and 32–bit objects, each entry is an array of 4-byte words in
the format of the target processor"
The official specification is different
http://www.sco.com/developers/gabi/latest/ch5.pheader.html#note_section
And says: "n 64-bit objects (files with e_ident[EI_CLASS] equal to ELFCLASS64), each entry is an array
of 8-byte words in the format of the target processor. In 32-bit objects (files with e_ident[EI_CLASS]
equal to ELFCLASS32), each entry is an array of 4-byte words in the format of the target processor"
Since LLVM uses the first, 32-bit way, this patch follows it.
Differential revision: https://reviews.llvm.org/D68983
2019-10-25 18:03:19 +08:00
|
|
|
case ELF::SHT_NOTE:
|
|
|
|
if (!IO.outputting())
|
|
|
|
Section.reset(new ELFYAML::NoteSection());
|
|
|
|
sectionMapping(IO, *cast<ELFYAML::NoteSection>(Section.get()));
|
|
|
|
break;
|
2019-10-24 20:38:53 +08:00
|
|
|
case ELF::SHT_GNU_HASH:
|
|
|
|
if (!IO.outputting())
|
|
|
|
Section.reset(new ELFYAML::GnuHashSection());
|
|
|
|
sectionMapping(IO, *cast<ELFYAML::GnuHashSection>(Section.get()));
|
|
|
|
break;
|
2019-02-21 20:21:43 +08:00
|
|
|
case ELF::SHT_GNU_verdef:
|
|
|
|
if (!IO.outputting())
|
|
|
|
Section.reset(new ELFYAML::VerdefSection());
|
|
|
|
sectionMapping(IO, *cast<ELFYAML::VerdefSection>(Section.get()));
|
|
|
|
break;
|
2019-02-19 23:29:07 +08:00
|
|
|
case ELF::SHT_GNU_versym:
|
|
|
|
if (!IO.outputting())
|
|
|
|
Section.reset(new ELFYAML::SymverSection());
|
|
|
|
sectionMapping(IO, *cast<ELFYAML::SymverSection>(Section.get()));
|
|
|
|
break;
|
2019-02-19 22:53:48 +08:00
|
|
|
case ELF::SHT_GNU_verneed:
|
|
|
|
if (!IO.outputting())
|
|
|
|
Section.reset(new ELFYAML::VerneedSection());
|
|
|
|
sectionMapping(IO, *cast<ELFYAML::VerneedSection>(Section.get()));
|
|
|
|
break;
|
2019-08-08 17:49:05 +08:00
|
|
|
case ELF::SHT_SYMTAB_SHNDX:
|
|
|
|
if (!IO.outputting())
|
|
|
|
Section.reset(new ELFYAML::SymtabShndxSection());
|
|
|
|
sectionMapping(IO, *cast<ELFYAML::SymtabShndxSection>(Section.get()));
|
|
|
|
break;
|
2019-10-03 22:52:33 +08:00
|
|
|
case ELF::SHT_LLVM_ADDRSIG:
|
|
|
|
if (!IO.outputting())
|
|
|
|
Section.reset(new ELFYAML::AddrsigSection());
|
|
|
|
sectionMapping(IO, *cast<ELFYAML::AddrsigSection>(Section.get()));
|
|
|
|
break;
|
2019-11-06 23:14:12 +08:00
|
|
|
case ELF::SHT_LLVM_LINKER_OPTIONS:
|
|
|
|
if (!IO.outputting())
|
|
|
|
Section.reset(new ELFYAML::LinkerOptionsSection());
|
|
|
|
sectionMapping(IO, *cast<ELFYAML::LinkerOptionsSection>(Section.get()));
|
|
|
|
break;
|
2019-11-22 22:18:34 +08:00
|
|
|
case ELF::SHT_LLVM_DEPENDENT_LIBRARIES:
|
|
|
|
if (!IO.outputting())
|
|
|
|
Section.reset(new ELFYAML::DependentLibrariesSection());
|
|
|
|
sectionMapping(IO,
|
|
|
|
*cast<ELFYAML::DependentLibrariesSection>(Section.get()));
|
|
|
|
break;
|
2020-01-31 17:43:09 +08:00
|
|
|
case ELF::SHT_LLVM_CALL_GRAPH_PROFILE:
|
|
|
|
if (!IO.outputting())
|
|
|
|
Section.reset(new ELFYAML::CallGraphProfileSection());
|
|
|
|
sectionMapping(IO, *cast<ELFYAML::CallGraphProfileSection>(Section.get()));
|
|
|
|
break;
|
2020-11-07 04:44:24 +08:00
|
|
|
case ELF::SHT_LLVM_BB_ADDR_MAP:
|
|
|
|
if (!IO.outputting())
|
|
|
|
Section.reset(new ELFYAML::BBAddrMapSection());
|
|
|
|
sectionMapping(IO, *cast<ELFYAML::BBAddrMapSection>(Section.get()));
|
|
|
|
break;
|
2014-04-11 12:13:39 +08:00
|
|
|
default:
|
2019-09-24 22:22:37 +08:00
|
|
|
if (!IO.outputting()) {
|
|
|
|
StringRef Name;
|
|
|
|
IO.mapOptional("Name", Name, StringRef());
|
2019-09-25 20:09:30 +08:00
|
|
|
Name = ELFYAML::dropUniqueSuffix(Name);
|
2019-09-24 22:22:37 +08:00
|
|
|
|
|
|
|
if (ELFYAML::StackSizesSection::nameMatches(Name))
|
|
|
|
Section = std::make_unique<ELFYAML::StackSizesSection>();
|
|
|
|
else
|
|
|
|
Section = std::make_unique<ELFYAML::RawContentSection>();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (auto S = dyn_cast<ELFYAML::RawContentSection>(Section.get()))
|
|
|
|
sectionMapping(IO, *S);
|
|
|
|
else
|
|
|
|
sectionMapping(IO, *cast<ELFYAML::StackSizesSection>(Section.get()));
|
2014-04-11 12:13:39 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-20 21:01:01 +08:00
|
|
|
std::string MappingTraits<std::unique_ptr<ELFYAML::Chunk>>::validate(
|
2019-11-01 20:24:58 +08:00
|
|
|
IO &io, std::unique_ptr<ELFYAML::Chunk> &C) {
|
2020-10-06 20:48:15 +08:00
|
|
|
if (const auto *F = dyn_cast<ELFYAML::Fill>(C.get())) {
|
|
|
|
if (F->Pattern && F->Pattern->binary_size() != 0 && !F->Size)
|
|
|
|
return "\"Size\" can't be 0 when \"Pattern\" is not empty";
|
2020-10-20 21:01:01 +08:00
|
|
|
return "";
|
2020-10-06 20:48:15 +08:00
|
|
|
}
|
|
|
|
|
2021-01-19 22:02:08 +08:00
|
|
|
if (const auto *SHT = dyn_cast<ELFYAML::SectionHeaderTable>(C.get())) {
|
|
|
|
if (SHT->NoHeaders && (SHT->Sections || SHT->Excluded || SHT->Offset))
|
|
|
|
return "NoHeaders can't be used together with Offset/Sections/Excluded";
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2020-10-06 20:48:15 +08:00
|
|
|
const ELFYAML::Section &Sec = *cast<ELFYAML::Section>(C.get());
|
|
|
|
if (Sec.Size && Sec.Content &&
|
|
|
|
(uint64_t)(*Sec.Size) < Sec.Content->binary_size())
|
|
|
|
return "Section size must be greater than or equal to the content size";
|
|
|
|
|
2020-10-20 21:01:01 +08:00
|
|
|
auto BuildErrPrefix = [](ArrayRef<std::pair<StringRef, bool>> EntV) {
|
|
|
|
std::string Msg;
|
|
|
|
for (size_t I = 0, E = EntV.size(); I != E; ++I) {
|
|
|
|
StringRef Name = EntV[I].first;
|
|
|
|
if (I == 0) {
|
|
|
|
Msg = "\"" + Name.str() + "\"";
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (I != EntV.size() - 1)
|
|
|
|
Msg += ", \"" + Name.str() + "\"";
|
|
|
|
else
|
|
|
|
Msg += " and \"" + Name.str() + "\"";
|
|
|
|
}
|
|
|
|
return Msg;
|
|
|
|
};
|
2020-10-20 20:16:56 +08:00
|
|
|
|
2020-10-20 21:01:01 +08:00
|
|
|
std::vector<std::pair<StringRef, bool>> Entries = Sec.getEntries();
|
|
|
|
const size_t NumUsedEntries = llvm::count_if(
|
|
|
|
Entries, [](const std::pair<StringRef, bool> &P) { return P.second; });
|
2020-10-20 20:16:56 +08:00
|
|
|
|
2020-10-20 21:01:01 +08:00
|
|
|
if ((Sec.Size || Sec.Content) && NumUsedEntries > 0)
|
|
|
|
return BuildErrPrefix(Entries) +
|
|
|
|
" cannot be used with \"Content\" or \"Size\"";
|
2020-10-20 20:16:56 +08:00
|
|
|
|
2020-10-20 21:01:01 +08:00
|
|
|
if (NumUsedEntries > 0 && Entries.size() != NumUsedEntries)
|
|
|
|
return BuildErrPrefix(Entries) + " must be used together";
|
2020-10-20 20:16:56 +08:00
|
|
|
|
2020-10-20 21:01:01 +08:00
|
|
|
if (const auto *RawSection = dyn_cast<ELFYAML::RawContentSection>(C.get())) {
|
|
|
|
if (RawSection->Flags && RawSection->ShFlags)
|
|
|
|
return "ShFlags and Flags cannot be used together";
|
|
|
|
return "";
|
2020-10-06 20:48:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (const auto *NB = dyn_cast<ELFYAML::NoBitsSection>(C.get())) {
|
|
|
|
if (NB->Content)
|
|
|
|
return "SHT_NOBITS section cannot have \"Content\"";
|
2020-10-20 21:01:01 +08:00
|
|
|
return "";
|
2020-10-06 20:48:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (const auto *MF = dyn_cast<ELFYAML::MipsABIFlags>(C.get())) {
|
|
|
|
if (MF->Content)
|
|
|
|
return "\"Content\" key is not implemented for SHT_MIPS_ABIFLAGS "
|
|
|
|
"sections";
|
|
|
|
if (MF->Size)
|
|
|
|
return "\"Size\" key is not implemented for SHT_MIPS_ABIFLAGS sections";
|
2020-10-20 21:01:01 +08:00
|
|
|
return "";
|
2020-09-23 23:00:32 +08:00
|
|
|
}
|
|
|
|
|
2020-10-20 21:01:01 +08:00
|
|
|
return "";
|
2014-05-17 00:01:00 +08:00
|
|
|
}
|
|
|
|
|
2015-01-25 21:29:25 +08:00
|
|
|
namespace {
|
2017-07-01 09:35:55 +08:00
|
|
|
|
2015-01-25 21:29:25 +08:00
|
|
|
struct NormalizedMips64RelType {
|
|
|
|
NormalizedMips64RelType(IO &)
|
|
|
|
: Type(ELFYAML::ELF_REL(ELF::R_MIPS_NONE)),
|
|
|
|
Type2(ELFYAML::ELF_REL(ELF::R_MIPS_NONE)),
|
|
|
|
Type3(ELFYAML::ELF_REL(ELF::R_MIPS_NONE)),
|
|
|
|
SpecSym(ELFYAML::ELF_REL(ELF::RSS_UNDEF)) {}
|
|
|
|
NormalizedMips64RelType(IO &, ELFYAML::ELF_REL Original)
|
|
|
|
: Type(Original & 0xFF), Type2(Original >> 8 & 0xFF),
|
|
|
|
Type3(Original >> 16 & 0xFF), SpecSym(Original >> 24 & 0xFF) {}
|
|
|
|
|
|
|
|
ELFYAML::ELF_REL denormalize(IO &) {
|
|
|
|
ELFYAML::ELF_REL Res = Type | Type2 << 8 | Type3 << 16 | SpecSym << 24;
|
|
|
|
return Res;
|
|
|
|
}
|
|
|
|
|
|
|
|
ELFYAML::ELF_REL Type;
|
|
|
|
ELFYAML::ELF_REL Type2;
|
|
|
|
ELFYAML::ELF_REL Type3;
|
|
|
|
ELFYAML::ELF_RSS SpecSym;
|
|
|
|
};
|
2017-07-01 09:35:55 +08:00
|
|
|
|
|
|
|
} // end anonymous namespace
|
2015-01-25 21:29:25 +08:00
|
|
|
|
2019-09-24 22:22:37 +08:00
|
|
|
void MappingTraits<ELFYAML::StackSizeEntry>::mapping(
|
|
|
|
IO &IO, ELFYAML::StackSizeEntry &E) {
|
|
|
|
assert(IO.getContext() && "The IO context is not initialized");
|
|
|
|
IO.mapOptional("Address", E.Address, Hex64(0));
|
|
|
|
IO.mapRequired("Size", E.Size);
|
|
|
|
}
|
|
|
|
|
2020-11-07 04:44:24 +08:00
|
|
|
void MappingTraits<ELFYAML::BBAddrMapEntry>::mapping(
|
|
|
|
IO &IO, ELFYAML::BBAddrMapEntry &E) {
|
|
|
|
assert(IO.getContext() && "The IO context is not initialized");
|
|
|
|
IO.mapOptional("Address", E.Address, Hex64(0));
|
2021-02-17 10:43:56 +08:00
|
|
|
IO.mapOptional("NumBlocks", E.NumBlocks);
|
2021-02-23 09:50:14 +08:00
|
|
|
IO.mapOptional("BBEntries", E.BBEntries);
|
2020-11-07 04:44:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void MappingTraits<ELFYAML::BBAddrMapEntry::BBEntry>::mapping(
|
|
|
|
IO &IO, ELFYAML::BBAddrMapEntry::BBEntry &E) {
|
|
|
|
assert(IO.getContext() && "The IO context is not initialized");
|
|
|
|
IO.mapRequired("AddressOffset", E.AddressOffset);
|
|
|
|
IO.mapRequired("Size", E.Size);
|
|
|
|
IO.mapRequired("Metadata", E.Metadata);
|
|
|
|
}
|
|
|
|
|
2019-10-24 20:38:53 +08:00
|
|
|
void MappingTraits<ELFYAML::GnuHashHeader>::mapping(IO &IO,
|
|
|
|
ELFYAML::GnuHashHeader &E) {
|
|
|
|
assert(IO.getContext() && "The IO context is not initialized");
|
|
|
|
IO.mapOptional("NBuckets", E.NBuckets);
|
|
|
|
IO.mapRequired("SymNdx", E.SymNdx);
|
|
|
|
IO.mapOptional("MaskWords", E.MaskWords);
|
|
|
|
IO.mapRequired("Shift2", E.Shift2);
|
|
|
|
}
|
|
|
|
|
2019-02-09 19:34:28 +08:00
|
|
|
void MappingTraits<ELFYAML::DynamicEntry>::mapping(IO &IO,
|
|
|
|
ELFYAML::DynamicEntry &Rel) {
|
2019-02-09 20:14:20 +08:00
|
|
|
assert(IO.getContext() && "The IO context is not initialized");
|
2019-02-09 19:34:28 +08:00
|
|
|
|
|
|
|
IO.mapRequired("Tag", Rel.Tag);
|
|
|
|
IO.mapRequired("Value", Rel.Val);
|
|
|
|
}
|
|
|
|
|
[yaml2obj, obj2yaml] - Add support for SHT_NOTE sections.
SHT_NOTE is the section that consists of
namesz, descsz, type, name + padding, desc + padding data.
This patch teaches yaml2obj, obj2yaml to dump and parse them.
This patch implements the section how it is described here:
https://docs.oracle.com/cd/E23824_01/html/819-0690/chapter6-18048.html
Which says: "For 64–bit objects and 32–bit objects, each entry is an array of 4-byte words in
the format of the target processor"
The official specification is different
http://www.sco.com/developers/gabi/latest/ch5.pheader.html#note_section
And says: "n 64-bit objects (files with e_ident[EI_CLASS] equal to ELFCLASS64), each entry is an array
of 8-byte words in the format of the target processor. In 32-bit objects (files with e_ident[EI_CLASS]
equal to ELFCLASS32), each entry is an array of 4-byte words in the format of the target processor"
Since LLVM uses the first, 32-bit way, this patch follows it.
Differential revision: https://reviews.llvm.org/D68983
2019-10-25 18:03:19 +08:00
|
|
|
void MappingTraits<ELFYAML::NoteEntry>::mapping(IO &IO, ELFYAML::NoteEntry &N) {
|
|
|
|
assert(IO.getContext() && "The IO context is not initialized");
|
|
|
|
|
|
|
|
IO.mapOptional("Name", N.Name);
|
|
|
|
IO.mapOptional("Desc", N.Desc);
|
|
|
|
IO.mapRequired("Type", N.Type);
|
|
|
|
}
|
|
|
|
|
2019-02-21 20:21:43 +08:00
|
|
|
void MappingTraits<ELFYAML::VerdefEntry>::mapping(IO &IO,
|
|
|
|
ELFYAML::VerdefEntry &E) {
|
|
|
|
assert(IO.getContext() && "The IO context is not initialized");
|
|
|
|
|
2021-01-13 22:16:55 +08:00
|
|
|
IO.mapOptional("Version", E.Version);
|
|
|
|
IO.mapOptional("Flags", E.Flags);
|
|
|
|
IO.mapOptional("VersionNdx", E.VersionNdx);
|
|
|
|
IO.mapOptional("Hash", E.Hash);
|
2019-02-21 20:21:43 +08:00
|
|
|
IO.mapRequired("Names", E.VerNames);
|
|
|
|
}
|
|
|
|
|
2019-02-19 22:53:48 +08:00
|
|
|
void MappingTraits<ELFYAML::VerneedEntry>::mapping(IO &IO,
|
|
|
|
ELFYAML::VerneedEntry &E) {
|
|
|
|
assert(IO.getContext() && "The IO context is not initialized");
|
|
|
|
|
|
|
|
IO.mapRequired("Version", E.Version);
|
|
|
|
IO.mapRequired("File", E.File);
|
|
|
|
IO.mapRequired("Entries", E.AuxV);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MappingTraits<ELFYAML::VernauxEntry>::mapping(IO &IO,
|
|
|
|
ELFYAML::VernauxEntry &E) {
|
|
|
|
assert(IO.getContext() && "The IO context is not initialized");
|
|
|
|
|
|
|
|
IO.mapRequired("Name", E.Name);
|
|
|
|
IO.mapRequired("Hash", E.Hash);
|
|
|
|
IO.mapRequired("Flags", E.Flags);
|
|
|
|
IO.mapRequired("Other", E.Other);
|
|
|
|
}
|
|
|
|
|
2014-04-11 12:13:39 +08:00
|
|
|
void MappingTraits<ELFYAML::Relocation>::mapping(IO &IO,
|
|
|
|
ELFYAML::Relocation &Rel) {
|
2015-01-25 21:29:25 +08:00
|
|
|
const auto *Object = static_cast<ELFYAML::Object *>(IO.getContext());
|
|
|
|
assert(Object && "The IO context is not initialized");
|
|
|
|
|
2020-03-04 21:55:15 +08:00
|
|
|
IO.mapOptional("Offset", Rel.Offset, (Hex64)0);
|
2017-08-31 07:13:31 +08:00
|
|
|
IO.mapOptional("Symbol", Rel.Symbol);
|
2015-01-25 21:29:25 +08:00
|
|
|
|
2020-08-18 20:24:26 +08:00
|
|
|
if (Object->getMachine() == ELFYAML::ELF_EM(ELF::EM_MIPS) &&
|
2015-01-25 21:29:25 +08:00
|
|
|
Object->Header.Class == ELFYAML::ELF_ELFCLASS(ELF::ELFCLASS64)) {
|
|
|
|
MappingNormalization<NormalizedMips64RelType, ELFYAML::ELF_REL> Key(
|
|
|
|
IO, Rel.Type);
|
|
|
|
IO.mapRequired("Type", Key->Type);
|
|
|
|
IO.mapOptional("Type2", Key->Type2, ELFYAML::ELF_REL(ELF::R_MIPS_NONE));
|
|
|
|
IO.mapOptional("Type3", Key->Type3, ELFYAML::ELF_REL(ELF::R_MIPS_NONE));
|
|
|
|
IO.mapOptional("SpecSym", Key->SpecSym, ELFYAML::ELF_RSS(ELF::RSS_UNDEF));
|
|
|
|
} else
|
|
|
|
IO.mapRequired("Type", Rel.Type);
|
|
|
|
|
2020-03-03 15:54:55 +08:00
|
|
|
IO.mapOptional("Addend", Rel.Addend, (ELFYAML::YAMLIntUInt)0);
|
2014-04-11 12:13:39 +08:00
|
|
|
}
|
|
|
|
|
2020-09-23 23:00:32 +08:00
|
|
|
void MappingTraits<ELFYAML::ARMIndexTableEntry>::mapping(
|
|
|
|
IO &IO, ELFYAML::ARMIndexTableEntry &E) {
|
|
|
|
assert(IO.getContext() && "The IO context is not initialized");
|
|
|
|
IO.mapRequired("Offset", E.Offset);
|
|
|
|
|
|
|
|
StringRef CantUnwind = "EXIDX_CANTUNWIND";
|
|
|
|
if (IO.outputting() && (uint32_t)E.Value == ARM::EHABI::EXIDX_CANTUNWIND)
|
|
|
|
IO.mapRequired("Value", CantUnwind);
|
|
|
|
else if (!IO.outputting() && getStringValue(IO, "Value") == CantUnwind)
|
|
|
|
E.Value = ARM::EHABI::EXIDX_CANTUNWIND;
|
|
|
|
else
|
|
|
|
IO.mapRequired("Value", E.Value);
|
|
|
|
}
|
|
|
|
|
2013-06-11 07:44:15 +08:00
|
|
|
void MappingTraits<ELFYAML::Object>::mapping(IO &IO, ELFYAML::Object &Object) {
|
2014-04-11 12:13:39 +08:00
|
|
|
assert(!IO.getContext() && "The IO context is initialized already");
|
|
|
|
IO.setContext(&Object);
|
2016-06-28 03:53:53 +08:00
|
|
|
IO.mapTag("!ELF", true);
|
2013-06-11 08:13:52 +08:00
|
|
|
IO.mapRequired("FileHeader", Object.Header);
|
2017-07-20 04:38:46 +08:00
|
|
|
IO.mapOptional("ProgramHeaders", Object.ProgramHeaders);
|
2019-11-01 20:24:58 +08:00
|
|
|
IO.mapOptional("Sections", Object.Chunks);
|
2013-06-22 09:38:00 +08:00
|
|
|
IO.mapOptional("Symbols", Object.Symbols);
|
2017-11-17 02:10:15 +08:00
|
|
|
IO.mapOptional("DynamicSymbols", Object.DynamicSymbols);
|
2020-05-29 10:51:37 +08:00
|
|
|
IO.mapOptional("DWARF", Object.DWARF);
|
2020-06-14 12:00:46 +08:00
|
|
|
if (Object.DWARF) {
|
2020-06-04 09:25:26 +08:00
|
|
|
Object.DWARF->IsLittleEndian =
|
|
|
|
Object.Header.Data == ELFYAML::ELF_ELFDATA(ELF::ELFDATA2LSB);
|
2020-07-14 10:55:34 +08:00
|
|
|
Object.DWARF->Is64BitAddrSize =
|
2020-06-14 12:00:46 +08:00
|
|
|
Object.Header.Class == ELFYAML::ELF_ELFCLASS(ELF::ELFCLASS64);
|
|
|
|
}
|
2014-04-11 12:13:39 +08:00
|
|
|
IO.setContext(nullptr);
|
2013-06-11 07:44:15 +08:00
|
|
|
}
|
|
|
|
|
2019-11-06 23:14:12 +08:00
|
|
|
void MappingTraits<ELFYAML::LinkerOption>::mapping(IO &IO,
|
|
|
|
ELFYAML::LinkerOption &Opt) {
|
|
|
|
assert(IO.getContext() && "The IO context is not initialized");
|
|
|
|
IO.mapRequired("Name", Opt.Key);
|
|
|
|
IO.mapRequired("Value", Opt.Value);
|
|
|
|
}
|
|
|
|
|
2021-06-24 23:02:45 +08:00
|
|
|
void MappingTraits<ELFYAML::CallGraphEntryWeight>::mapping(
|
|
|
|
IO &IO, ELFYAML::CallGraphEntryWeight &E) {
|
2020-01-31 17:43:09 +08:00
|
|
|
assert(IO.getContext() && "The IO context is not initialized");
|
|
|
|
IO.mapRequired("Weight", E.Weight);
|
|
|
|
}
|
|
|
|
|
2015-05-07 23:40:48 +08:00
|
|
|
LLVM_YAML_STRONG_TYPEDEF(uint8_t, MIPS_AFL_REG)
|
|
|
|
LLVM_YAML_STRONG_TYPEDEF(uint8_t, MIPS_ABI_FP)
|
|
|
|
LLVM_YAML_STRONG_TYPEDEF(uint32_t, MIPS_AFL_EXT)
|
|
|
|
LLVM_YAML_STRONG_TYPEDEF(uint32_t, MIPS_AFL_ASE)
|
|
|
|
LLVM_YAML_STRONG_TYPEDEF(uint32_t, MIPS_AFL_FLAGS1)
|
|
|
|
|
2013-06-11 07:44:15 +08:00
|
|
|
} // end namespace yaml
|
2017-07-01 09:35:55 +08:00
|
|
|
|
2013-06-11 07:44:15 +08:00
|
|
|
} // end namespace llvm
|