[Lldb-commits] [PATCH] D44157: [elf] Remove one copy of the section merging code

Pavel Labath via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Mar 9 04:32:48 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL327123: [elf] Remove one copy of the section merging code (authored by labath, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D44157

Files:
  lldb/trunk/lit/Modules/elf-duplicate-section.yaml
  lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp


Index: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===================================================================
--- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -1986,38 +1986,10 @@
     }
   }
 
-  if (m_sections_ap.get()) {
-    if (GetType() == eTypeDebugInfo) {
-      static const SectionType g_sections[] = {
-          eSectionTypeDWARFDebugAbbrev,   eSectionTypeDWARFDebugAddr,
-          eSectionTypeDWARFDebugAranges,  eSectionTypeDWARFDebugCuIndex,
-          eSectionTypeDWARFDebugFrame,    eSectionTypeDWARFDebugInfo,
-          eSectionTypeDWARFDebugLine,     eSectionTypeDWARFDebugLoc,
-          eSectionTypeDWARFDebugMacInfo,  eSectionTypeDWARFDebugPubNames,
-          eSectionTypeDWARFDebugPubTypes, eSectionTypeDWARFDebugRanges,
-          eSectionTypeDWARFDebugStr,      eSectionTypeDWARFDebugStrOffsets,
-          eSectionTypeELFSymbolTable,
-      };
-      SectionList *elf_section_list = m_sections_ap.get();
-      for (size_t idx = 0; idx < sizeof(g_sections) / sizeof(g_sections[0]);
-           ++idx) {
-        SectionType section_type = g_sections[idx];
-        SectionSP section_sp(
-            elf_section_list->FindSectionByType(section_type, true));
-        if (section_sp) {
-          SectionSP module_section_sp(
-              unified_section_list.FindSectionByType(section_type, true));
-          if (module_section_sp)
-            unified_section_list.ReplaceSection(module_section_sp->GetID(),
-                                                section_sp);
-          else
-            unified_section_list.AddSection(section_sp);
-        }
-      }
-    } else {
-      unified_section_list = *m_sections_ap;
-    }
-  }
+  // For eTypeDebugInfo files, the Symbol Vendor will take care of updating the
+  // unified section list.
+  if (GetType() != eTypeDebugInfo)
+    unified_section_list = *m_sections_ap;
 }
 
 // Find the arm/aarch64 mapping symbol character in the given symbol name.
Index: lldb/trunk/lit/Modules/elf-duplicate-section.yaml
===================================================================
--- lldb/trunk/lit/Modules/elf-duplicate-section.yaml
+++ lldb/trunk/lit/Modules/elf-duplicate-section.yaml
@@ -0,0 +1,42 @@
+# RUN: mkdir -p %t/.build-id/1b
+# RUN: yaml2obj %s > %t/.build-id/1b/8a73ac238390e32a7ff4ac8ebe4d6a41ecf5c9.debug
+# RUN: cd %t
+# RUN: llvm-objcopy --strip-all --add-gnu-debuglink=.build-id/1b/8a73ac238390e32a7ff4ac8ebe4d6a41ecf5c9.debug %t/.build-id/1b/8a73ac238390e32a7ff4ac8ebe4d6a41ecf5c9.debug %t/stripped.out
+# RUN: lldb-test module-sections %t/stripped.out | FileCheck %s
+
+# Make sure that the debug_frame section is present only once.
+# CHECK: Name: .debug_frame
+# CHECK-NOT: .debug_frame
+
+--- !ELF
+FileHeader:
+  Class:           ELFCLASS64
+  Data:            ELFDATA2LSB
+  Type:            ET_EXEC
+  Machine:         EM_X86_64
+  Entry:           0x00000000004003D0
+Sections:
+  - Name:            .note.gnu.build-id
+    Type:            SHT_NOTE
+    Flags:           [ SHF_ALLOC ]
+    Address:         0x0000000000400274
+    AddressAlign:    0x0000000000000004
+    Content:         040000001400000003000000474E55001B8A73AC238390E32A7FF4AC8EBE4D6A41ECF5C9
+  - Name:            .text
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
+    Address:         0x00000000004003D0
+    AddressAlign:    0x0000000000000010
+    Content:         DEADBEEFBAADF00D
+  - Name:            .debug_frame
+    Type:            SHT_PROGBITS
+    AddressAlign:    0x0000000000000008
+    Content:         DEADBEEFBAADF00D
+Symbols:
+  Local:
+    - Name:            main
+      Type:            STT_FUNC
+      Section:         .text
+      Value:           0x00000000004003D0
+      Size:            0x0000000000000008
+...


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44157.137725.patch
Type: text/x-patch
Size: 3867 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20180309/88944f71/attachment.bin>


More information about the lldb-commits mailing list