@@ -429,7 +429,8 @@ void writeStringsAndOffsets(MCStreamer &Out, DWPStringPool &Strings,
429429 MCSection *StrOffsetSection,
430430 StringRef CurStrSection,
431431 StringRef CurStrOffsetSection, uint16_t Version,
432- SectionLengths &SectionLength) {
432+ SectionLengths &SectionLength,
433+ const bool ForceDwarf64StringOffsets) {
433434 // Could possibly produce an error or warning if one of these was non-null but
434435 // the other was null.
435436 if (CurStrSection.empty () || CurStrOffsetSection.empty ())
@@ -442,9 +443,11 @@ void writeStringsAndOffsets(MCStreamer &Out, DWPStringPool &Strings,
442443 uint64_t PrevOffset = 0 ;
443444
444445 // Keep track if any new string offsets exceed UINT32_MAX. If any do, we can
445- // emit a DWARF64 .debug_str_offsets table for this compile unit.
446+ // emit a DWARF64 .debug_str_offsets table for this compile unit. If the
447+ // \a ForceDwarf64StringOffsets argument is true, then force the emission of
448+ // DWARF64 .debug_str_offsets for testing.
446449 uint32_t OldOffsetSize = 4 ;
447- uint32_t NewOffsetSize = 4 ;
450+ uint32_t NewOffsetSize = ForceDwarf64StringOffsets ? 8 : 4 ;
448451 while (const char *S = Data.getCStr (&LocalOffset)) {
449452 uint64_t NewOffset = Strings.getOffset (S, LocalOffset - PrevOffset);
450453 OffsetRemapping[PrevOffset] = NewOffset;
@@ -666,7 +669,8 @@ Error handleSection(
666669}
667670
668671Error write (MCStreamer &Out, ArrayRef<std::string> Inputs,
669- OnCuIndexOverflow OverflowOptValue) {
672+ OnCuIndexOverflow OverflowOptValue,
673+ bool ForceDwarf64StringOffsets) {
670674 const auto &MCOFI = *Out.getContext ().getObjectFileInfo ();
671675 MCSection *const StrSection = MCOFI.getDwarfStrDWOSection ();
672676 MCSection *const StrOffsetSection = MCOFI.getDwarfStrOffDWOSection ();
@@ -759,7 +763,8 @@ Error write(MCStreamer &Out, ArrayRef<std::string> Inputs,
759763 }
760764
761765 writeStringsAndOffsets (Out, Strings, StrOffsetSection, CurStrSection,
762- CurStrOffsetSection, Header.Version , SectionLength);
766+ CurStrOffsetSection, Header.Version , SectionLength,
767+ ForceDwarf64StringOffsets);
763768
764769 for (auto Pair : SectionLength) {
765770 auto Index = getContributionIndex (Pair.first , IndexVersion);
0 commit comments