[lld] [lld][ELF] Add --debug-names to create merged .debug_names. (PR #86508)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 18 11:15:47 PDT 2024
================
@@ -2711,6 +2714,620 @@ static uint32_t computeGdbHash(StringRef s) {
return h;
}
+// 4-byte alignment ensures that values in the hash lookup table and the name
+// table are aligned.
+DebugNamesBaseSection::DebugNamesBaseSection()
+ : SyntheticSection(0, SHT_PROGBITS, 4, ".debug_names") {}
+
+// Get the size of the .debug_names section header in bytes for DWARF32:
+static uint32_t getDebugNamesHeaderSize(uint32_t augmentationStringSize) {
+ return /* unit length */ 4 +
+ /* version */ 2 +
+ /* padding */ 2 +
+ /* CU count */ 4 +
+ /* TU count */ 4 +
+ /* Foreign TU count */ 4 +
+ /* Bucket Count */ 4 +
+ /* Name Count */ 4 +
+ /* Abbrev table size */ 4 +
+ /* Augmentation string size */ 4 +
+ /* Augmentation string */ augmentationStringSize;
+}
+
+static Expected<DebugNamesBaseSection::IndexEntry *>
+readEntry(uint64_t &offset, const DWARFDebugNames::NameIndex &ni,
+ uint64_t entriesBase, DWARFDataExtractor &namesExtractor,
+ const LLDDWARFSection &namesSec) {
+ std::string errMsg;
+ auto ie = makeThreadLocal<DebugNamesBaseSection::IndexEntry>();
+ ie->poolOffset = offset;
+ Error err = Error::success();
+ uint64_t ulebVal = namesExtractor.getULEB128(&offset, &err);
+ if (err) {
+ errMsg = ": invalid abbrev code in entry: ";
+ errMsg.append(toString(std::move(err)));
+ return createStringError(inconvertibleErrorCode(), errMsg.c_str());
+ }
+ if (ulebVal < UINT32_MAX)
----------------
MaskRay wrote:
This should be `<=`
Or use `isUInt<32>(ulebVal)`
https://github.com/llvm/llvm-project/pull/86508
More information about the llvm-commits
mailing list