uint32_t SymbolTableEntryCount = 0;
uint64_t SymbolTableOffset = 0;
uint16_t SectionCount = 0;
+ uint32_t PaddingsBeforeDwarf = 0;
std::vector<std::pair<std::string, size_t>> FileNames;
bool HasVisibility = false;
SymbolTableEntryCount = 0;
SymbolTableOffset = 0;
SectionCount = 0;
+ PaddingsBeforeDwarf = 0;
Strings.clear();
MCObjectWriter::reset();
auxiliaryHeaderSize();
// Calculate the file offset to the section data.
- uint64_t CurrAddress = 0;
for (auto *Sec : Sections) {
if (Sec->Index == SectionEntry::UninitializedIndex || Sec->IsVirtual)
continue;
RawPointer += Sec->Size;
if (RawPointer > MaxRawDataSize)
report_fatal_error("Section raw data overflowed this object file.");
-
- CurrAddress = Sec->Address + Sec->Size;
}
- // Sections other than DWARF section use DefaultSectionAlign as the default
- // alignment, while DWARF sections have their own alignments. If these two
- // alignments are not the same, we need some padding here and to use this
- // padding in FileOffsetToData calculation.
if (!DwarfSections.empty()) {
- RawPointer +=
- alignTo(CurrAddress,
- (*DwarfSections.begin()).DwarfSect->MCSec->getAlign()) -
- CurrAddress;
+ RawPointer += PaddingsBeforeDwarf;
for (auto &DwarfSection : DwarfSections) {
DwarfSection.FileOffsetToData = RawPointer;
RawPointer += DwarfSection.MemorySize;
Section->Size = Address - Section->Address;
}
- // Start to generate DWARF sections.
+ // Start to generate DWARF sections. Sections other than DWARF section use
+ // DefaultSectionAlign as the default alignment, while DWARF sections have
+ // their own alignments. If these two alignments are not the same, we need
+ // some paddings here and record the paddings bytes for FileOffsetToData
+ // calculation.
+ if (!DwarfSections.empty())
+ PaddingsBeforeDwarf =
+ alignTo(Address,
+ (*DwarfSections.begin()).DwarfSect->MCSec->getAlign()) -
+ Address;
+
DwarfSectionEntry *LastDwarfSection = nullptr;
for (auto &DwarfSection : DwarfSections) {
assert((SectionIndex <= MaxSectionIndex) && "Section index overflow!");