[lld] [lld][ELF] Implement merged .debug_names section. (PR #86508)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 26 22:56:00 PDT 2024
================
@@ -2690,6 +2693,759 @@ static uint32_t computeGdbHash(StringRef s) {
return h;
}
+DebugNamesSection::DebugNamesSection()
+ : SyntheticSection(0, SHT_PROGBITS, 1, ".debug_names") {}
+
+template <class ELFT, class RelTy>
+void DebugNamesSection::getNameRelocsImpl(
+ InputSection *sec, ArrayRef<RelTy> rels,
+ llvm::DenseMap<uint32_t, uint32_t> &relocs) {
+ for (auto &rel : rels) {
+ Symbol &sym = sec->getFile<ELFT>()->getRelocTargetSym(rel);
+ relocs[rel.r_offset] = sym.getVA(getAddend<ELFT>(rel));
+ }
+}
+
+template <class ELFT>
+void DebugNamesSection::getNameRelocs(
+ InputSectionBase *base, llvm::DenseMap<uint32_t, uint32_t> &relocs) {
+ auto *sec = cast<InputSection>(base);
+ const RelsOrRelas<ELFT> rels = sec->template relsOrRelas<ELFT>();
+ if (rels.areRelocsRel())
+ getNameRelocsImpl<ELFT>(sec, rels.rels, relocs);
+ else
+ getNameRelocsImpl<ELFT>(sec, rels.relas, relocs);
+}
+
+void DebugNamesSection::writeTo(uint8_t *buf) { invokeELFT(writeToImpl, buf); }
+
+template <class ELFT> void DebugNamesSection::writeToImpl(uint8_t *buf) {
+ SmallVector<uint32_t, 0> mergedCuOffsets;
+ SmallVector<uint32_t, 0> mergedTuOffsets;
+ llvm::DenseMap<uint32_t, uint32_t> strOffsets;
+ SmallVector<llvm::DenseMap<uint32_t, uint32_t>, 0> chunksRelocs;
+ chunksRelocs.reserve(numChunks);
+
+ for (size_t i = 0; i < numChunks; ++i) {
+ DebugNamesOutputChunk &chunk = outputChunks[i];
+ InputSectionBase *base = inputDebugNamesSections[i];
+ llvm::DenseMap<uint32_t, uint32_t> relocs;
----------------
cmtice wrote:
Both are done.
https://github.com/llvm/llvm-project/pull/86508
More information about the llvm-commits
mailing list