[PATCH] D81148: [MC] Fix DWARF forms for 64-bit DWARFv3 files [6/7]
Igor Kudrin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 4 05:24:49 PDT 2020
ikudrin created this revision.
ikudrin added reviewers: dblaikie, jhenderson, aprantl, probinson, MaskRay, echristo.
ikudrin added projects: LLVM, debug-info.
Herald added subscribers: hiraditya, emaste.
Herald added a reviewer: espindola.
ikudrin added a parent revision: D81147: [MC] Generate .debug_rnglists in the 64-bit DWARF format [5/7].
ikudrin added a child revision: D81149: [MC] Generate .debug_frame in the 64-bit DWARF format [7/7].
`DW_FORM_sec_offset` was introduced in `DWARFv4`, so, for 64-bit `DWARFv3`, `DW_FORM_data8` should be used instead.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D81148
Files:
llvm/lib/MC/MCDwarf.cpp
llvm/test/MC/ELF/gen-dwarf64.s
Index: llvm/test/MC/ELF/gen-dwarf64.s
===================================================================
--- llvm/test/MC/ELF/gen-dwarf64.s
+++ llvm/test/MC/ELF/gen-dwarf64.s
@@ -1,5 +1,9 @@
## This checks that llvm-mc is able to produce 64-bit debug info.
+# RUN: llvm-mc -g -dwarf-version 3 -dwarf64 -triple x86_64 %s -filetype=obj -o %t3.o
+# RUN: llvm-readobj -r %t3.o | FileCheck --check-prefixes=REL %s
+# RUN: llvm-dwarfdump -v %t3.o | FileCheck --check-prefixes=DUMP,DUMP3 %s
+
# RUN: llvm-mc -g -dwarf-version 5 -dwarf64 -triple x86_64 %s -filetype=obj -o %t5.o
# RUN: llvm-readobj -r %t5.o | FileCheck --check-prefixes=REL,REL5 %s
# RUN: llvm-dwarfdump -v %t5.o | FileCheck --check-prefixes=DUMP,DUMP5 %s
@@ -9,6 +13,7 @@
# REL: Section ({{[0-9]+}}) .rela.debug_info {
# REL-NEXT: R_X86_64_64 .debug_abbrev 0x0
# REL-NEXT: R_X86_64_64 .debug_line 0x0
+# REL3-NEXT: R_X86_64_64 .debug_ranges 0x0
# REL5-NEXT: R_X86_64_64 .debug_rnglists 0x14
# REL: Section ({{[0-9]+}}) .rela.debug_aranges {
# REL-NEXT: R_X86_64_64 .debug_info 0x0
@@ -16,11 +21,21 @@
# REL5-NEXT: R_X86_64_64 .debug_line_str 0x0
# REL5-NEXT: R_X86_64_64 .debug_line_str 0x
+## DW_FORM_sec_offset was introduced in DWARFv4.
+## For DWARFv3, DW_FORM_data8 is used instead.
+# DUMP: .debug_abbrev contents:
+# DUMP3: DW_AT_stmt_list DW_FORM_data8
+# DUMP3-NEXT: DW_AT_ranges DW_FORM_data8
+# DUMP5: DW_AT_stmt_list DW_FORM_sec_offset
+# DUMP5-NEXT: DW_AT_ranges DW_FORM_sec_offset
+
# DUMP: .debug_info contents:
# DUMP-NEXT: 0x00000000: Compile Unit:
# DUMP-SAME: format = DWARF64
# DUMP: DW_TAG_compile_unit [1] *
+# DUMP3-NEXT: DW_AT_stmt_list [DW_FORM_data8] (0x0000000000000000)
# DUMP5-NEXT: DW_AT_stmt_list [DW_FORM_sec_offset] (0x0000000000000000)
+# DUMP3-NEXT: DW_AT_ranges [DW_FORM_data8] (0x0000000000000000
# DUMP5-NEXT: DW_AT_ranges [DW_FORM_sec_offset] (0x0000000000000014
# DUMP-NEXT: [0x0000000000000000, 0x0000000000000001) ".foo"
# DUMP-NEXT: [0x0000000000000000, 0x0000000000000001) ".bar")
@@ -46,6 +61,13 @@
# DUMP5-NEXT: 0x00000000: "[[DIR]]"
# DUMP5-NEXT: 0x[[FILEOFF]]: "[[FILE]]"
+# DUMP3: .debug_ranges contents:
+# DUMP3-NEXT: 00000000 ffffffffffffffff 0000000000000000
+# DUMP3-NEXT: 00000000 0000000000000000 0000000000000001
+# DUMP3-NEXT: 00000000 ffffffffffffffff 0000000000000000
+# DUMP3-NEXT: 00000000 0000000000000000 0000000000000001
+# DUMP3-NEXT: 00000000 <End of list>
+
# DUMP5: .debug_rnglists contents:
# DUMP5-NEXT: 0x00000000: range list header:
# DUMP5-SAME: format = DWARF64
Index: llvm/lib/MC/MCDwarf.cpp
===================================================================
--- llvm/lib/MC/MCDwarf.cpp
+++ llvm/lib/MC/MCDwarf.cpp
@@ -833,14 +833,15 @@
MCOS->emitULEB128IntValue(1);
MCOS->emitULEB128IntValue(dwarf::DW_TAG_compile_unit);
MCOS->emitInt8(dwarf::DW_CHILDREN_yes);
- EmitAbbrev(MCOS, dwarf::DW_AT_stmt_list, context.getDwarfVersion() >= 4
- ? dwarf::DW_FORM_sec_offset
- : dwarf::DW_FORM_data4);
+ dwarf::Form SecOffsetForm =
+ context.getDwarfVersion() >= 4
+ ? dwarf::DW_FORM_sec_offset
+ : (context.getDwarfFormat() == dwarf::DWARF64 ? dwarf::DW_FORM_data8
+ : dwarf::DW_FORM_data4);
+ EmitAbbrev(MCOS, dwarf::DW_AT_stmt_list, SecOffsetForm);
if (context.getGenDwarfSectionSyms().size() > 1 &&
context.getDwarfVersion() >= 3) {
- EmitAbbrev(MCOS, dwarf::DW_AT_ranges, context.getDwarfVersion() >= 4
- ? dwarf::DW_FORM_sec_offset
- : dwarf::DW_FORM_data4);
+ EmitAbbrev(MCOS, dwarf::DW_AT_ranges, SecOffsetForm);
} else {
EmitAbbrev(MCOS, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr);
EmitAbbrev(MCOS, dwarf::DW_AT_high_pc, dwarf::DW_FORM_addr);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81148.268431.patch
Type: text/x-patch
Size: 4035 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200604/ef65b0af/attachment.bin>
More information about the llvm-commits
mailing list