aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/llvm/lib/MC/ELFObjectWriter.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2023-12-18 20:30:12 +0000
committerDimitry Andric <dim@FreeBSD.org>2024-04-19 21:12:03 +0000
commitc9157d925c489f07ba9c0b2ce47e5149b75969a5 (patch)
tree08bc4a3d9cad3f9ebffa558ddf140b9d9257b219 /contrib/llvm-project/llvm/lib/MC/ELFObjectWriter.cpp
parent2a66844f606a35d68ad8a8061f4bea204274b3bc (diff)
Diffstat (limited to 'contrib/llvm-project/llvm/lib/MC/ELFObjectWriter.cpp')
-rw-r--r--contrib/llvm-project/llvm/lib/MC/ELFObjectWriter.cpp33
1 files changed, 17 insertions, 16 deletions
diff --git a/contrib/llvm-project/llvm/lib/MC/ELFObjectWriter.cpp b/contrib/llvm-project/llvm/lib/MC/ELFObjectWriter.cpp
index 6a6befdd3054..cb8af1aa9955 100644
--- a/contrib/llvm-project/llvm/lib/MC/ELFObjectWriter.cpp
+++ b/contrib/llvm-project/llvm/lib/MC/ELFObjectWriter.cpp
@@ -72,7 +72,7 @@ class ELFObjectWriter;
struct ELFWriter;
bool isDwoSection(const MCSectionELF &Sec) {
- return Sec.getName().endswith(".dwo");
+ return Sec.getName().ends_with(".dwo");
}
class SymbolTableWriter {
@@ -152,8 +152,9 @@ struct ELFWriter {
public:
ELFWriter(ELFObjectWriter &OWriter, raw_pwrite_stream &OS,
bool IsLittleEndian, DwoMode Mode)
- : OWriter(OWriter),
- W(OS, IsLittleEndian ? support::little : support::big), Mode(Mode) {}
+ : OWriter(OWriter), W(OS, IsLittleEndian ? llvm::endianness::little
+ : llvm::endianness::big),
+ Mode(Mode) {}
void WriteWord(uint64_t Word) {
if (is64Bit())
@@ -227,8 +228,7 @@ class ELFObjectWriter : public MCObjectWriter {
bool hasRelocationAddend() const;
- bool shouldRelocateWithSymbol(const MCAssembler &Asm,
- const MCSymbolRefExpr *RefA,
+ bool shouldRelocateWithSymbol(const MCAssembler &Asm, const MCValue &Val,
const MCSymbolELF *Sym, uint64_t C,
unsigned Type) const;
@@ -407,8 +407,8 @@ void ELFWriter::writeHeader(const MCAssembler &Asm) {
W.OS << char(is64Bit() ? ELF::ELFCLASS64 : ELF::ELFCLASS32); // e_ident[EI_CLASS]
// e_ident[EI_DATA]
- W.OS << char(W.Endian == support::little ? ELF::ELFDATA2LSB
- : ELF::ELFDATA2MSB);
+ W.OS << char(W.Endian == llvm::endianness::little ? ELF::ELFDATA2LSB
+ : ELF::ELFDATA2MSB);
W.OS << char(ELF::EV_CURRENT); // e_ident[EI_VERSION]
// e_ident[EI_OSABI]
@@ -843,7 +843,7 @@ bool ELFWriter::maybeWriteCompression(
uint32_t ChType, uint64_t Size,
SmallVectorImpl<uint8_t> &CompressedContents, Align Alignment) {
uint64_t HdrSize =
- is64Bit() ? sizeof(ELF::Elf32_Chdr) : sizeof(ELF::Elf64_Chdr);
+ is64Bit() ? sizeof(ELF::Elf64_Chdr) : sizeof(ELF::Elf32_Chdr);
if (Size <= HdrSize + CompressedContents.size())
return false;
// Platform specific header is followed by compressed data.
@@ -872,7 +872,7 @@ void ELFWriter::writeSectionData(const MCAssembler &Asm, MCSection &Sec,
const DebugCompressionType CompressionType = MAI->compressDebugSections();
if (CompressionType == DebugCompressionType::None ||
- !SectionName.startswith(".debug_")) {
+ !SectionName.starts_with(".debug_")) {
Asm.writeSectionData(W.OS, &Section, Layout);
return;
}
@@ -1250,7 +1250,7 @@ void ELFObjectWriter::executePostLayoutBinding(MCAssembler &Asm,
StringRef Prefix = AliasName.substr(0, Pos);
StringRef Rest = AliasName.substr(Pos);
StringRef Tail = Rest;
- if (Rest.startswith("@@@"))
+ if (Rest.starts_with("@@@"))
Tail = Rest.substr(Symbol.isUndefined() ? 2 : 1);
auto *Alias =
@@ -1268,8 +1268,8 @@ void ELFObjectWriter::executePostLayoutBinding(MCAssembler &Asm,
if (!Symbol.isUndefined() && S.KeepOriginalSym)
continue;
- if (Symbol.isUndefined() && Rest.startswith("@@") &&
- !Rest.startswith("@@@")) {
+ if (Symbol.isUndefined() && Rest.starts_with("@@") &&
+ !Rest.starts_with("@@@")) {
Asm.getContext().reportError(S.Loc, "default version symbol " +
AliasName + " must be defined");
continue;
@@ -1287,7 +1287,7 @@ void ELFObjectWriter::executePostLayoutBinding(MCAssembler &Asm,
for (const MCSymbol *&Sym : AddrsigSyms) {
if (const MCSymbol *R = Renames.lookup(cast<MCSymbolELF>(Sym)))
Sym = R;
- if (Sym->isInSection() && Sym->getName().startswith(".L"))
+ if (Sym->isInSection() && Sym->getName().starts_with(".L"))
Sym = Sym->getSection().getBeginSymbol();
Sym->setUsedInReloc();
}
@@ -1297,10 +1297,11 @@ void ELFObjectWriter::executePostLayoutBinding(MCAssembler &Asm,
// to use a relocation with a section if that is possible. Using the section
// allows us to omit some local symbols from the symbol table.
bool ELFObjectWriter::shouldRelocateWithSymbol(const MCAssembler &Asm,
- const MCSymbolRefExpr *RefA,
+ const MCValue &Val,
const MCSymbolELF *Sym,
uint64_t C,
unsigned Type) const {
+ const MCSymbolRefExpr *RefA = Val.getSymA();
// A PCRel relocation to an absolute value has no symbol (or section). We
// represent that with a relocation to a null section.
if (!RefA)
@@ -1419,7 +1420,7 @@ bool ELFObjectWriter::shouldRelocateWithSymbol(const MCAssembler &Asm,
if (Asm.isThumbFunc(Sym))
return true;
- if (TargetObjectWriter->needsRelocateWithSymbol(*Sym, Type))
+ if (TargetObjectWriter->needsRelocateWithSymbol(Val, *Sym, Type))
return true;
return false;
}
@@ -1484,7 +1485,7 @@ void ELFObjectWriter::recordRelocation(MCAssembler &Asm,
const auto *Parent = cast<MCSectionELF>(Fragment->getParent());
// Emiting relocation with sybmol for CG Profile to help with --cg-profile.
bool RelocateWithSymbol =
- shouldRelocateWithSymbol(Asm, RefA, SymA, C, Type) ||
+ shouldRelocateWithSymbol(Asm, Target, SymA, C, Type) ||
(Parent->getType() == ELF::SHT_LLVM_CALL_GRAPH_PROFILE);
uint64_t Addend = 0;