[lld] [lld][ELF] Implement merged .debug_names section. (PR #86508)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 10 00:06:19 PDT 2024
================
@@ -788,6 +792,125 @@ class RelroPaddingSection final : public SyntheticSection {
void writeTo(uint8_t *buf) override {}
};
+template <class ELFT> class DebugNamesSection final : public SyntheticSection {
+ // N.B. Everything in this class assumes that we are using DWARF32.
+ // If we move to DWARF64, most of this data will need to be re-sized,
+ // and the code that handles or manipulates it will need to be updated
+ // accordingly.
+
+public:
+ DebugNamesSection();
+ static DebugNamesSection *create();
+ void writeTo(uint8_t *buf) override;
+ size_t getSize() const override { return sectionSize; }
+ bool isNeeded() const override;
+
+ template <class RelTy>
+ void getNameRelocsImpl(InputSection *sec, ArrayRef<RelTy> rels,
+ llvm::DenseMap<uint32_t, uint32_t> &relocs);
+
+ void getNameRelocs(InputSectionBase *base,
+ llvm::DenseMap<uint32_t, uint32_t> &relocs);
+
+ struct Abbrev : public llvm::FoldingSetNode {
+ uint32_t code;
+ uint32_t tag;
+ SmallVector<llvm::DWARFDebugNames::AttributeEncoding, 2> attributes;
+
+ void Profile(llvm::FoldingSetNodeID &id) const;
+ };
+
+ struct AttrValueData {
+ uint32_t attrValue;
+ uint8_t attrSize;
+ };
+
+ struct IndexEntry {
+ uint32_t abbrevCode;
+ uint32_t poolOffset;
+ union {
+ int32_t parentOffset = -1;
+ IndexEntry *parentEntry;
+ };
+ SmallVector<AttrValueData, 3> attrValues;
----------------
MaskRay wrote:
Peak memory usage is extremely sensitive to the `IndexEntry` size. I don't find a straightforward way to make `attrValues` smaller.
https://github.com/llvm/llvm-project/pull/86508
More information about the llvm-commits
mailing list