[lld] [lld][ELF] Implement merged .debug_names section. (PR #86508)
Alexander Yermolovich via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 28 10:07:22 PDT 2024
================
@@ -788,6 +792,136 @@ class RelroPaddingSection final : public SyntheticSection {
void writeTo(uint8_t *buf) override {}
};
+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();
+ template <typename ELFT> static DebugNamesSection *create();
+ void writeTo(uint8_t *buf) override;
+ size_t getSize() const override { return sectionSize; }
+ bool isNeeded() const override;
+
+ void addSections(SmallVector<InputSectionBase *, 0> sec_list) {
+ inputDebugNamesSections = sec_list;
+ }
+
+ template <class ELFT> void writeToImpl(uint8_t *buf);
+
+ template <class ELFT, class RelTy>
+ void getNameRelocsImpl(InputSection *sec, ArrayRef<RelTy> rels,
+ llvm::DenseMap<uint32_t, uint32_t> &relocs);
+
+ template <class ELFT>
+ void getNameRelocs(InputSectionBase *base,
+ llvm::DenseMap<uint32_t, uint32_t> &relocs);
+
+ template <class ELFT>
+ void endianWrite(uint8_t size, uint8_t *buf_start, uint32_t offset,
+ uint32_t data);
+
+ 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;
----------------
ayermolo wrote:
Yep entry offsets are relative, with first one being zero for the purposes of parent. Discovered that when implementing support in BOLT.
https://github.com/llvm/llvm-project/pull/86508
More information about the llvm-commits
mailing list