[lld] 2763353 - [Object,ELFType] Rename TargetEndianness to Endianness (#86604)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 28 09:10:38 PDT 2024
Author: Fangrui Song
Date: 2024-03-28T09:10:34-07:00
New Revision: 276335389133d6acf5f9d7d2f8ce09f9c610cb9c
URL: https://github.com/llvm/llvm-project/commit/276335389133d6acf5f9d7d2f8ce09f9c610cb9c
DIFF: https://github.com/llvm/llvm-project/commit/276335389133d6acf5f9d7d2f8ce09f9c610cb9c.diff
LOG: [Object,ELFType] Rename TargetEndianness to Endianness (#86604)
`TargetEndianness` is long and unwieldy. "Target" in the name is confusing. Rename it to "Endianness".
I cannot find noticeable out-of-tree users of `TargetEndianness`, but
keep `TargetEndianness` to make this patch safer. `TargetEndianness`
will be removed by a subsequent change.
Added:
Modified:
lld/ELF/Arch/Mips.cpp
lld/ELF/DWARF.h
lld/ELF/InputFiles.cpp
lld/ELF/InputSection.cpp
lld/ELF/SyntheticSections.cpp
llvm/include/llvm/ExecutionEngine/Orc/ExecutionUtils.h
llvm/include/llvm/Object/ELFObjectFile.h
llvm/include/llvm/Object/ELFTypes.h
llvm/lib/ExecutionEngine/JITLink/ELFLinkGraphBuilder.h
llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp
llvm/lib/InterfaceStub/ELFObjHandler.cpp
llvm/lib/ObjCopy/ELF/ELFObject.cpp
llvm/lib/ObjectYAML/ELFEmitter.cpp
llvm/tools/llvm-readobj/DwarfCFIEHPrinter.h
llvm/tools/llvm-readobj/ELFDumper.cpp
Removed:
################################################################################
diff --git a/lld/ELF/Arch/Mips.cpp b/lld/ELF/Arch/Mips.cpp
index b02ad10649d901..e36e9d59a7401c 100644
--- a/lld/ELF/Arch/Mips.cpp
+++ b/lld/ELF/Arch/Mips.cpp
@@ -380,7 +380,7 @@ bool MIPS<ELFT>::needsThunk(RelExpr expr, RelType type, const InputFile *file,
template <class ELFT>
int64_t MIPS<ELFT>::getImplicitAddend(const uint8_t *buf, RelType type) const {
- const endianness e = ELFT::TargetEndianness;
+ const endianness e = ELFT::Endianness;
switch (type) {
case R_MIPS_32:
case R_MIPS_REL32:
@@ -521,7 +521,7 @@ static uint64_t fixupCrossModeJump(uint8_t *loc, RelType type, uint64_t val) {
// to a microMIPS target and vice versa. In that cases jump
// instructions need to be replaced by their "cross-mode"
// equivalents.
- const endianness e = ELFT::TargetEndianness;
+ const endianness e = ELFT::Endianness;
bool isMicroTgt = val & 0x1;
bool isCrossJump = (isMicroTgt && isBranchReloc(type)) ||
(!isMicroTgt && isMicroBranchReloc(type));
@@ -567,7 +567,7 @@ static uint64_t fixupCrossModeJump(uint8_t *loc, RelType type, uint64_t val) {
template <class ELFT>
void MIPS<ELFT>::relocate(uint8_t *loc, const Relocation &rel,
uint64_t val) const {
- const endianness e = ELFT::TargetEndianness;
+ const endianness e = ELFT::Endianness;
RelType type = rel.type;
if (ELFT::Is64Bits || config->mipsN32Abi)
diff --git a/lld/ELF/DWARF.h b/lld/ELF/DWARF.h
index 1b9a3e3f77943b..d56895277bcc91 100644
--- a/lld/ELF/DWARF.h
+++ b/lld/ELF/DWARF.h
@@ -74,7 +74,7 @@ template <class ELFT> class LLDDwarfObj final : public llvm::DWARFObject {
StringRef getLineStrSection() const override { return lineStrSection; }
bool isLittleEndian() const override {
- return ELFT::TargetEndianness == llvm::endianness::little;
+ return ELFT::Endianness == llvm::endianness::little;
}
std::optional<llvm::RelocAddrEntry> find(const llvm::DWARFSection &sec,
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index 42761b6e12097f..725c6f166fffca 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -971,8 +971,8 @@ template <class ELFT> static uint32_t readAndFeatures(const InputSection &sec) {
const uint8_t *place = desc.data();
if (desc.size() < 8)
reportFatal(place, "program property is too short");
- uint32_t type = read32<ELFT::TargetEndianness>(desc.data());
- uint32_t size = read32<ELFT::TargetEndianness>(desc.data() + 4);
+ uint32_t type = read32<ELFT::Endianness>(desc.data());
+ uint32_t size = read32<ELFT::Endianness>(desc.data() + 4);
desc = desc.slice(8);
if (desc.size() < size)
reportFatal(place, "program property is too short");
@@ -983,7 +983,7 @@ template <class ELFT> static uint32_t readAndFeatures(const InputSection &sec) {
// accumulate the bits set.
if (size < 4)
reportFatal(place, "FEATURE_1_AND entry is too short");
- featuresSet |= read32<ELFT::TargetEndianness>(desc.data());
+ featuresSet |= read32<ELFT::Endianness>(desc.data());
}
// Padding is present in the note descriptor, if necessary.
diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp
index c34bf08757b156..4f88313b868b24 100644
--- a/lld/ELF/InputSection.cpp
+++ b/lld/ELF/InputSection.cpp
@@ -1258,10 +1258,10 @@ void EhInputSection::split(ArrayRef<RelTy> rels) {
msg = "CIE/FDE too small";
break;
}
- uint64_t size = endian::read32<ELFT::TargetEndianness>(d.data());
+ uint64_t size = endian::read32<ELFT::Endianness>(d.data());
if (size == 0) // ZERO terminator
break;
- uint32_t id = endian::read32<ELFT::TargetEndianness>(d.data() + 4);
+ uint32_t id = endian::read32<ELFT::Endianness>(d.data() + 4);
size += 4;
if (LLVM_UNLIKELY(size > d.size())) {
// If it is 0xFFFFFFFF, the next 8 bytes contain the size instead,
diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index 650bd6cd390060..8708bfeef8fa9a 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -415,7 +415,7 @@ void EhFrameSection::addRecords(EhInputSection *sec, ArrayRef<RelTy> rels) {
for (EhSectionPiece &cie : sec->cies)
offsetToCie[cie.inputOff] = addCie<ELFT>(cie, rels);
for (EhSectionPiece &fde : sec->fdes) {
- uint32_t id = endian::read32<ELFT::TargetEndianness>(fde.data().data() + 4);
+ uint32_t id = endian::read32<ELFT::Endianness>(fde.data().data() + 4);
CieRecord *rec = offsetToCie[fde.inputOff + 4 - id];
if (!rec)
fatal(toString(sec) + ": invalid CIE reference");
@@ -448,7 +448,7 @@ void EhFrameSection::iterateFDEWithLSDAAux(
if (hasLSDA(cie))
ciesWithLSDA.insert(cie.inputOff);
for (EhSectionPiece &fde : sec.fdes) {
- uint32_t id = endian::read32<ELFT::TargetEndianness>(fde.data().data() + 4);
+ uint32_t id = endian::read32<ELFT::Endianness>(fde.data().data() + 4);
if (!ciesWithLSDA.contains(fde.inputOff + 4 - id))
continue;
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/ExecutionUtils.h b/llvm/include/llvm/ExecutionEngine/Orc/ExecutionUtils.h
index f7c286bec778b0..ed30a792e9e9ce 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/ExecutionUtils.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/ExecutionUtils.h
@@ -352,7 +352,7 @@ class DLLImportDefinitionGenerator : public DefinitionGenerator {
: ES(ES), L(L) {}
static Expected<unsigned> getTargetPointerSize(const Triple &TT);
- static Expected<llvm::endianness> getTargetEndianness(const Triple &TT);
+ static Expected<llvm::endianness> getEndianness(const Triple &TT);
Expected<std::unique_ptr<jitlink::LinkGraph>>
createStubsGraph(const SymbolMap &Resolved);
diff --git a/llvm/include/llvm/Object/ELFObjectFile.h b/llvm/include/llvm/Object/ELFObjectFile.h
index f57a7ab8882ad2..1d457be93741f2 100644
--- a/llvm/include/llvm/Object/ELFObjectFile.h
+++ b/llvm/include/llvm/Object/ELFObjectFile.h
@@ -419,7 +419,7 @@ template <class ELFT> class ELFObjectFile : public ELFObjectFileBase {
if (Contents[0] != ELFAttrs::Format_Version || Contents.size() == 1)
return Error::success();
- if (Error E = Attributes.parse(Contents, ELFT::TargetEndianness))
+ if (Error E = Attributes.parse(Contents, ELFT::Endianness))
return E;
break;
}
@@ -482,7 +482,7 @@ template <class ELFT> class ELFObjectFile : public ELFObjectFileBase {
bool isDyldType() const { return isDyldELFObject; }
static bool classof(const Binary *v) {
return v->getType() ==
- getELFType(ELFT::TargetEndianness == llvm::endianness::little,
+ getELFType(ELFT::Endianness == llvm::endianness::little,
ELFT::Is64Bits);
}
@@ -1155,10 +1155,9 @@ ELFObjectFile<ELFT>::ELFObjectFile(MemoryBufferRef Object, ELFFile<ELFT> EF,
const Elf_Shdr *DotDynSymSec,
const Elf_Shdr *DotSymtabSec,
const Elf_Shdr *DotSymtabShndx)
- : ELFObjectFileBase(
- getELFType(ELFT::TargetEndianness == llvm::endianness::little,
- ELFT::Is64Bits),
- Object),
+ : ELFObjectFileBase(getELFType(ELFT::Endianness == llvm::endianness::little,
+ ELFT::Is64Bits),
+ Object),
EF(EF), DotDynSymSec(DotDynSymSec), DotSymtabSec(DotSymtabSec),
DotSymtabShndxSec(DotSymtabShndx) {}
@@ -1226,8 +1225,7 @@ uint8_t ELFObjectFile<ELFT>::getBytesInAddress() const {
template <class ELFT>
StringRef ELFObjectFile<ELFT>::getFileFormatName() const {
- constexpr bool IsLittleEndian =
- ELFT::TargetEndianness == llvm::endianness::little;
+ constexpr bool IsLittleEndian = ELFT::Endianness == llvm::endianness::little;
switch (EF.getHeader().e_ident[ELF::EI_CLASS]) {
case ELF::ELFCLASS32:
switch (EF.getHeader().e_machine) {
@@ -1305,7 +1303,7 @@ StringRef ELFObjectFile<ELFT>::getFileFormatName() const {
}
template <class ELFT> Triple::ArchType ELFObjectFile<ELFT>::getArch() const {
- bool IsLittleEndian = ELFT::TargetEndianness == llvm::endianness::little;
+ bool IsLittleEndian = ELFT::Endianness == llvm::endianness::little;
switch (EF.getHeader().e_machine) {
case ELF::EM_68K:
return Triple::m68k;
diff --git a/llvm/include/llvm/Object/ELFTypes.h b/llvm/include/llvm/Object/ELFTypes.h
index 4986ecf8323d02..4617b70a2f120a 100644
--- a/llvm/include/llvm/Object/ELFTypes.h
+++ b/llvm/include/llvm/Object/ELFTypes.h
@@ -52,6 +52,7 @@ template <endianness E, bool Is64> struct ELFType {
public:
static const endianness TargetEndianness = E;
+ static const endianness Endianness = E;
static const bool Is64Bits = Is64;
using uint = std::conditional_t<Is64, uint64_t, uint32_t>;
@@ -145,9 +146,9 @@ using ELF64BE = ELFType<llvm::endianness::big, true>;
// Section header.
template <class ELFT> struct Elf_Shdr_Base;
-template <endianness TargetEndianness>
-struct Elf_Shdr_Base<ELFType<TargetEndianness, false>> {
- LLVM_ELF_IMPORT_TYPES(TargetEndianness, false)
+template <endianness Endianness>
+struct Elf_Shdr_Base<ELFType<Endianness, false>> {
+ LLVM_ELF_IMPORT_TYPES(Endianness, false)
Elf_Word sh_name; // Section name (index into string table)
Elf_Word sh_type; // Section type (SHT_*)
Elf_Word sh_flags; // Section flags (SHF_*)
@@ -160,9 +161,9 @@ struct Elf_Shdr_Base<ELFType<TargetEndianness, false>> {
Elf_Word sh_entsize; // Size of records contained within the section
};
-template <endianness TargetEndianness>
-struct Elf_Shdr_Base<ELFType<TargetEndianness, true>> {
- LLVM_ELF_IMPORT_TYPES(TargetEndianness, true)
+template <endianness Endianness>
+struct Elf_Shdr_Base<ELFType<Endianness, true>> {
+ LLVM_ELF_IMPORT_TYPES(Endianness, true)
Elf_Word sh_name; // Section name (index into string table)
Elf_Word sh_type; // Section type (SHT_*)
Elf_Xword sh_flags; // Section flags (SHF_*)
@@ -190,9 +191,9 @@ struct Elf_Shdr_Impl : Elf_Shdr_Base<ELFT> {
template <class ELFT> struct Elf_Sym_Base;
-template <endianness TargetEndianness>
-struct Elf_Sym_Base<ELFType<TargetEndianness, false>> {
- LLVM_ELF_IMPORT_TYPES(TargetEndianness, false)
+template <endianness Endianness>
+struct Elf_Sym_Base<ELFType<Endianness, false>> {
+ LLVM_ELF_IMPORT_TYPES(Endianness, false)
Elf_Word st_name; // Symbol name (index into string table)
Elf_Addr st_value; // Value or address associated with the symbol
Elf_Word st_size; // Size of the symbol
@@ -201,9 +202,9 @@ struct Elf_Sym_Base<ELFType<TargetEndianness, false>> {
Elf_Half st_shndx; // Which section (header table index) it's defined in
};
-template <endianness TargetEndianness>
-struct Elf_Sym_Base<ELFType<TargetEndianness, true>> {
- LLVM_ELF_IMPORT_TYPES(TargetEndianness, true)
+template <endianness Endianness>
+struct Elf_Sym_Base<ELFType<Endianness, true>> {
+ LLVM_ELF_IMPORT_TYPES(Endianness, true)
Elf_Word st_name; // Symbol name (index into string table)
unsigned char st_info; // Symbol's type and binding attributes
unsigned char st_other; // Must be zero; reserved
@@ -349,9 +350,9 @@ struct Elf_Vernaux_Impl {
/// table section (.dynamic) look like.
template <class ELFT> struct Elf_Dyn_Base;
-template <endianness TargetEndianness>
-struct Elf_Dyn_Base<ELFType<TargetEndianness, false>> {
- LLVM_ELF_IMPORT_TYPES(TargetEndianness, false)
+template <endianness Endianness>
+struct Elf_Dyn_Base<ELFType<Endianness, false>> {
+ LLVM_ELF_IMPORT_TYPES(Endianness, false)
Elf_Sword d_tag;
union {
Elf_Word d_val;
@@ -359,9 +360,9 @@ struct Elf_Dyn_Base<ELFType<TargetEndianness, false>> {
} d_un;
};
-template <endianness TargetEndianness>
-struct Elf_Dyn_Base<ELFType<TargetEndianness, true>> {
- LLVM_ELF_IMPORT_TYPES(TargetEndianness, true)
+template <endianness Endianness>
+struct Elf_Dyn_Base<ELFType<Endianness, true>> {
+ LLVM_ELF_IMPORT_TYPES(Endianness, true)
Elf_Sxword d_tag;
union {
Elf_Xword d_val;
@@ -381,9 +382,9 @@ struct Elf_Dyn_Impl : Elf_Dyn_Base<ELFT> {
uintX_t getPtr() const { return d_un.d_ptr; }
};
-template <endianness TargetEndianness>
-struct Elf_Rel_Impl<ELFType<TargetEndianness, false>, false> {
- LLVM_ELF_IMPORT_TYPES(TargetEndianness, false)
+template <endianness Endianness>
+struct Elf_Rel_Impl<ELFType<Endianness, false>, false> {
+ LLVM_ELF_IMPORT_TYPES(Endianness, false)
static const bool IsRela = false;
Elf_Addr r_offset; // Location (file byte offset, or program virtual addr)
Elf_Word r_info; // Symbol table index and type of relocation to apply
@@ -416,17 +417,17 @@ struct Elf_Rel_Impl<ELFType<TargetEndianness, false>, false> {
}
};
-template <endianness TargetEndianness>
-struct Elf_Rel_Impl<ELFType<TargetEndianness, false>, true>
- : public Elf_Rel_Impl<ELFType<TargetEndianness, false>, false> {
- LLVM_ELF_IMPORT_TYPES(TargetEndianness, false)
+template <endianness Endianness>
+struct Elf_Rel_Impl<ELFType<Endianness, false>, true>
+ : public Elf_Rel_Impl<ELFType<Endianness, false>, false> {
+ LLVM_ELF_IMPORT_TYPES(Endianness, false)
static const bool IsRela = true;
Elf_Sword r_addend; // Compute value for relocatable field by adding this
};
-template <endianness TargetEndianness>
-struct Elf_Rel_Impl<ELFType<TargetEndianness, true>, false> {
- LLVM_ELF_IMPORT_TYPES(TargetEndianness, true)
+template <endianness Endianness>
+struct Elf_Rel_Impl<ELFType<Endianness, true>, false> {
+ LLVM_ELF_IMPORT_TYPES(Endianness, true)
static const bool IsRela = false;
Elf_Addr r_offset; // Location (file byte offset, or program virtual addr)
Elf_Xword r_info; // Symbol table index and type of relocation to apply
@@ -469,10 +470,10 @@ struct Elf_Rel_Impl<ELFType<TargetEndianness, true>, false> {
}
};
-template <endianness TargetEndianness>
-struct Elf_Rel_Impl<ELFType<TargetEndianness, true>, true>
- : public Elf_Rel_Impl<ELFType<TargetEndianness, true>, false> {
- LLVM_ELF_IMPORT_TYPES(TargetEndianness, true)
+template <endianness Endianness>
+struct Elf_Rel_Impl<ELFType<Endianness, true>, true>
+ : public Elf_Rel_Impl<ELFType<Endianness, true>, false> {
+ LLVM_ELF_IMPORT_TYPES(Endianness, true)
static const bool IsRela = true;
Elf_Sxword r_addend; // Compute value for relocatable field by adding this.
};
@@ -504,9 +505,9 @@ struct Elf_Ehdr_Impl {
unsigned char getDataEncoding() const { return e_ident[ELF::EI_DATA]; }
};
-template <endianness TargetEndianness>
-struct Elf_Phdr_Impl<ELFType<TargetEndianness, false>> {
- LLVM_ELF_IMPORT_TYPES(TargetEndianness, false)
+template <endianness Endianness>
+struct Elf_Phdr_Impl<ELFType<Endianness, false>> {
+ LLVM_ELF_IMPORT_TYPES(Endianness, false)
Elf_Word p_type; // Type of segment
Elf_Off p_offset; // FileOffset where segment is located, in bytes
Elf_Addr p_vaddr; // Virtual Address of beginning of segment
@@ -517,9 +518,9 @@ struct Elf_Phdr_Impl<ELFType<TargetEndianness, false>> {
Elf_Word p_align; // Segment alignment constraint
};
-template <endianness TargetEndianness>
-struct Elf_Phdr_Impl<ELFType<TargetEndianness, true>> {
- LLVM_ELF_IMPORT_TYPES(TargetEndianness, true)
+template <endianness Endianness>
+struct Elf_Phdr_Impl<ELFType<Endianness, true>> {
+ LLVM_ELF_IMPORT_TYPES(Endianness, true)
Elf_Word p_type; // Type of segment
Elf_Word p_flags; // Segment flags
Elf_Off p_offset; // FileOffset where segment is located, in bytes
@@ -574,17 +575,17 @@ struct Elf_GnuHash_Impl {
// Compressed section headers.
// http://www.sco.com/developers/gabi/latest/ch4.sheader.html#compression_header
-template <endianness TargetEndianness>
-struct Elf_Chdr_Impl<ELFType<TargetEndianness, false>> {
- LLVM_ELF_IMPORT_TYPES(TargetEndianness, false)
+template <endianness Endianness>
+struct Elf_Chdr_Impl<ELFType<Endianness, false>> {
+ LLVM_ELF_IMPORT_TYPES(Endianness, false)
Elf_Word ch_type;
Elf_Word ch_size;
Elf_Word ch_addralign;
};
-template <endianness TargetEndianness>
-struct Elf_Chdr_Impl<ELFType<TargetEndianness, true>> {
- LLVM_ELF_IMPORT_TYPES(TargetEndianness, true)
+template <endianness Endianness>
+struct Elf_Chdr_Impl<ELFType<Endianness, true>> {
+ LLVM_ELF_IMPORT_TYPES(Endianness, true)
Elf_Word ch_type;
Elf_Word ch_reserved;
Elf_Xword ch_size;
@@ -742,17 +743,17 @@ template <class ELFT> struct Elf_CGProfile_Impl {
template <class ELFT>
struct Elf_Mips_RegInfo;
-template <llvm::endianness TargetEndianness>
-struct Elf_Mips_RegInfo<ELFType<TargetEndianness, false>> {
- LLVM_ELF_IMPORT_TYPES(TargetEndianness, false)
+template <llvm::endianness Endianness>
+struct Elf_Mips_RegInfo<ELFType<Endianness, false>> {
+ LLVM_ELF_IMPORT_TYPES(Endianness, false)
Elf_Word ri_gprmask; // bit-mask of used general registers
Elf_Word ri_cprmask[4]; // bit-mask of used co-processor registers
Elf_Addr ri_gp_value; // gp register value
};
-template <llvm::endianness TargetEndianness>
-struct Elf_Mips_RegInfo<ELFType<TargetEndianness, true>> {
- LLVM_ELF_IMPORT_TYPES(TargetEndianness, true)
+template <llvm::endianness Endianness>
+struct Elf_Mips_RegInfo<ELFType<Endianness, true>> {
+ LLVM_ELF_IMPORT_TYPES(Endianness, true)
Elf_Word ri_gprmask; // bit-mask of used general registers
Elf_Word ri_pad; // unused padding field
Elf_Word ri_cprmask[4]; // bit-mask of used co-processor registers
diff --git a/llvm/lib/ExecutionEngine/JITLink/ELFLinkGraphBuilder.h b/llvm/lib/ExecutionEngine/JITLink/ELFLinkGraphBuilder.h
index e1b11dfcfc211a..5dae6006293957 100644
--- a/llvm/lib/ExecutionEngine/JITLink/ELFLinkGraphBuilder.h
+++ b/llvm/lib/ExecutionEngine/JITLink/ELFLinkGraphBuilder.h
@@ -193,7 +193,7 @@ ELFLinkGraphBuilder<ELFT>::ELFLinkGraphBuilder(
StringRef FileName, LinkGraph::GetEdgeKindNameFunction GetEdgeKindName)
: ELFLinkGraphBuilderBase(std::make_unique<LinkGraph>(
FileName.str(), Triple(std::move(TT)), std::move(Features),
- ELFT::Is64Bits ? 8 : 4, llvm::endianness(ELFT::TargetEndianness),
+ ELFT::Is64Bits ? 8 : 4, llvm::endianness(ELFT::Endianness),
std::move(GetEdgeKindName))),
Obj(Obj) {
LLVM_DEBUG(
diff --git a/llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp b/llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp
index 3952445bb1aa4b..670c8cf996fd61 100644
--- a/llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp
@@ -545,7 +545,7 @@ DLLImportDefinitionGenerator::getTargetPointerSize(const Triple &TT) {
}
Expected<llvm::endianness>
-DLLImportDefinitionGenerator::getTargetEndianness(const Triple &TT) {
+DLLImportDefinitionGenerator::getEndianness(const Triple &TT) {
switch (TT.getArch()) {
case Triple::x86_64:
return llvm::endianness::little;
@@ -562,7 +562,7 @@ DLLImportDefinitionGenerator::createStubsGraph(const SymbolMap &Resolved) {
auto PointerSize = getTargetPointerSize(TT);
if (!PointerSize)
return PointerSize.takeError();
- auto Endianness = getTargetEndianness(TT);
+ auto Endianness = getEndianness(TT);
if (!Endianness)
return Endianness.takeError();
diff --git a/llvm/lib/InterfaceStub/ELFObjHandler.cpp b/llvm/lib/InterfaceStub/ELFObjHandler.cpp
index c1256563d0d627..9c81a8832c0f2a 100644
--- a/llvm/lib/InterfaceStub/ELFObjHandler.cpp
+++ b/llvm/lib/InterfaceStub/ELFObjHandler.cpp
@@ -57,7 +57,7 @@ static void initELFHeader(typename ELFT::Ehdr &ElfHeader, uint16_t Machine) {
ElfHeader.e_ident[EI_MAG2] = ElfMagic[EI_MAG2];
ElfHeader.e_ident[EI_MAG3] = ElfMagic[EI_MAG3];
ElfHeader.e_ident[EI_CLASS] = ELFT::Is64Bits ? ELFCLASS64 : ELFCLASS32;
- bool IsLittleEndian = ELFT::TargetEndianness == llvm::endianness::little;
+ bool IsLittleEndian = ELFT::Endianness == llvm::endianness::little;
ElfHeader.e_ident[EI_DATA] = IsLittleEndian ? ELFDATA2LSB : ELFDATA2MSB;
ElfHeader.e_ident[EI_VERSION] = EV_CURRENT;
ElfHeader.e_ident[EI_OSABI] = ELFOSABI_NONE;
diff --git a/llvm/lib/ObjCopy/ELF/ELFObject.cpp b/llvm/lib/ObjCopy/ELF/ELFObject.cpp
index 9547cc10d2a0ba..8b6a0035dae356 100644
--- a/llvm/lib/ObjCopy/ELF/ELFObject.cpp
+++ b/llvm/lib/ObjCopy/ELF/ELFObject.cpp
@@ -33,6 +33,7 @@ using namespace llvm;
using namespace llvm::ELF;
using namespace llvm::objcopy::elf;
using namespace llvm::object;
+using namespace llvm::support;
template <class ELFT> void ELFWriter<ELFT>::writePhdr(const Segment &Seg) {
uint8_t *B = reinterpret_cast<uint8_t *>(Buf->getBufferStart()) +
@@ -1175,9 +1176,9 @@ template <class ELFT>
Error ELFSectionWriter<ELFT>::visit(const GroupSection &Sec) {
ELF::Elf32_Word *Buf =
reinterpret_cast<ELF::Elf32_Word *>(Out.getBufferStart() + Sec.Offset);
- support::endian::write32<ELFT::TargetEndianness>(Buf++, Sec.FlagWord);
+ endian::write32<ELFT::Endianness>(Buf++, Sec.FlagWord);
for (SectionBase *S : Sec.GroupMembers)
- support::endian::write32<ELFT::TargetEndianness>(Buf++, S->Index);
+ endian::write32<ELFT::Endianness>(Buf++, S->Index);
return Error::success();
}
@@ -1522,10 +1523,9 @@ Error ELFBuilder<ELFT>::initGroupSection(GroupSection *GroupSec) {
reinterpret_cast<const ELF::Elf32_Word *>(GroupSec->Contents.data());
const ELF::Elf32_Word *End =
Word + GroupSec->Contents.size() / sizeof(ELF::Elf32_Word);
- GroupSec->setFlagWord(
- support::endian::read32<ELFT::TargetEndianness>(Word++));
+ GroupSec->setFlagWord(endian::read32<ELFT::Endianness>(Word++));
for (; Word != End; ++Word) {
- uint32_t Index = support::endian::read32<ELFT::TargetEndianness>(Word);
+ uint32_t Index = support::endian::read32<ELFT::Endianness>(Word);
Expected<SectionBase *> Sec = SecTable.getSection(
Index, "group member index " + Twine(Index) + " in section '" +
GroupSec->Name + "' is invalid");
@@ -1993,9 +1993,8 @@ template <class ELFT> void ELFWriter<ELFT>::writeEhdr() {
Ehdr.e_ident[EI_MAG2] = 'L';
Ehdr.e_ident[EI_MAG3] = 'F';
Ehdr.e_ident[EI_CLASS] = ELFT::Is64Bits ? ELFCLASS64 : ELFCLASS32;
- Ehdr.e_ident[EI_DATA] = ELFT::TargetEndianness == llvm::endianness::big
- ? ELFDATA2MSB
- : ELFDATA2LSB;
+ Ehdr.e_ident[EI_DATA] =
+ ELFT::Endianness == llvm::endianness::big ? ELFDATA2MSB : ELFDATA2LSB;
Ehdr.e_ident[EI_VERSION] = EV_CURRENT;
Ehdr.e_ident[EI_OSABI] = Obj.OSABI;
Ehdr.e_ident[EI_ABIVERSION] = Obj.ABIVersion;
diff --git a/llvm/lib/ObjectYAML/ELFEmitter.cpp b/llvm/lib/ObjectYAML/ELFEmitter.cpp
index 58a725f8d87788..b7118a543faed3 100644
--- a/llvm/lib/ObjectYAML/ELFEmitter.cpp
+++ b/llvm/lib/ObjectYAML/ELFEmitter.cpp
@@ -1314,7 +1314,7 @@ void ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader,
if (!ELFT::Is64Bits && E > UINT32_MAX)
reportError(Section.Name + ": the value is too large for 32-bits: 0x" +
Twine::utohexstr(E));
- CBA.write<uintX_t>(E, ELFT::TargetEndianness);
+ CBA.write<uintX_t>(E, ELFT::Endianness);
}
SHeader.sh_size = sizeof(uintX_t) * Section.Entries->size();
@@ -1333,7 +1333,7 @@ void ELFState<ELFT>::writeSectionContent(
return;
for (uint32_t E : *Shndx.Entries)
- CBA.write<uint32_t>(E, ELFT::TargetEndianness);
+ CBA.write<uint32_t>(E, ELFT::Endianness);
SHeader.sh_size = Shndx.Entries->size() * SHeader.sh_entsize;
}
@@ -1357,7 +1357,7 @@ void ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader,
SectionIndex = llvm::ELF::GRP_COMDAT;
else
SectionIndex = toSectionIndex(Member.sectionNameOrType, Section.Name);
- CBA.write<uint32_t>(SectionIndex, ELFT::TargetEndianness);
+ CBA.write<uint32_t>(SectionIndex, ELFT::Endianness);
}
SHeader.sh_size = SHeader.sh_entsize * Section.Members->size();
}
@@ -1370,7 +1370,7 @@ void ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader,
return;
for (uint16_t Version : *Section.Entries)
- CBA.write<uint16_t>(Version, ELFT::TargetEndianness);
+ CBA.write<uint16_t>(Version, ELFT::Endianness);
SHeader.sh_size = Section.Entries->size() * SHeader.sh_entsize;
}
@@ -1382,7 +1382,7 @@ void ELFState<ELFT>::writeSectionContent(
return;
for (const ELFYAML::StackSizeEntry &E : *Section.Entries) {
- CBA.write<uintX_t>(E.Address, ELFT::TargetEndianness);
+ CBA.write<uintX_t>(E.Address, ELFT::Endianness);
SHeader.sh_size += sizeof(uintX_t) + CBA.writeULEB128(E.Size);
}
}
@@ -1444,7 +1444,7 @@ void ELFState<ELFT>::writeSectionContent(
uint64_t TotalNumBlocks = 0;
for (const ELFYAML::BBAddrMapEntry::BBRangeEntry &BBR : *E.BBRanges) {
// Write the base address of the range.
- CBA.write<uintX_t>(BBR.BaseAddress, ELFT::TargetEndianness);
+ CBA.write<uintX_t>(BBR.BaseAddress, ELFT::Endianness);
// Write number of BBEntries (number of basic blocks in this basic block
// range). This is overridden by the 'NumBlocks' YAML field when
// specified.
@@ -1558,7 +1558,7 @@ void ELFState<ELFT>::writeSectionContent(
return;
for (const ELFYAML::CallGraphEntryWeight &E : *Section.Entries) {
- CBA.write<uint64_t>(E.Weight, ELFT::TargetEndianness);
+ CBA.write<uint64_t>(E.Weight, ELFT::Endianness);
SHeader.sh_size += sizeof(object::Elf_CGProfile_Impl<ELFT>);
}
}
@@ -1572,15 +1572,15 @@ void ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader,
CBA.write<uint32_t>(
Section.NBucket.value_or(llvm::yaml::Hex64(Section.Bucket->size())),
- ELFT::TargetEndianness);
+ ELFT::Endianness);
CBA.write<uint32_t>(
Section.NChain.value_or(llvm::yaml::Hex64(Section.Chain->size())),
- ELFT::TargetEndianness);
+ ELFT::Endianness);
for (uint32_t Val : *Section.Bucket)
- CBA.write<uint32_t>(Val, ELFT::TargetEndianness);
+ CBA.write<uint32_t>(Val, ELFT::Endianness);
for (uint32_t Val : *Section.Chain)
- CBA.write<uint32_t>(Val, ELFT::TargetEndianness);
+ CBA.write<uint32_t>(Val, ELFT::Endianness);
SHeader.sh_size = (2 + Section.Bucket->size() + Section.Chain->size()) * 4;
}
@@ -1687,8 +1687,8 @@ void ELFState<ELFT>::writeSectionContent(
return;
for (const ELFYAML::ARMIndexTableEntry &E : *Section.Entries) {
- CBA.write<uint32_t>(E.Offset, ELFT::TargetEndianness);
- CBA.write<uint32_t>(E.Value, ELFT::TargetEndianness);
+ CBA.write<uint32_t>(E.Offset, ELFT::Endianness);
+ CBA.write<uint32_t>(E.Value, ELFT::Endianness);
}
SHeader.sh_size = Section.Entries->size() * 8;
}
@@ -1729,8 +1729,8 @@ void ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader,
return;
for (const ELFYAML::DynamicEntry &DE : *Section.Entries) {
- CBA.write<uintX_t>(DE.Tag, ELFT::TargetEndianness);
- CBA.write<uintX_t>(DE.Val, ELFT::TargetEndianness);
+ CBA.write<uintX_t>(DE.Tag, ELFT::Endianness);
+ CBA.write<uintX_t>(DE.Val, ELFT::Endianness);
}
SHeader.sh_size = 2 * sizeof(uintX_t) * Section.Entries->size();
}
@@ -1758,18 +1758,18 @@ void ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader,
for (const ELFYAML::NoteEntry &NE : *Section.Notes) {
// Write name size.
if (NE.Name.empty())
- CBA.write<uint32_t>(0, ELFT::TargetEndianness);
+ CBA.write<uint32_t>(0, ELFT::Endianness);
else
- CBA.write<uint32_t>(NE.Name.size() + 1, ELFT::TargetEndianness);
+ CBA.write<uint32_t>(NE.Name.size() + 1, ELFT::Endianness);
// Write description size.
if (NE.Desc.binary_size() == 0)
- CBA.write<uint32_t>(0, ELFT::TargetEndianness);
+ CBA.write<uint32_t>(0, ELFT::Endianness);
else
- CBA.write<uint32_t>(NE.Desc.binary_size(), ELFT::TargetEndianness);
+ CBA.write<uint32_t>(NE.Desc.binary_size(), ELFT::Endianness);
// Write type.
- CBA.write<uint32_t>(NE.Type, ELFT::TargetEndianness);
+ CBA.write<uint32_t>(NE.Type, ELFT::Endianness);
// Write name, null terminator and padding.
if (!NE.Name.empty()) {
@@ -1803,35 +1803,35 @@ void ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader,
// be used to override this field, which is useful for producing broken
// objects.
if (Section.Header->NBuckets)
- CBA.write<uint32_t>(*Section.Header->NBuckets, ELFT::TargetEndianness);
+ CBA.write<uint32_t>(*Section.Header->NBuckets, ELFT::Endianness);
else
- CBA.write<uint32_t>(Section.HashBuckets->size(), ELFT::TargetEndianness);
+ CBA.write<uint32_t>(Section.HashBuckets->size(), ELFT::Endianness);
// Write the index of the first symbol in the dynamic symbol table accessible
// via the hash table.
- CBA.write<uint32_t>(Section.Header->SymNdx, ELFT::TargetEndianness);
+ CBA.write<uint32_t>(Section.Header->SymNdx, ELFT::Endianness);
// Write the number of words in the Bloom filter. As above, the "MaskWords"
// property can be used to set this field to any value.
if (Section.Header->MaskWords)
- CBA.write<uint32_t>(*Section.Header->MaskWords, ELFT::TargetEndianness);
+ CBA.write<uint32_t>(*Section.Header->MaskWords, ELFT::Endianness);
else
- CBA.write<uint32_t>(Section.BloomFilter->size(), ELFT::TargetEndianness);
+ CBA.write<uint32_t>(Section.BloomFilter->size(), ELFT::Endianness);
// Write the shift constant used by the Bloom filter.
- CBA.write<uint32_t>(Section.Header->Shift2, ELFT::TargetEndianness);
+ CBA.write<uint32_t>(Section.Header->Shift2, ELFT::Endianness);
// We've finished writing the header. Now write the Bloom filter.
for (llvm::yaml::Hex64 Val : *Section.BloomFilter)
- CBA.write<uintX_t>(Val, ELFT::TargetEndianness);
+ CBA.write<uintX_t>(Val, ELFT::Endianness);
// Write an array of hash buckets.
for (llvm::yaml::Hex32 Val : *Section.HashBuckets)
- CBA.write<uint32_t>(Val, ELFT::TargetEndianness);
+ CBA.write<uint32_t>(Val, ELFT::Endianness);
// Write an array of hash values.
for (llvm::yaml::Hex32 Val : *Section.HashValues)
- CBA.write<uint32_t>(Val, ELFT::TargetEndianness);
+ CBA.write<uint32_t>(Val, ELFT::Endianness);
SHeader.sh_size = 16 /*Header size*/ +
Section.BloomFilter->size() * sizeof(typename ELFT::uint) +
diff --git a/llvm/tools/llvm-readobj/DwarfCFIEHPrinter.h b/llvm/tools/llvm-readobj/DwarfCFIEHPrinter.h
index 2e89463e68d519..94a44e3afccb43 100644
--- a/llvm/tools/llvm-readobj/DwarfCFIEHPrinter.h
+++ b/llvm/tools/llvm-readobj/DwarfCFIEHPrinter.h
@@ -113,7 +113,7 @@ void PrinterContext<ELFT>::printEHFrameHdr(const Elf_Phdr *EHFramePHdr) const {
if (!Content)
reportError(Content.takeError(), ObjF.getFileName());
- DataExtractor DE(*Content, ELFT::TargetEndianness == llvm::endianness::little,
+ DataExtractor DE(*Content, ELFT::Endianness == llvm::endianness::little,
ELFT::Is64Bits ? 8 : 4);
DictScope D(W, "Header");
@@ -186,10 +186,9 @@ void PrinterContext<ELFT>::printEHFrame(const Elf_Shdr *EHFrameShdr) const {
// Construct DWARFDataExtractor to handle relocations ("PC Begin" fields).
std::unique_ptr<DWARFContext> DICtx = DWARFContext::create(
ObjF, DWARFContext::ProcessDebugRelocations::Process, nullptr);
- DWARFDataExtractor DE(DICtx->getDWARFObj(),
- DICtx->getDWARFObj().getEHFrameSection(),
- ELFT::TargetEndianness == llvm::endianness::little,
- ELFT::Is64Bits ? 8 : 4);
+ DWARFDataExtractor DE(
+ DICtx->getDWARFObj(), DICtx->getDWARFObj().getEHFrameSection(),
+ ELFT::Endianness == llvm::endianness::little, ELFT::Is64Bits ? 8 : 4);
DWARFDebugFrame EHFrame(Triple::ArchType(ObjF.getArch()), /*IsEH=*/true,
/*EHFrameAddress=*/Address);
if (Error E = EHFrame.parse(DE))
diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp
index d1c05f437042de..4b406ef12aecfe 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -74,6 +74,7 @@
using namespace llvm;
using namespace llvm::object;
+using namespace llvm::support;
using namespace ELF;
#define LLVM_READOBJ_ENUM_CASE(ns, enum) \
@@ -3419,13 +3420,13 @@ template <class ELFT> void ELFDumper<ELFT>::printStackMap() const {
return;
}
- if (Error E = StackMapParser<ELFT::TargetEndianness>::validateHeader(
- *ContentOrErr)) {
+ if (Error E =
+ StackMapParser<ELFT::Endianness>::validateHeader(*ContentOrErr)) {
Warn(std::move(E));
return;
}
- prettyPrintStackMap(W, StackMapParser<ELFT::TargetEndianness>(*ContentOrErr));
+ prettyPrintStackMap(W, StackMapParser<ELFT::Endianness>(*ContentOrErr));
}
template <class ELFT>
@@ -5145,7 +5146,7 @@ static std::string getGNUProperty(uint32_t Type, uint32_t DataSize,
OS << format("<corrupt length: 0x%x>", DataSize);
return OS.str();
}
- PrData = support::endian::read32<ELFT::TargetEndianness>(Data.data());
+ PrData = endian::read32<ELFT::Endianness>(Data.data());
if (PrData == 0) {
OS << "<None>";
return OS.str();
@@ -5169,7 +5170,7 @@ static std::string getGNUProperty(uint32_t Type, uint32_t DataSize,
OS << format("<corrupt length: 0x%x>", DataSize);
return OS.str();
}
- PrData = support::endian::read32<ELFT::TargetEndianness>(Data.data());
+ PrData = endian::read32<ELFT::Endianness>(Data.data());
if (PrData == 0) {
OS << "<None>";
return OS.str();
@@ -5195,7 +5196,7 @@ static std::string getGNUProperty(uint32_t Type, uint32_t DataSize,
OS << format("<corrupt length: 0x%x>", DataSize);
return OS.str();
}
- PrData = support::endian::read32<ELFT::TargetEndianness>(Data.data());
+ PrData = endian::read32<ELFT::Endianness>(Data.data());
if (PrData == 0) {
OS << "<None>";
return OS.str();
@@ -5374,10 +5375,8 @@ static bool printAArch64Note(raw_ostream &OS, uint32_t NoteType,
return false;
}
- uint64_t Platform =
- support::endian::read64<ELFT::TargetEndianness>(Desc.data() + 0);
- uint64_t Version =
- support::endian::read64<ELFT::TargetEndianness>(Desc.data() + 8);
+ uint64_t Platform = endian::read64<ELFT::Endianness>(Desc.data() + 0);
+ uint64_t Version = endian::read64<ELFT::Endianness>(Desc.data() + 8);
OS << format("platform 0x%" PRIx64 ", version 0x%" PRIx64, Platform, Version);
if (Desc.size() > 16)
@@ -5457,16 +5456,14 @@ getFreeBSDNote(uint32_t NoteType, ArrayRef<uint8_t> Desc, bool IsCore) {
case ELF::NT_FREEBSD_ABI_TAG:
if (Desc.size() != 4)
return std::nullopt;
- return FreeBSDNote{
- "ABI tag",
- utostr(support::endian::read32<ELFT::TargetEndianness>(Desc.data()))};
+ return FreeBSDNote{"ABI tag",
+ utostr(endian::read32<ELFT::Endianness>(Desc.data()))};
case ELF::NT_FREEBSD_ARCH_TAG:
return FreeBSDNote{"Arch tag", toStringRef(Desc).str()};
case ELF::NT_FREEBSD_FEATURE_CTL: {
if (Desc.size() != 4)
return std::nullopt;
- unsigned Value =
- support::endian::read32<ELFT::TargetEndianness>(Desc.data());
+ unsigned Value = endian::read32<ELFT::Endianness>(Desc.data());
std::string FlagsStr;
raw_string_ostream OS(FlagsStr);
printFlags(Value, ArrayRef(FreeBSDFeatureCtlFlags), OS);
@@ -6053,7 +6050,7 @@ template <class ELFT> void GNUELFDumper<ELFT>::printNotes() {
} else if (Name == "CORE") {
if (Type == ELF::NT_FILE) {
DataExtractor DescExtractor(
- Descriptor, ELFT::TargetEndianness == llvm::endianness::little,
+ Descriptor, ELFT::Endianness == llvm::endianness::little,
sizeof(Elf_Addr));
if (Expected<CoreNote> NoteOrErr = readCoreNote(DescExtractor)) {
printCoreNote<ELFT>(OS, *NoteOrErr);
@@ -7714,10 +7711,8 @@ static bool printAarch64NoteLLVMStyle(uint32_t NoteType, ArrayRef<uint8_t> Desc,
if (Desc.size() < 16)
return false;
- uint64_t platform =
- support::endian::read64<ELFT::TargetEndianness>(Desc.data() + 0);
- uint64_t version =
- support::endian::read64<ELFT::TargetEndianness>(Desc.data() + 8);
+ uint64_t platform = endian::read64<ELFT::Endianness>(Desc.data() + 0);
+ uint64_t version = endian::read64<ELFT::Endianness>(Desc.data() + 8);
W.printNumber("Platform", platform);
W.printNumber("Version", version);
@@ -7852,7 +7847,7 @@ template <class ELFT> void LLVMELFDumper<ELFT>::printNotes() {
} else if (Name == "CORE") {
if (Type == ELF::NT_FILE) {
DataExtractor DescExtractor(
- Descriptor, ELFT::TargetEndianness == llvm::endianness::little,
+ Descriptor, ELFT::Endianness == llvm::endianness::little,
sizeof(Elf_Addr));
if (Expected<CoreNote> N = readCoreNote(DescExtractor)) {
printCoreNoteLLVMStyle(*N, W);
More information about the llvm-commits
mailing list