@@ -126,7 +126,8 @@ uint64_t MachObjectWriter::getSymbolAddress(const MCSymbol &S) const {
126
126
uint64_t MachObjectWriter::getPaddingSize (const MCAssembler &Asm,
127
127
const MCSection *Sec) const {
128
128
uint64_t EndAddr = getSectionAddress (Sec) + Asm.getSectionAddressSize (*Sec);
129
- unsigned Next = cast<MCSectionMachO>(Sec)->getLayoutOrder () + 1 ;
129
+ unsigned Next =
130
+ static_cast <const MCSectionMachO *>(Sec)->getLayoutOrder () + 1 ;
130
131
if (Next >= SectionOrder.size ())
131
132
return 0 ;
132
133
@@ -259,27 +260,24 @@ void MachObjectWriter::writeSegmentLoadCommand(
259
260
}
260
261
261
262
void MachObjectWriter::writeSection (const MCAssembler &Asm,
262
- const MCSection &Sec, uint64_t VMAddr,
263
+ const MCSectionMachO &Sec, uint64_t VMAddr,
263
264
uint64_t FileOffset, unsigned Flags,
264
265
uint64_t RelocationsStart,
265
266
unsigned NumRelocations) {
266
- uint64_t SectionSize = Asm.getSectionAddressSize (Sec);
267
- const MCSectionMachO &Section = cast<MCSectionMachO>(Sec);
268
-
269
267
// The offset is unused for virtual sections.
270
- if (Section .isBssSection ()) {
268
+ if (Sec .isBssSection ()) {
271
269
assert (Asm.getSectionFileSize (Sec) == 0 && " Invalid file size!" );
272
270
FileOffset = 0 ;
273
271
}
274
272
275
273
// struct section (68 bytes) or
276
274
// struct section_64 (80 bytes)
277
275
276
+ uint64_t SectionSize = Asm.getSectionAddressSize (Sec);
278
277
uint64_t Start = W.OS .tell ();
279
278
(void ) Start;
280
-
281
- writeWithPadding (Section.getName (), 16 );
282
- writeWithPadding (Section.getSegmentName (), 16 );
279
+ writeWithPadding (Sec.getName (), 16 );
280
+ writeWithPadding (Sec.getSegmentName (), 16 );
283
281
if (is64Bit ()) {
284
282
W.write <uint64_t >(VMAddr); // address
285
283
W.write <uint64_t >(SectionSize); // size
@@ -290,14 +288,14 @@ void MachObjectWriter::writeSection(const MCAssembler &Asm,
290
288
assert (isUInt<32 >(FileOffset) && " Cannot encode offset of section" );
291
289
W.write <uint32_t >(FileOffset);
292
290
293
- W.write <uint32_t >(Log2 (Section .getAlign ()));
291
+ W.write <uint32_t >(Log2 (Sec .getAlign ()));
294
292
assert ((!NumRelocations || isUInt<32 >(RelocationsStart)) &&
295
293
" Cannot encode offset of relocations" );
296
294
W.write <uint32_t >(NumRelocations ? RelocationsStart : 0 );
297
295
W.write <uint32_t >(NumRelocations);
298
296
W.write <uint32_t >(Flags);
299
297
W.write <uint32_t >(IndirectSymBase.lookup (&Sec)); // reserved1
300
- W.write <uint32_t >(Section .getStubSize ()); // reserved2
298
+ W.write <uint32_t >(Sec .getStubSize ()); // reserved2
301
299
if (is64Bit ())
302
300
W.write <uint32_t >(0 ); // reserved3
303
301
@@ -531,7 +529,7 @@ void MachObjectWriter::bindIndirectSymbols(MCAssembler &Asm) {
531
529
// Report errors for use of .indirect_symbol not in a symbol pointer section
532
530
// or stub section.
533
531
for (IndirectSymbolData &ISD : IndirectSymbols) {
534
- const MCSectionMachO &Section = cast <MCSectionMachO>(*ISD.Section );
532
+ const MCSectionMachO &Section = static_cast <MCSectionMachO & >(*ISD.Section );
535
533
536
534
if (Section.getType () != MachO::S_NON_LAZY_SYMBOL_POINTERS &&
537
535
Section.getType () != MachO::S_LAZY_SYMBOL_POINTERS &&
@@ -545,7 +543,7 @@ void MachObjectWriter::bindIndirectSymbols(MCAssembler &Asm) {
545
543
546
544
// Bind non-lazy symbol pointers first.
547
545
for (auto [IndirectIndex, ISD] : enumerate(IndirectSymbols)) {
548
- const auto &Section = cast <MCSectionMachO>(*ISD.Section );
546
+ const auto &Section = static_cast <MCSectionMachO & >(*ISD.Section );
549
547
550
548
if (Section.getType () != MachO::S_NON_LAZY_SYMBOL_POINTERS &&
551
549
Section.getType () != MachO::S_THREAD_LOCAL_VARIABLE_POINTERS)
@@ -559,7 +557,7 @@ void MachObjectWriter::bindIndirectSymbols(MCAssembler &Asm) {
559
557
560
558
// Then lazy symbol pointers and symbol stubs.
561
559
for (auto [IndirectIndex, ISD] : enumerate(IndirectSymbols)) {
562
- const auto &Section = cast <MCSectionMachO>(*ISD.Section );
560
+ const auto &Section = static_cast <MCSectionMachO & >(*ISD.Section );
563
561
564
562
if (Section.getType () != MachO::S_LAZY_SYMBOL_POINTERS &&
565
563
Section.getType () != MachO::S_SYMBOL_STUBS)
@@ -684,13 +682,13 @@ void MachObjectWriter::computeSectionAddresses(const MCAssembler &Asm) {
684
682
for (MCSection &Sec : Asm) {
685
683
if (!Sec.isBssSection ()) {
686
684
SectionOrder.push_back (&Sec);
687
- cast <MCSectionMachO>(Sec).setLayoutOrder (i++);
685
+ static_cast <MCSectionMachO & >(Sec).setLayoutOrder (i++);
688
686
}
689
687
}
690
688
for (MCSection &Sec : Asm) {
691
689
if (Sec.isBssSection ()) {
692
690
SectionOrder.push_back (&Sec);
693
- cast <MCSectionMachO>(Sec).setLayoutOrder (i++);
691
+ static_cast <MCSectionMachO & >(Sec).setLayoutOrder (i++);
694
692
}
695
693
}
696
694
@@ -907,7 +905,7 @@ uint64_t MachObjectWriter::writeObject() {
907
905
// ... and then the section headers.
908
906
uint64_t RelocTableEnd = SectionDataStart + SectionDataFileSize;
909
907
for (const MCSection &Section : Asm) {
910
- const auto &Sec = cast< MCSectionMachO>(Section);
908
+ const auto &Sec = static_cast < const MCSectionMachO & >(Section);
911
909
std::vector<RelAndSymbol> &Relocs = Relocations[&Sec];
912
910
unsigned NumRelocs = Relocs.size ();
913
911
uint64_t SectionStart = SectionDataStart + getSectionAddress (&Sec);
0 commit comments