[llvm] 40f4131 - [DWARFYAML] Make the debug_addr section optional.
Xing GUO via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 7 01:18:47 PDT 2020
Author: Xing GUO
Date: 2020-09-07T16:17:18+08:00
New Revision: 40f4131fce787fe7a8596f06cef5fb6a06bf5ded
URL: https://github.com/llvm/llvm-project/commit/40f4131fce787fe7a8596f06cef5fb6a06bf5ded
DIFF: https://github.com/llvm/llvm-project/commit/40f4131fce787fe7a8596f06cef5fb6a06bf5ded.diff
LOG: [DWARFYAML] Make the debug_addr section optional.
This patch makes the debug_addr section optional. When an empty
debug_addr section is specified, yaml2obj only emits a section header
for it.
Reviewed By: jhenderson
Differential Revision: https://reviews.llvm.org/D87205
Added:
Modified:
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
Removed:
################################################################################
diff --git a/llvm/include/llvm/ObjectYAML/DWARFYAML.h b/llvm/include/llvm/ObjectYAML/DWARFYAML.h
index 19b7f3500ee6..99a7af87d2c7 100644
--- a/llvm/include/llvm/ObjectYAML/DWARFYAML.h
+++ b/llvm/include/llvm/ObjectYAML/DWARFYAML.h
@@ -215,7 +215,7 @@ struct Data {
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;
diff --git a/llvm/lib/ObjectYAML/DWARFEmitter.cpp b/llvm/lib/ObjectYAML/DWARFEmitter.cpp
index a0a445ae0c9d..bf29f40579ce 100644
--- a/llvm/lib/ObjectYAML/DWARFEmitter.cpp
+++ b/llvm/lib/ObjectYAML/DWARFEmitter.cpp
@@ -594,7 +594,7 @@ Error DWARFYAML::emitDebugLine(raw_ostream &OS, const DWARFYAML::Data &DI) {
}
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;
diff --git a/llvm/lib/ObjectYAML/DWARFYAML.cpp b/llvm/lib/ObjectYAML/DWARFYAML.cpp
index 046dddbf9a39..353e5058a0e5 100644
--- a/llvm/lib/ObjectYAML/DWARFYAML.cpp
+++ b/llvm/lib/ObjectYAML/DWARFYAML.cpp
@@ -32,7 +32,7 @@ SetVector<StringRef> DWARFYAML::Data::getNonEmptySectionNames() const {
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");
diff --git a/llvm/test/tools/yaml2obj/ELF/DWARF/debug-addr.yaml b/llvm/test/tools/yaml2obj/ELF/DWARF/debug-addr.yaml
index 52841e167b44..6a8dc84d98aa 100644
--- a/llvm/test/tools/yaml2obj/ELF/DWARF/debug-addr.yaml
+++ b/llvm/test/tools/yaml2obj/ELF/DWARF/debug-addr.yaml
@@ -631,3 +631,18 @@ DWARF:
[[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 %t12.o | \
+# RUN: FileCheck %s -DSIZE=0 -DADDRALIGN=1 --check-prefix=SHDR
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_EXEC
+DWARF:
+ debug_addr: []
More information about the llvm-commits
mailing list