-// Emit strings into a string section.
-void DwarfFile::emitStrings(const MCSection *StrSection,
- const MCSection *OffsetSection = NULL,
- const MCSymbol *StrSecSym = NULL) {
-
- if (StringPool.empty())
- return;
-
- // Start the dwarf str section.
- Asm->OutStreamer.SwitchSection(StrSection);
-
- // Get all of the string pool entries and put them in an array by their ID so
- // we can sort them.
- SmallVector<std::pair<unsigned, const StrPool::value_type *>, 64 > Entries;
-
- for (const auto &I : StringPool)
- Entries.push_back(std::make_pair(I.second.second, &I));
-
- array_pod_sort(Entries.begin(), Entries.end());
-
- for (const auto &Entry : Entries) {
- // Emit a label for reference from debug information entries.
- Asm->OutStreamer.EmitLabel(Entry.second->getValue().first);
-
- // Emit the string itself with a terminating null byte.
- Asm->OutStreamer.EmitBytes(StringRef(Entry.second->getKeyData(),
- Entry.second->getKeyLength() + 1));
- }
-
- // If we've got an offset section go ahead and emit that now as well.
- if (OffsetSection) {
- Asm->OutStreamer.SwitchSection(OffsetSection);
- unsigned offset = 0;
- unsigned size = 4; // FIXME: DWARF64 is 8.
- for (const auto &Entry : Entries) {
- Asm->OutStreamer.EmitIntValue(offset, size);
- offset += Entry.second->getKeyLength() + 1;
- }
- }
-}
-
-// Emit addresses into the section given.
-void DwarfFile::emitAddresses(const MCSection *AddrSection) {
-
- if (AddressPool.empty())
- return;
-
- // Start the dwarf addr section.
- Asm->OutStreamer.SwitchSection(AddrSection);
-
- // Order the address pool entries by ID
- SmallVector<const MCExpr *, 64> Entries(AddressPool.size());
-
- for (const auto &I : AddressPool)
- Entries[I.second.Number] =
- I.second.TLS
- ? Asm->getObjFileLowering().getDebugThreadLocalSymbol(I.first)
- : MCSymbolRefExpr::Create(I.first, Asm->OutContext);
-
- for (const MCExpr *Entry : Entries)
- Asm->OutStreamer.EmitValue(Entry, Asm->getDataLayout().getPointerSize());
-}
-