[Lldb-commits] [lldb] [LLDB] Fix debuginfo ELF files overwriting Unified Section List (PR #166635)

Greg Clayton via lldb-commits lldb-commits at lists.llvm.org
Wed Nov 5 13:35:36 PST 2025


================
@@ -130,6 +130,42 @@ class ELFRelocation {
 
   RelocUnion reloc;
 };
+
+lldb::SectionSP MergeSections(lldb::SectionSP lhs, lldb::SectionSP rhs) {
+  assert(lhs && rhs);
+
+  // We only take the RHS is the LHS is SHT_NOBITS, which would be
+  // represented as a size of 0. Where we can take the rhs.
----------------
clayborg wrote:

Byte size of zero isn't always SHT_NOBITS. You might want to check the section type to see if it is `eSectionTypeZeroFill` instead of looking for a byte size of zero. Looking at the ObjectFileELF we can see:
```
SectionType ObjectFileELF::GetSectionType(const ELFSectionHeaderInfo &H) const {
  switch (H.sh_type) {
  case SHT_PROGBITS:
    if (H.sh_flags & SHF_EXECINSTR)
      return eSectionTypeCode;
    break;
  case SHT_NOBITS:
    if (H.sh_flags & SHF_ALLOC)
      return eSectionTypeZeroFill;
    break;
...
```

Also, both sections might be zero filled, so we want to take the `lhs` in that case.

https://github.com/llvm/llvm-project/pull/166635


More information about the lldb-commits mailing list