@@ -277,17 +277,16 @@ void ObjFile::parseSections(ArrayRef<SectionHeader> sectionHeaders) {
277
277
ArrayRef<uint8_t > data = {isZeroFill (sec.flags ) ? nullptr
278
278
: buf + sec.offset ,
279
279
static_cast <size_t >(sec.size )};
280
+ sections.push_back (sec.addr );
280
281
if (sec.align >= 32 ) {
281
282
error (" alignment " + std::to_string (sec.align ) + " of section " + name +
282
283
" is too large" );
283
- sections.push_back (sec.addr );
284
284
continue ;
285
285
}
286
286
uint32_t align = 1 << sec.align ;
287
287
uint32_t flags = sec.flags ;
288
288
289
289
auto splitRecords = [&](int recordSize) -> void {
290
- sections.push_back (sec.addr );
291
290
if (data.empty ())
292
291
return ;
293
292
Subsections &subsections = sections.back ().subsections ;
@@ -321,7 +320,6 @@ void ObjFile::parseSections(ArrayRef<SectionHeader> sectionHeaders) {
321
320
isec = make<WordLiteralInputSection>(segname, name, this , data, align,
322
321
flags);
323
322
}
324
- sections.push_back (sec.addr );
325
323
sections.back ().subsections .push_back ({0 , isec});
326
324
} else if (auto recordSize = getRecordSize (segname, name)) {
327
325
splitRecords (*recordSize);
@@ -350,23 +348,19 @@ void ObjFile::parseSections(ArrayRef<SectionHeader> sectionHeaders) {
350
348
// ld64 does not appear to emit contents from sections within the __LLVM
351
349
// segment. Symbols within those sections point to bitcode metadata
352
350
// instead of actual symbols. Global symbols within those sections could
353
- // have the same name without causing duplicate symbol errors. Push an
354
- // empty entry to ensure indices line up for the remaining sections.
351
+ // have the same name without causing duplicate symbol errors. To avoid
352
+ // spurious duplicate symbol errors, we do not parse these sections.
355
353
// TODO: Evaluate whether the bitcode metadata is needed.
356
- sections.push_back (sec.addr );
357
354
} else {
358
355
auto *isec =
359
356
make<ConcatInputSection>(segname, name, this , data, align, flags);
360
357
if (isDebugSection (isec->getFlags ()) &&
361
358
isec->getSegName () == segment_names::dwarf) {
362
359
// Instead of emitting DWARF sections, we emit STABS symbols to the
363
360
// object files that contain them. We filter them out early to avoid
364
- // parsing their relocations unnecessarily. But we must still push an
365
- // empty entry to ensure the indices line up for the remaining sections.
366
- sections.push_back (sec.addr );
361
+ // parsing their relocations unnecessarily.
367
362
debugSections.push_back (isec);
368
363
} else {
369
- sections.push_back (sec.addr );
370
364
sections.back ().subsections .push_back ({0 , isec});
371
365
}
372
366
}
0 commit comments