[PATCH] D87205: [DWARFYAML] Make the debug_addr section optional.

Xing GUO via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 6 07:15:20 PDT 2020


Higuoxing created this revision.
Higuoxing added reviewers: jhenderson, grimar, MaskRay.
Herald added subscribers: llvm-commits, hiraditya, emaste.
Herald added a reviewer: espindola.
Herald added a project: LLVM.
Higuoxing requested review of this revision.

This patch makes the debug_addr section optional. When an empty
debug_addr section is specified, yaml2obj only emits a section header
for it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87205

Files:
  llvm/include/llvm/ObjectYAML/DWARFYAML.h
  llvm/lib/ObjectYAML/DWARFEmitter.cpp
  llvm/lib/ObjectYAML/DWARFYAML.cpp
  llvm/test/tools/yaml2obj/ELF/DWARF/debug-addr.yaml


Index: llvm/test/tools/yaml2obj/ELF/DWARF/debug-addr.yaml
===================================================================
--- llvm/test/tools/yaml2obj/ELF/DWARF/debug-addr.yaml
+++ llvm/test/tools/yaml2obj/ELF/DWARF/debug-addr.yaml
@@ -631,3 +631,18 @@
       [[SIZENAME]]: 3
       Entries:
         - Address: 0x1234
+
+## n) Test that the .debug_addr section header is emitted if the "debug_addr"
+## entry is empty.
+
+# RUN: yaml2obj --docnum=12 %s -o %t12.o
+# RUN: llvm-readobj --sections --section-data %t12.o | \
+# RUN:   FileCheck %s -DSIZE=0 -DADDRALIGN=1 --check-prefix=SHDR
+
+--- !ELF
+FileHeader:
+  Class: ELFCLASS64
+  Data:  ELFDATA2LSB
+  Type:  ET_EXEC
+DWARF:
+  debug_addr: []
Index: llvm/lib/ObjectYAML/DWARFYAML.cpp
===================================================================
--- llvm/lib/ObjectYAML/DWARFYAML.cpp
+++ llvm/lib/ObjectYAML/DWARFYAML.cpp
@@ -32,7 +32,7 @@
     SecNames.insert("debug_ranges");
   if (!DebugLines.empty())
     SecNames.insert("debug_line");
-  if (!DebugAddr.empty())
+  if (DebugAddr)
     SecNames.insert("debug_addr");
   if (!DebugAbbrev.empty())
     SecNames.insert("debug_abbrev");
Index: llvm/lib/ObjectYAML/DWARFEmitter.cpp
===================================================================
--- llvm/lib/ObjectYAML/DWARFEmitter.cpp
+++ llvm/lib/ObjectYAML/DWARFEmitter.cpp
@@ -594,7 +594,7 @@
 }
 
 Error DWARFYAML::emitDebugAddr(raw_ostream &OS, const Data &DI) {
-  for (const AddrTableEntry &TableEntry : DI.DebugAddr) {
+  for (const AddrTableEntry &TableEntry : *DI.DebugAddr) {
     uint8_t AddrSize;
     if (TableEntry.AddrSize)
       AddrSize = *TableEntry.AddrSize;
Index: llvm/include/llvm/ObjectYAML/DWARFYAML.h
===================================================================
--- llvm/include/llvm/ObjectYAML/DWARFYAML.h
+++ llvm/include/llvm/ObjectYAML/DWARFYAML.h
@@ -215,7 +215,7 @@
   Optional<std::vector<StringOffsetsTable>> DebugStrOffsets;
   Optional<std::vector<ARange>> DebugAranges;
   std::vector<Ranges> DebugRanges;
-  std::vector<AddrTableEntry> DebugAddr;
+  Optional<std::vector<AddrTableEntry>> DebugAddr;
   Optional<PubSection> PubNames;
   Optional<PubSection> PubTypes;
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87205.290139.patch
Type: text/x-patch
Size: 2190 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200906/be47da6c/attachment-0001.bin>


More information about the llvm-commits mailing list