@@ -167,7 +167,7 @@ struct ELFWriter {
167
167
: llvm::endianness::big),
168
168
Mode (Mode) {}
169
169
170
- void WriteWord (uint64_t Word) {
170
+ void writeWord (uint64_t Word) {
171
171
if (is64Bit ())
172
172
W.write <uint64_t >(Word);
173
173
else
@@ -197,20 +197,20 @@ struct ELFWriter {
197
197
MCSectionELF *createRelocationSection (MCContext &Ctx,
198
198
const MCSectionELF &Sec);
199
199
200
- void writeSectionHeader (const MCAssembler &Asm);
200
+ void writeSectionHeaders (const MCAssembler &Asm);
201
201
202
202
void writeSectionData (const MCAssembler &Asm, MCSection &Sec);
203
203
204
- void WriteSecHdrEntry (uint32_t Name, uint32_t Type, uint64_t Flags,
205
- uint64_t Address, uint64_t Offset, uint64_t Size,
206
- uint32_t Link, uint32_t Info, MaybeAlign Alignment ,
207
- uint64_t EntrySize);
204
+ void writeSectionHeaderEntry (uint32_t Name, uint32_t Type, uint64_t Flags,
205
+ uint64_t Address, uint64_t Offset, uint64_t Size,
206
+ uint32_t Link, uint32_t Info,
207
+ MaybeAlign Alignment, uint64_t EntrySize);
208
208
209
209
void writeRelocations (const MCAssembler &Asm, const MCSectionELF &Sec);
210
210
211
211
uint64_t writeObject (MCAssembler &Asm);
212
- void writeSection (uint32_t GroupSymbolIndex, uint64_t Offset, uint64_t Size ,
213
- const MCSectionELF &Section);
212
+ void writeSectionHeader (uint32_t GroupSymbolIndex, uint64_t Offset,
213
+ uint64_t Size, const MCSectionELF &Section);
214
214
};
215
215
} // end anonymous namespace
216
216
@@ -317,9 +317,9 @@ void ELFWriter::writeHeader(const MCAssembler &Asm) {
317
317
W.write <uint16_t >(OWriter.TargetObjectWriter ->getEMachine ()); // e_machine = target
318
318
319
319
W.write <uint32_t >(ELF::EV_CURRENT); // e_version
320
- WriteWord (0 ); // e_entry, no entry point in .o file
321
- WriteWord (0 ); // e_phoff, no program header for .o
322
- WriteWord (0 ); // e_shoff = sec hdr table off in bytes
320
+ writeWord (0 ); // e_entry, no entry point in .o file
321
+ writeWord (0 ); // e_phoff, no program header for .o
322
+ writeWord (0 ); // e_shoff = sec hdr table off in bytes
323
323
324
324
// e_flags = whatever the target wants
325
325
W.write <uint32_t >(OWriter.getELFHeaderEFlags ());
@@ -791,20 +791,22 @@ void ELFWriter::writeSectionData(const MCAssembler &Asm, MCSection &Sec) {
791
791
W.OS << toStringRef (Compressed);
792
792
}
793
793
794
- void ELFWriter::WriteSecHdrEntry (uint32_t Name, uint32_t Type, uint64_t Flags,
795
- uint64_t Address, uint64_t Offset,
796
- uint64_t Size, uint32_t Link, uint32_t Info,
797
- MaybeAlign Alignment, uint64_t EntrySize) {
794
+ void ELFWriter::writeSectionHeaderEntry (uint32_t Name, uint32_t Type,
795
+ uint64_t Flags, uint64_t Address,
796
+ uint64_t Offset, uint64_t Size,
797
+ uint32_t Link, uint32_t Info,
798
+ MaybeAlign Alignment,
799
+ uint64_t EntrySize) {
798
800
W.write <uint32_t >(Name); // sh_name: index into string table
799
801
W.write <uint32_t >(Type); // sh_type
800
- WriteWord (Flags); // sh_flags
801
- WriteWord (Address); // sh_addr
802
- WriteWord (Offset); // sh_offset
803
- WriteWord (Size); // sh_size
802
+ writeWord (Flags); // sh_flags
803
+ writeWord (Address); // sh_addr
804
+ writeWord (Offset); // sh_offset
805
+ writeWord (Size); // sh_size
804
806
W.write <uint32_t >(Link); // sh_link
805
807
W.write <uint32_t >(Info); // sh_info
806
- WriteWord (Alignment ? Alignment->value () : 0 ); // sh_addralign
807
- WriteWord (EntrySize); // sh_entsize
808
+ writeWord (Alignment ? Alignment->value () : 0 ); // sh_addralign
809
+ writeWord (EntrySize); // sh_entsize
808
810
}
809
811
810
812
template <bool Is64>
@@ -888,8 +890,8 @@ void ELFWriter::writeRelocations(const MCAssembler &Asm,
888
890
}
889
891
}
890
892
891
- void ELFWriter::writeSection (uint32_t GroupSymbolIndex, uint64_t Offset,
892
- uint64_t Size, const MCSectionELF &Section) {
893
+ void ELFWriter::writeSectionHeader (uint32_t GroupSymbolIndex, uint64_t Offset,
894
+ uint64_t Size, const MCSectionELF &Section) {
893
895
uint64_t sh_link = 0 ;
894
896
uint64_t sh_info = 0 ;
895
897
@@ -936,19 +938,20 @@ void ELFWriter::writeSection(uint32_t GroupSymbolIndex, uint64_t Offset,
936
938
sh_link = Sym->getSection ().getOrdinal ();
937
939
}
938
940
939
- WriteSecHdrEntry (StrTabBuilder.getOffset (Section.getName ()),
940
- Section.getType (), Section.getFlags (), 0 , Offset, Size ,
941
- sh_link, sh_info, Section.getAlign (),
942
- Section.getEntrySize ());
941
+ writeSectionHeaderEntry (StrTabBuilder.getOffset (Section.getName ()),
942
+ Section.getType (), Section.getFlags (), 0 , Offset,
943
+ Size, sh_link, sh_info, Section.getAlign (),
944
+ Section.getEntrySize ());
943
945
}
944
946
945
- void ELFWriter::writeSectionHeader (const MCAssembler &Asm) {
947
+ void ELFWriter::writeSectionHeaders (const MCAssembler &Asm) {
946
948
const unsigned NumSections = SectionTable.size ();
947
949
948
950
// Null section first.
949
951
uint64_t FirstSectionSize =
950
952
(NumSections + 1 ) >= ELF::SHN_LORESERVE ? NumSections + 1 : 0 ;
951
- WriteSecHdrEntry (0 , 0 , 0 , 0 , 0 , FirstSectionSize, 0 , 0 , std::nullopt, 0 );
953
+ writeSectionHeaderEntry (0 , 0 , 0 , 0 , 0 , FirstSectionSize, 0 , 0 , std::nullopt,
954
+ 0 );
952
955
953
956
for (const MCSectionELF *Section : SectionTable) {
954
957
uint32_t GroupSymbolIndex;
@@ -1003,7 +1006,7 @@ void ELFWriter::writeSectionHeader(const MCAssembler &Asm) {
1003
1006
}
1004
1007
}
1005
1008
1006
- writeSection (GroupSymbolIndex, Offsets.first , Size, *Section);
1009
+ writeSectionHeader (GroupSymbolIndex, Offsets.first , Size, *Section);
1007
1010
}
1008
1011
}
1009
1012
@@ -1126,7 +1129,7 @@ uint64_t ELFWriter::writeObject(MCAssembler &Asm) {
1126
1129
const uint64_t SectionHeaderOffset = align (is64Bit () ? Align (8 ) : Align (4 ));
1127
1130
1128
1131
// ... then the section header table ...
1129
- writeSectionHeader (Asm);
1132
+ writeSectionHeaders (Asm);
1130
1133
1131
1134
uint16_t NumSections = support::endian::byte_swap<uint16_t >(
1132
1135
(SectionTable.size () + 1 >= ELF::SHN_LORESERVE) ? (uint16_t )ELF::SHN_UNDEF
0 commit comments