-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[NFC][ELF] Rename some ELFWriter methods #109332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
More consistent casing + more accurate names.
@llvm/pr-subscribers-mc Author: Arthur Eubanks (aeubanks) ChangesMore consistent casing + more accurate names. Full diff: https://github.com/llvm/llvm-project/pull/109332.diff 1 Files Affected:
diff --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp
index 62a4b5347f8299..8127091ad37627 100644
--- a/llvm/lib/MC/ELFObjectWriter.cpp
+++ b/llvm/lib/MC/ELFObjectWriter.cpp
@@ -167,7 +167,7 @@ struct ELFWriter {
: llvm::endianness::big),
Mode(Mode) {}
- void WriteWord(uint64_t Word) {
+ void writeWord(uint64_t Word) {
if (is64Bit())
W.write<uint64_t>(Word);
else
@@ -197,20 +197,20 @@ struct ELFWriter {
MCSectionELF *createRelocationSection(MCContext &Ctx,
const MCSectionELF &Sec);
- void writeSectionHeader(const MCAssembler &Asm);
+ void writeSectionHeaders(const MCAssembler &Asm);
void writeSectionData(const MCAssembler &Asm, MCSection &Sec);
- void WriteSecHdrEntry(uint32_t Name, uint32_t Type, uint64_t Flags,
- uint64_t Address, uint64_t Offset, uint64_t Size,
- uint32_t Link, uint32_t Info, MaybeAlign Alignment,
- uint64_t EntrySize);
+ void writeSectionHeaderEntry(uint32_t Name, uint32_t Type, uint64_t Flags,
+ uint64_t Address, uint64_t Offset, uint64_t Size,
+ uint32_t Link, uint32_t Info,
+ MaybeAlign Alignment, uint64_t EntrySize);
void writeRelocations(const MCAssembler &Asm, const MCSectionELF &Sec);
uint64_t writeObject(MCAssembler &Asm);
- void writeSection(uint32_t GroupSymbolIndex, uint64_t Offset, uint64_t Size,
- const MCSectionELF &Section);
+ void writeSectionHeader(uint32_t GroupSymbolIndex, uint64_t Offset,
+ uint64_t Size, const MCSectionELF &Section);
};
} // end anonymous namespace
@@ -317,9 +317,9 @@ void ELFWriter::writeHeader(const MCAssembler &Asm) {
W.write<uint16_t>(OWriter.TargetObjectWriter->getEMachine()); // e_machine = target
W.write<uint32_t>(ELF::EV_CURRENT); // e_version
- WriteWord(0); // e_entry, no entry point in .o file
- WriteWord(0); // e_phoff, no program header for .o
- WriteWord(0); // e_shoff = sec hdr table off in bytes
+ writeWord(0); // e_entry, no entry point in .o file
+ writeWord(0); // e_phoff, no program header for .o
+ writeWord(0); // e_shoff = sec hdr table off in bytes
// e_flags = whatever the target wants
W.write<uint32_t>(OWriter.getELFHeaderEFlags());
@@ -791,20 +791,22 @@ void ELFWriter::writeSectionData(const MCAssembler &Asm, MCSection &Sec) {
W.OS << toStringRef(Compressed);
}
-void ELFWriter::WriteSecHdrEntry(uint32_t Name, uint32_t Type, uint64_t Flags,
- uint64_t Address, uint64_t Offset,
- uint64_t Size, uint32_t Link, uint32_t Info,
- MaybeAlign Alignment, uint64_t EntrySize) {
+void ELFWriter::writeSectionHeaderEntry(uint32_t Name, uint32_t Type,
+ uint64_t Flags, uint64_t Address,
+ uint64_t Offset, uint64_t Size,
+ uint32_t Link, uint32_t Info,
+ MaybeAlign Alignment,
+ uint64_t EntrySize) {
W.write<uint32_t>(Name); // sh_name: index into string table
W.write<uint32_t>(Type); // sh_type
- WriteWord(Flags); // sh_flags
- WriteWord(Address); // sh_addr
- WriteWord(Offset); // sh_offset
- WriteWord(Size); // sh_size
+ writeWord(Flags); // sh_flags
+ writeWord(Address); // sh_addr
+ writeWord(Offset); // sh_offset
+ writeWord(Size); // sh_size
W.write<uint32_t>(Link); // sh_link
W.write<uint32_t>(Info); // sh_info
- WriteWord(Alignment ? Alignment->value() : 0); // sh_addralign
- WriteWord(EntrySize); // sh_entsize
+ writeWord(Alignment ? Alignment->value() : 0); // sh_addralign
+ writeWord(EntrySize); // sh_entsize
}
template <bool Is64>
@@ -888,8 +890,8 @@ void ELFWriter::writeRelocations(const MCAssembler &Asm,
}
}
-void ELFWriter::writeSection(uint32_t GroupSymbolIndex, uint64_t Offset,
- uint64_t Size, const MCSectionELF &Section) {
+void ELFWriter::writeSectionHeader(uint32_t GroupSymbolIndex, uint64_t Offset,
+ uint64_t Size, const MCSectionELF &Section) {
uint64_t sh_link = 0;
uint64_t sh_info = 0;
@@ -936,19 +938,20 @@ void ELFWriter::writeSection(uint32_t GroupSymbolIndex, uint64_t Offset,
sh_link = Sym->getSection().getOrdinal();
}
- WriteSecHdrEntry(StrTabBuilder.getOffset(Section.getName()),
- Section.getType(), Section.getFlags(), 0, Offset, Size,
- sh_link, sh_info, Section.getAlign(),
- Section.getEntrySize());
+ writeSectionHeaderEntry(StrTabBuilder.getOffset(Section.getName()),
+ Section.getType(), Section.getFlags(), 0, Offset,
+ Size, sh_link, sh_info, Section.getAlign(),
+ Section.getEntrySize());
}
-void ELFWriter::writeSectionHeader(const MCAssembler &Asm) {
+void ELFWriter::writeSectionHeaders(const MCAssembler &Asm) {
const unsigned NumSections = SectionTable.size();
// Null section first.
uint64_t FirstSectionSize =
(NumSections + 1) >= ELF::SHN_LORESERVE ? NumSections + 1 : 0;
- WriteSecHdrEntry(0, 0, 0, 0, 0, FirstSectionSize, 0, 0, std::nullopt, 0);
+ writeSectionHeaderEntry(0, 0, 0, 0, 0, FirstSectionSize, 0, 0, std::nullopt,
+ 0);
for (const MCSectionELF *Section : SectionTable) {
uint32_t GroupSymbolIndex;
@@ -1003,7 +1006,7 @@ void ELFWriter::writeSectionHeader(const MCAssembler &Asm) {
}
}
- writeSection(GroupSymbolIndex, Offsets.first, Size, *Section);
+ writeSectionHeader(GroupSymbolIndex, Offsets.first, Size, *Section);
}
}
@@ -1126,7 +1129,7 @@ uint64_t ELFWriter::writeObject(MCAssembler &Asm) {
const uint64_t SectionHeaderOffset = align(is64Bit() ? Align(8) : Align(4));
// ... then the section header table ...
- writeSectionHeader(Asm);
+ writeSectionHeaders(Asm);
uint16_t NumSections = support::endian::byte_swap<uint16_t>(
(SectionTable.size() + 1 >= ELF::SHN_LORESERVE) ? (uint16_t)ELF::SHN_UNDEF
|
MaskRay
approved these changes
Sep 19, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
More consistent casing + more accurate names.