forked from OSchip/llvm-project
[Debuginfo][llvm-dwarfutil] Add check for unsupported debug sections.
Current DWARFLinker implementation does not support some debug sections (mainly DWARF v5 sections). This patch adds diagnostic for such sections. The warning would be displayed for critical(such that could not be removed) sections and the source file would be skipped. Other unsupported sections would be removed and warning message should be displayed. The zero exit status would be returned for both cases. Reviewed By: JDevlieghere Differential Revision: https://reviews.llvm.org/D123623
This commit is contained in:
parent
418d2338f9
commit
0d191b7553
|
@ -245,7 +245,7 @@ public:
|
||||||
|
|
||||||
/// Link debug info for added objFiles. Object
|
/// Link debug info for added objFiles. Object
|
||||||
/// files are linked all together.
|
/// files are linked all together.
|
||||||
bool link();
|
Error link();
|
||||||
|
|
||||||
/// A number of methods setting various linking options:
|
/// A number of methods setting various linking options:
|
||||||
|
|
||||||
|
|
|
@ -2343,7 +2343,7 @@ void DWARFLinker::addObjectFile(DWARFFile &File) {
|
||||||
updateAccelKind(*ObjectContexts.back().File.Dwarf);
|
updateAccelKind(*ObjectContexts.back().File.Dwarf);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DWARFLinker::link() {
|
Error DWARFLinker::link() {
|
||||||
assert(Options.NoOutput || TheDwarfEmitter);
|
assert(Options.NoOutput || TheDwarfEmitter);
|
||||||
|
|
||||||
// A unique ID that identifies each compile unit.
|
// A unique ID that identifies each compile unit.
|
||||||
|
@ -2410,6 +2410,55 @@ bool DWARFLinker::link() {
|
||||||
if (!OptContext.File.Dwarf)
|
if (!OptContext.File.Dwarf)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
// Check whether type units are presented.
|
||||||
|
if (!OptContext.File.Dwarf->types_section_units().empty()) {
|
||||||
|
reportWarning("type units are not currently supported: file will "
|
||||||
|
"be skipped",
|
||||||
|
OptContext.File);
|
||||||
|
OptContext.Skip = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for unsupported sections. Following sections can be referenced
|
||||||
|
// from .debug_info section. Current DWARFLinker implementation does not
|
||||||
|
// support or update references to these tables. Thus we report warning
|
||||||
|
// and skip corresponding object file.
|
||||||
|
if (!OptContext.File.Dwarf->getDWARFObj()
|
||||||
|
.getRnglistsSection()
|
||||||
|
.Data.empty()) {
|
||||||
|
reportWarning("'.debug_rnglists' is not currently supported: file "
|
||||||
|
"will be skipped",
|
||||||
|
OptContext.File);
|
||||||
|
OptContext.Skip = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!OptContext.File.Dwarf->getDWARFObj()
|
||||||
|
.getLoclistsSection()
|
||||||
|
.Data.empty()) {
|
||||||
|
reportWarning("'.debug_loclists' is not currently supported: file "
|
||||||
|
"will be skipped",
|
||||||
|
OptContext.File);
|
||||||
|
OptContext.Skip = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!OptContext.File.Dwarf->getDWARFObj().getMacroSection().Data.empty()) {
|
||||||
|
reportWarning("'.debug_macro' is not currently supported: file "
|
||||||
|
"will be skipped",
|
||||||
|
OptContext.File);
|
||||||
|
OptContext.Skip = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (OptContext.File.Dwarf->getDWARFObj().getMacinfoSection().size() > 1) {
|
||||||
|
reportWarning("'.debug_macinfo' is not currently supported: file "
|
||||||
|
"will be skipped",
|
||||||
|
OptContext.File);
|
||||||
|
OptContext.Skip = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// In a first phase, just read in the debug info and load all clang modules.
|
// In a first phase, just read in the debug info and load all clang modules.
|
||||||
OptContext.CompileUnits.reserve(
|
OptContext.CompileUnits.reserve(
|
||||||
OptContext.File.Dwarf->getNumCompileUnits());
|
OptContext.File.Dwarf->getNumCompileUnits());
|
||||||
|
@ -2660,7 +2709,7 @@ bool DWARFLinker::link() {
|
||||||
"---------------\n\n";
|
"---------------\n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return Error::success();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DWARFLinker::verify(const DWARFFile &File) {
|
bool DWARFLinker::verify(const DWARFFile &File) {
|
||||||
|
|
Binary file not shown.
|
@ -0,0 +1,54 @@
|
||||||
|
## This test checks the warning message displayed if input file
|
||||||
|
## contains .debug_cu_index section.
|
||||||
|
|
||||||
|
# RUN: yaml2obj %s -o %t.o
|
||||||
|
|
||||||
|
# RUN: llvm-dwarfutil --garbage-collection %t.o %t1 2>&1 | FileCheck %s -DFILE=%t.o
|
||||||
|
|
||||||
|
# CHECK: [[FILE]]: warning: '.debug_cu_index' is not currently supported: section will be skipped
|
||||||
|
|
||||||
|
--- !ELF
|
||||||
|
FileHeader:
|
||||||
|
Class: ELFCLASS64
|
||||||
|
Data: ELFDATA2LSB
|
||||||
|
Type: ET_REL
|
||||||
|
Machine: EM_X86_64
|
||||||
|
Sections:
|
||||||
|
- Name: .text
|
||||||
|
Type: SHT_PROGBITS
|
||||||
|
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
|
||||||
|
Address: 0x1000
|
||||||
|
AddressAlign: 0x0000000000000010
|
||||||
|
Content: "FFFFFFFF"
|
||||||
|
- Name: .debug_cu_index
|
||||||
|
Type: SHT_PROGBITS
|
||||||
|
Flags: [ ]
|
||||||
|
Content: "0000"
|
||||||
|
DWARF:
|
||||||
|
debug_abbrev:
|
||||||
|
- Table:
|
||||||
|
- Tag: DW_TAG_compile_unit
|
||||||
|
Children: DW_CHILDREN_yes
|
||||||
|
Attributes:
|
||||||
|
- Attribute: DW_AT_producer
|
||||||
|
Form: DW_FORM_string
|
||||||
|
- Attribute: DW_AT_language
|
||||||
|
Form: DW_FORM_data2
|
||||||
|
- Attribute: DW_AT_name
|
||||||
|
Form: DW_FORM_string
|
||||||
|
- Attribute: DW_AT_low_pc
|
||||||
|
Form: DW_FORM_addr
|
||||||
|
- Attribute: DW_AT_high_pc
|
||||||
|
Form: DW_FORM_data8
|
||||||
|
debug_info:
|
||||||
|
- Version: 4
|
||||||
|
Entries:
|
||||||
|
- AbbrCode: 1
|
||||||
|
Values:
|
||||||
|
- CStr: by_hand
|
||||||
|
- Value: 0x04
|
||||||
|
- CStr: CU1
|
||||||
|
- Value: 0x1000
|
||||||
|
- Value: 0x4
|
||||||
|
- AbbrCode: 0
|
||||||
|
...
|
|
@ -0,0 +1,54 @@
|
||||||
|
## This test checks the warning message displayed if input file
|
||||||
|
## contains .gdb_index section.
|
||||||
|
|
||||||
|
# RUN: yaml2obj %s -o %t.o
|
||||||
|
|
||||||
|
# RUN: llvm-dwarfutil --garbage-collection %t.o %t1 2>&1 | FileCheck %s -DFILE=%t.o
|
||||||
|
|
||||||
|
# CHECK: [[FILE]]: warning: '.gdb_index' is not currently supported: section will be skipped
|
||||||
|
|
||||||
|
--- !ELF
|
||||||
|
FileHeader:
|
||||||
|
Class: ELFCLASS64
|
||||||
|
Data: ELFDATA2LSB
|
||||||
|
Type: ET_REL
|
||||||
|
Machine: EM_X86_64
|
||||||
|
Sections:
|
||||||
|
- Name: .text
|
||||||
|
Type: SHT_PROGBITS
|
||||||
|
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
|
||||||
|
Address: 0x1000
|
||||||
|
AddressAlign: 0x0000000000000010
|
||||||
|
Content: "FFFFFFFF"
|
||||||
|
- Name: .gdb_index
|
||||||
|
Type: SHT_PROGBITS
|
||||||
|
Flags: [ ]
|
||||||
|
Content: "0000"
|
||||||
|
DWARF:
|
||||||
|
debug_abbrev:
|
||||||
|
- Table:
|
||||||
|
- Tag: DW_TAG_compile_unit
|
||||||
|
Children: DW_CHILDREN_yes
|
||||||
|
Attributes:
|
||||||
|
- Attribute: DW_AT_producer
|
||||||
|
Form: DW_FORM_string
|
||||||
|
- Attribute: DW_AT_language
|
||||||
|
Form: DW_FORM_data2
|
||||||
|
- Attribute: DW_AT_name
|
||||||
|
Form: DW_FORM_string
|
||||||
|
- Attribute: DW_AT_low_pc
|
||||||
|
Form: DW_FORM_addr
|
||||||
|
- Attribute: DW_AT_high_pc
|
||||||
|
Form: DW_FORM_data8
|
||||||
|
debug_info:
|
||||||
|
- Version: 4
|
||||||
|
Entries:
|
||||||
|
- AbbrCode: 1
|
||||||
|
Values:
|
||||||
|
- CStr: by_hand
|
||||||
|
- Value: 0x04
|
||||||
|
- CStr: CU1
|
||||||
|
- Value: 0x1000
|
||||||
|
- Value: 0x4
|
||||||
|
- AbbrCode: 0
|
||||||
|
...
|
|
@ -0,0 +1,54 @@
|
||||||
|
## This test checks the warning message displayed if input file
|
||||||
|
## contains .debug_pubnames section.
|
||||||
|
|
||||||
|
# RUN: yaml2obj %s -o %t.o
|
||||||
|
|
||||||
|
# RUN: llvm-dwarfutil --garbage-collection %t.o %t1 2>&1 | FileCheck %s -DFILE=%t.o
|
||||||
|
|
||||||
|
# CHECK: [[FILE]]: warning: '.debug_gnu_pubnames' is not currently supported: section will be skipped
|
||||||
|
|
||||||
|
--- !ELF
|
||||||
|
FileHeader:
|
||||||
|
Class: ELFCLASS64
|
||||||
|
Data: ELFDATA2LSB
|
||||||
|
Type: ET_REL
|
||||||
|
Machine: EM_X86_64
|
||||||
|
Sections:
|
||||||
|
- Name: .text
|
||||||
|
Type: SHT_PROGBITS
|
||||||
|
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
|
||||||
|
Address: 0x1000
|
||||||
|
AddressAlign: 0x0000000000000010
|
||||||
|
Content: "FFFFFFFF"
|
||||||
|
- Name: .debug_gnu_pubnames
|
||||||
|
Type: SHT_PROGBITS
|
||||||
|
Flags: [ ]
|
||||||
|
Content: "0000"
|
||||||
|
DWARF:
|
||||||
|
debug_abbrev:
|
||||||
|
- Table:
|
||||||
|
- Tag: DW_TAG_compile_unit
|
||||||
|
Children: DW_CHILDREN_yes
|
||||||
|
Attributes:
|
||||||
|
- Attribute: DW_AT_producer
|
||||||
|
Form: DW_FORM_string
|
||||||
|
- Attribute: DW_AT_language
|
||||||
|
Form: DW_FORM_data2
|
||||||
|
- Attribute: DW_AT_name
|
||||||
|
Form: DW_FORM_string
|
||||||
|
- Attribute: DW_AT_low_pc
|
||||||
|
Form: DW_FORM_addr
|
||||||
|
- Attribute: DW_AT_high_pc
|
||||||
|
Form: DW_FORM_data8
|
||||||
|
debug_info:
|
||||||
|
- Version: 4
|
||||||
|
Entries:
|
||||||
|
- AbbrCode: 1
|
||||||
|
Values:
|
||||||
|
- CStr: by_hand
|
||||||
|
- Value: 0x04
|
||||||
|
- CStr: CU1
|
||||||
|
- Value: 0x1000
|
||||||
|
- Value: 0x4
|
||||||
|
- AbbrCode: 0
|
||||||
|
...
|
|
@ -0,0 +1,54 @@
|
||||||
|
## This test checks the warning message displayed if input file
|
||||||
|
## contains .debug_gnu_pubtypes section.
|
||||||
|
|
||||||
|
# RUN: yaml2obj %s -o %t.o
|
||||||
|
|
||||||
|
# RUN: llvm-dwarfutil --garbage-collection %t.o %t1 2>&1 | FileCheck %s -DFILE=%t.o
|
||||||
|
|
||||||
|
# CHECK: [[FILE]]: warning: '.debug_gnu_pubtypes' is not currently supported: section will be skipped
|
||||||
|
|
||||||
|
--- !ELF
|
||||||
|
FileHeader:
|
||||||
|
Class: ELFCLASS64
|
||||||
|
Data: ELFDATA2LSB
|
||||||
|
Type: ET_REL
|
||||||
|
Machine: EM_X86_64
|
||||||
|
Sections:
|
||||||
|
- Name: .text
|
||||||
|
Type: SHT_PROGBITS
|
||||||
|
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
|
||||||
|
Address: 0x1000
|
||||||
|
AddressAlign: 0x0000000000000010
|
||||||
|
Content: "FFFFFFFF"
|
||||||
|
- Name: .debug_gnu_pubtypes
|
||||||
|
Type: SHT_PROGBITS
|
||||||
|
Flags: [ ]
|
||||||
|
Content: "0000"
|
||||||
|
DWARF:
|
||||||
|
debug_abbrev:
|
||||||
|
- Table:
|
||||||
|
- Tag: DW_TAG_compile_unit
|
||||||
|
Children: DW_CHILDREN_yes
|
||||||
|
Attributes:
|
||||||
|
- Attribute: DW_AT_producer
|
||||||
|
Form: DW_FORM_string
|
||||||
|
- Attribute: DW_AT_language
|
||||||
|
Form: DW_FORM_data2
|
||||||
|
- Attribute: DW_AT_name
|
||||||
|
Form: DW_FORM_string
|
||||||
|
- Attribute: DW_AT_low_pc
|
||||||
|
Form: DW_FORM_addr
|
||||||
|
- Attribute: DW_AT_high_pc
|
||||||
|
Form: DW_FORM_data8
|
||||||
|
debug_info:
|
||||||
|
- Version: 4
|
||||||
|
Entries:
|
||||||
|
- AbbrCode: 1
|
||||||
|
Values:
|
||||||
|
- CStr: by_hand
|
||||||
|
- Value: 0x04
|
||||||
|
- CStr: CU1
|
||||||
|
- Value: 0x1000
|
||||||
|
- Value: 0x4
|
||||||
|
- AbbrCode: 0
|
||||||
|
...
|
|
@ -0,0 +1,54 @@
|
||||||
|
## This test checks the warning message displayed if input file
|
||||||
|
## contains .debug_loclists section.
|
||||||
|
|
||||||
|
# RUN: yaml2obj %s -o %t.o
|
||||||
|
|
||||||
|
# RUN: llvm-dwarfutil --garbage-collection %t.o %t1 2>&1 | FileCheck %s -DFILE=%t.o
|
||||||
|
|
||||||
|
# CHECK: [[FILE]]: warning: '.debug_loclists' is not currently supported: file will be skipped
|
||||||
|
|
||||||
|
--- !ELF
|
||||||
|
FileHeader:
|
||||||
|
Class: ELFCLASS64
|
||||||
|
Data: ELFDATA2LSB
|
||||||
|
Type: ET_REL
|
||||||
|
Machine: EM_X86_64
|
||||||
|
Sections:
|
||||||
|
- Name: .text
|
||||||
|
Type: SHT_PROGBITS
|
||||||
|
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
|
||||||
|
Address: 0x1000
|
||||||
|
AddressAlign: 0x0000000000000010
|
||||||
|
Content: "FFFFFFFF"
|
||||||
|
- Name: .debug_loclists
|
||||||
|
Type: SHT_PROGBITS
|
||||||
|
Flags: [ ]
|
||||||
|
Content: "0000000000000000000000"
|
||||||
|
DWARF:
|
||||||
|
debug_abbrev:
|
||||||
|
- Table:
|
||||||
|
- Tag: DW_TAG_compile_unit
|
||||||
|
Children: DW_CHILDREN_yes
|
||||||
|
Attributes:
|
||||||
|
- Attribute: DW_AT_producer
|
||||||
|
Form: DW_FORM_string
|
||||||
|
- Attribute: DW_AT_language
|
||||||
|
Form: DW_FORM_data2
|
||||||
|
- Attribute: DW_AT_name
|
||||||
|
Form: DW_FORM_string
|
||||||
|
- Attribute: DW_AT_low_pc
|
||||||
|
Form: DW_FORM_addr
|
||||||
|
- Attribute: DW_AT_high_pc
|
||||||
|
Form: DW_FORM_data8
|
||||||
|
debug_info:
|
||||||
|
- Version: 4
|
||||||
|
Entries:
|
||||||
|
- AbbrCode: 1
|
||||||
|
Values:
|
||||||
|
- CStr: by_hand
|
||||||
|
- Value: 0x04
|
||||||
|
- CStr: CU1
|
||||||
|
- Value: 0x1000
|
||||||
|
- Value: 0x4
|
||||||
|
- AbbrCode: 0
|
||||||
|
...
|
|
@ -0,0 +1,54 @@
|
||||||
|
## This test checks the warning message displayed if input file
|
||||||
|
## contains .debug_macinfo section.
|
||||||
|
|
||||||
|
# RUN: yaml2obj %s -o %t.o
|
||||||
|
|
||||||
|
# RUN: llvm-dwarfutil --garbage-collection %t.o %t1 2>&1 | FileCheck %s -DFILE=%t.o
|
||||||
|
|
||||||
|
# CHECK: [[FILE]]: warning: '.debug_macinfo' is not currently supported: file will be skipped
|
||||||
|
|
||||||
|
--- !ELF
|
||||||
|
FileHeader:
|
||||||
|
Class: ELFCLASS64
|
||||||
|
Data: ELFDATA2LSB
|
||||||
|
Type: ET_REL
|
||||||
|
Machine: EM_X86_64
|
||||||
|
Sections:
|
||||||
|
- Name: .text
|
||||||
|
Type: SHT_PROGBITS
|
||||||
|
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
|
||||||
|
Address: 0x1000
|
||||||
|
AddressAlign: 0x0000000000000010
|
||||||
|
Content: "FFFFFFFF"
|
||||||
|
- Name: .debug_macinfo
|
||||||
|
Type: SHT_PROGBITS
|
||||||
|
Flags: [ ]
|
||||||
|
Content: "0000"
|
||||||
|
DWARF:
|
||||||
|
debug_abbrev:
|
||||||
|
- Table:
|
||||||
|
- Tag: DW_TAG_compile_unit
|
||||||
|
Children: DW_CHILDREN_yes
|
||||||
|
Attributes:
|
||||||
|
- Attribute: DW_AT_producer
|
||||||
|
Form: DW_FORM_string
|
||||||
|
- Attribute: DW_AT_language
|
||||||
|
Form: DW_FORM_data2
|
||||||
|
- Attribute: DW_AT_name
|
||||||
|
Form: DW_FORM_string
|
||||||
|
- Attribute: DW_AT_low_pc
|
||||||
|
Form: DW_FORM_addr
|
||||||
|
- Attribute: DW_AT_high_pc
|
||||||
|
Form: DW_FORM_data8
|
||||||
|
debug_info:
|
||||||
|
- Version: 4
|
||||||
|
Entries:
|
||||||
|
- AbbrCode: 1
|
||||||
|
Values:
|
||||||
|
- CStr: by_hand
|
||||||
|
- Value: 0x04
|
||||||
|
- CStr: CU1
|
||||||
|
- Value: 0x1000
|
||||||
|
- Value: 0x4
|
||||||
|
- AbbrCode: 0
|
||||||
|
...
|
|
@ -0,0 +1,54 @@
|
||||||
|
## This test checks the warning message displayed if input file
|
||||||
|
## contains .debug_macro section.
|
||||||
|
|
||||||
|
# RUN: yaml2obj %s -o %t.o
|
||||||
|
|
||||||
|
# RUN: llvm-dwarfutil --garbage-collection %t.o %t1 2>&1 | FileCheck %s -DFILE=%t.o
|
||||||
|
|
||||||
|
# CHECK: [[FILE]]: warning: '.debug_macro' is not currently supported: file will be skipped
|
||||||
|
|
||||||
|
--- !ELF
|
||||||
|
FileHeader:
|
||||||
|
Class: ELFCLASS64
|
||||||
|
Data: ELFDATA2LSB
|
||||||
|
Type: ET_REL
|
||||||
|
Machine: EM_X86_64
|
||||||
|
Sections:
|
||||||
|
- Name: .text
|
||||||
|
Type: SHT_PROGBITS
|
||||||
|
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
|
||||||
|
Address: 0x1000
|
||||||
|
AddressAlign: 0x0000000000000010
|
||||||
|
Content: "FFFFFFFF"
|
||||||
|
- Name: .debug_macro
|
||||||
|
Type: SHT_PROGBITS
|
||||||
|
Flags: [ ]
|
||||||
|
Content: "0000"
|
||||||
|
DWARF:
|
||||||
|
debug_abbrev:
|
||||||
|
- Table:
|
||||||
|
- Tag: DW_TAG_compile_unit
|
||||||
|
Children: DW_CHILDREN_yes
|
||||||
|
Attributes:
|
||||||
|
- Attribute: DW_AT_producer
|
||||||
|
Form: DW_FORM_string
|
||||||
|
- Attribute: DW_AT_language
|
||||||
|
Form: DW_FORM_data2
|
||||||
|
- Attribute: DW_AT_name
|
||||||
|
Form: DW_FORM_string
|
||||||
|
- Attribute: DW_AT_low_pc
|
||||||
|
Form: DW_FORM_addr
|
||||||
|
- Attribute: DW_AT_high_pc
|
||||||
|
Form: DW_FORM_data8
|
||||||
|
debug_info:
|
||||||
|
- Version: 4
|
||||||
|
Entries:
|
||||||
|
- AbbrCode: 1
|
||||||
|
Values:
|
||||||
|
- CStr: by_hand
|
||||||
|
- Value: 0x04
|
||||||
|
- CStr: CU1
|
||||||
|
- Value: 0x1000
|
||||||
|
- Value: 0x4
|
||||||
|
- AbbrCode: 0
|
||||||
|
...
|
|
@ -0,0 +1,54 @@
|
||||||
|
## This test checks the warning message displayed if input file
|
||||||
|
## contains .debug_names section.
|
||||||
|
|
||||||
|
# RUN: yaml2obj %s -o %t.o
|
||||||
|
|
||||||
|
# RUN: llvm-dwarfutil --garbage-collection %t.o %t1 2>&1 | FileCheck %s -DFILE=%t.o
|
||||||
|
|
||||||
|
# CHECK: [[FILE]]: warning: '.debug_names' is not currently supported: section will be skipped
|
||||||
|
|
||||||
|
--- !ELF
|
||||||
|
FileHeader:
|
||||||
|
Class: ELFCLASS64
|
||||||
|
Data: ELFDATA2LSB
|
||||||
|
Type: ET_REL
|
||||||
|
Machine: EM_X86_64
|
||||||
|
Sections:
|
||||||
|
- Name: .text
|
||||||
|
Type: SHT_PROGBITS
|
||||||
|
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
|
||||||
|
Address: 0x1000
|
||||||
|
AddressAlign: 0x0000000000000010
|
||||||
|
Content: "FFFFFFFF"
|
||||||
|
- Name: .debug_names
|
||||||
|
Type: SHT_PROGBITS
|
||||||
|
Flags: [ ]
|
||||||
|
Content: "0000"
|
||||||
|
DWARF:
|
||||||
|
debug_abbrev:
|
||||||
|
- Table:
|
||||||
|
- Tag: DW_TAG_compile_unit
|
||||||
|
Children: DW_CHILDREN_yes
|
||||||
|
Attributes:
|
||||||
|
- Attribute: DW_AT_producer
|
||||||
|
Form: DW_FORM_string
|
||||||
|
- Attribute: DW_AT_language
|
||||||
|
Form: DW_FORM_data2
|
||||||
|
- Attribute: DW_AT_name
|
||||||
|
Form: DW_FORM_string
|
||||||
|
- Attribute: DW_AT_low_pc
|
||||||
|
Form: DW_FORM_addr
|
||||||
|
- Attribute: DW_AT_high_pc
|
||||||
|
Form: DW_FORM_data8
|
||||||
|
debug_info:
|
||||||
|
- Version: 4
|
||||||
|
Entries:
|
||||||
|
- AbbrCode: 1
|
||||||
|
Values:
|
||||||
|
- CStr: by_hand
|
||||||
|
- Value: 0x04
|
||||||
|
- CStr: CU1
|
||||||
|
- Value: 0x1000
|
||||||
|
- Value: 0x4
|
||||||
|
- AbbrCode: 0
|
||||||
|
...
|
|
@ -0,0 +1,54 @@
|
||||||
|
## This test checks the warning message displayed if input file
|
||||||
|
## contains .debug_pubnames section.
|
||||||
|
|
||||||
|
# RUN: yaml2obj %s -o %t.o
|
||||||
|
|
||||||
|
# RUN: llvm-dwarfutil --garbage-collection %t.o %t1 2>&1 | FileCheck %s -DFILE=%t.o
|
||||||
|
|
||||||
|
# CHECK: [[FILE]]: warning: '.debug_pubnames' is not currently supported: section will be skipped
|
||||||
|
|
||||||
|
--- !ELF
|
||||||
|
FileHeader:
|
||||||
|
Class: ELFCLASS64
|
||||||
|
Data: ELFDATA2LSB
|
||||||
|
Type: ET_REL
|
||||||
|
Machine: EM_X86_64
|
||||||
|
Sections:
|
||||||
|
- Name: .text
|
||||||
|
Type: SHT_PROGBITS
|
||||||
|
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
|
||||||
|
Address: 0x1000
|
||||||
|
AddressAlign: 0x0000000000000010
|
||||||
|
Content: "FFFFFFFF"
|
||||||
|
- Name: .debug_pubnames
|
||||||
|
Type: SHT_PROGBITS
|
||||||
|
Flags: [ ]
|
||||||
|
Content: "0000"
|
||||||
|
DWARF:
|
||||||
|
debug_abbrev:
|
||||||
|
- Table:
|
||||||
|
- Tag: DW_TAG_compile_unit
|
||||||
|
Children: DW_CHILDREN_yes
|
||||||
|
Attributes:
|
||||||
|
- Attribute: DW_AT_producer
|
||||||
|
Form: DW_FORM_string
|
||||||
|
- Attribute: DW_AT_language
|
||||||
|
Form: DW_FORM_data2
|
||||||
|
- Attribute: DW_AT_name
|
||||||
|
Form: DW_FORM_string
|
||||||
|
- Attribute: DW_AT_low_pc
|
||||||
|
Form: DW_FORM_addr
|
||||||
|
- Attribute: DW_AT_high_pc
|
||||||
|
Form: DW_FORM_data8
|
||||||
|
debug_info:
|
||||||
|
- Version: 4
|
||||||
|
Entries:
|
||||||
|
- AbbrCode: 1
|
||||||
|
Values:
|
||||||
|
- CStr: by_hand
|
||||||
|
- Value: 0x04
|
||||||
|
- CStr: CU1
|
||||||
|
- Value: 0x1000
|
||||||
|
- Value: 0x4
|
||||||
|
- AbbrCode: 0
|
||||||
|
...
|
|
@ -0,0 +1,54 @@
|
||||||
|
## This test checks the warning message displayed if input file
|
||||||
|
## contains .debug_pubtypes section.
|
||||||
|
|
||||||
|
# RUN: yaml2obj %s -o %t.o
|
||||||
|
|
||||||
|
# RUN: llvm-dwarfutil --garbage-collection %t.o %t1 2>&1 | FileCheck %s -DFILE=%t.o
|
||||||
|
|
||||||
|
# CHECK: [[FILE]]: warning: '.debug_pubtypes' is not currently supported: section will be skipped
|
||||||
|
|
||||||
|
--- !ELF
|
||||||
|
FileHeader:
|
||||||
|
Class: ELFCLASS64
|
||||||
|
Data: ELFDATA2LSB
|
||||||
|
Type: ET_REL
|
||||||
|
Machine: EM_X86_64
|
||||||
|
Sections:
|
||||||
|
- Name: .text
|
||||||
|
Type: SHT_PROGBITS
|
||||||
|
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
|
||||||
|
Address: 0x1000
|
||||||
|
AddressAlign: 0x0000000000000010
|
||||||
|
Content: "FFFFFFFF"
|
||||||
|
- Name: .debug_pubtypes
|
||||||
|
Type: SHT_PROGBITS
|
||||||
|
Flags: [ ]
|
||||||
|
Content: "0000"
|
||||||
|
DWARF:
|
||||||
|
debug_abbrev:
|
||||||
|
- Table:
|
||||||
|
- Tag: DW_TAG_compile_unit
|
||||||
|
Children: DW_CHILDREN_yes
|
||||||
|
Attributes:
|
||||||
|
- Attribute: DW_AT_producer
|
||||||
|
Form: DW_FORM_string
|
||||||
|
- Attribute: DW_AT_language
|
||||||
|
Form: DW_FORM_data2
|
||||||
|
- Attribute: DW_AT_name
|
||||||
|
Form: DW_FORM_string
|
||||||
|
- Attribute: DW_AT_low_pc
|
||||||
|
Form: DW_FORM_addr
|
||||||
|
- Attribute: DW_AT_high_pc
|
||||||
|
Form: DW_FORM_data8
|
||||||
|
debug_info:
|
||||||
|
- Version: 4
|
||||||
|
Entries:
|
||||||
|
- AbbrCode: 1
|
||||||
|
Values:
|
||||||
|
- CStr: by_hand
|
||||||
|
- Value: 0x04
|
||||||
|
- CStr: CU1
|
||||||
|
- Value: 0x1000
|
||||||
|
- Value: 0x4
|
||||||
|
- AbbrCode: 0
|
||||||
|
...
|
|
@ -0,0 +1,54 @@
|
||||||
|
## This test checks the warning message displayed if input file
|
||||||
|
## contains .debug_rnglists section.
|
||||||
|
|
||||||
|
# RUN: yaml2obj %s -o %t.o
|
||||||
|
|
||||||
|
# RUN: llvm-dwarfutil --garbage-collection %t.o %t1 2>&1 | FileCheck %s -DFILE=%t.o
|
||||||
|
|
||||||
|
# CHECK: [[FILE]]: warning: '.debug_rnglists' is not currently supported: file will be skipped
|
||||||
|
|
||||||
|
--- !ELF
|
||||||
|
FileHeader:
|
||||||
|
Class: ELFCLASS64
|
||||||
|
Data: ELFDATA2LSB
|
||||||
|
Type: ET_REL
|
||||||
|
Machine: EM_X86_64
|
||||||
|
Sections:
|
||||||
|
- Name: .text
|
||||||
|
Type: SHT_PROGBITS
|
||||||
|
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
|
||||||
|
Address: 0x1000
|
||||||
|
AddressAlign: 0x0000000000000010
|
||||||
|
Content: "FFFFFFFF"
|
||||||
|
- Name: .debug_rnglists
|
||||||
|
Type: SHT_PROGBITS
|
||||||
|
Flags: [ ]
|
||||||
|
Content: "0000"
|
||||||
|
DWARF:
|
||||||
|
debug_abbrev:
|
||||||
|
- Table:
|
||||||
|
- Tag: DW_TAG_compile_unit
|
||||||
|
Children: DW_CHILDREN_yes
|
||||||
|
Attributes:
|
||||||
|
- Attribute: DW_AT_producer
|
||||||
|
Form: DW_FORM_string
|
||||||
|
- Attribute: DW_AT_language
|
||||||
|
Form: DW_FORM_data2
|
||||||
|
- Attribute: DW_AT_name
|
||||||
|
Form: DW_FORM_string
|
||||||
|
- Attribute: DW_AT_low_pc
|
||||||
|
Form: DW_FORM_addr
|
||||||
|
- Attribute: DW_AT_high_pc
|
||||||
|
Form: DW_FORM_data8
|
||||||
|
debug_info:
|
||||||
|
- Version: 4
|
||||||
|
Entries:
|
||||||
|
- AbbrCode: 1
|
||||||
|
Values:
|
||||||
|
- CStr: by_hand
|
||||||
|
- Value: 0x04
|
||||||
|
- CStr: CU1
|
||||||
|
- Value: 0x1000
|
||||||
|
- Value: 0x4
|
||||||
|
- AbbrCode: 0
|
||||||
|
...
|
|
@ -0,0 +1,6 @@
|
||||||
|
## This test checks the warning message displayed if input file
|
||||||
|
## contains type units.
|
||||||
|
|
||||||
|
# RUN: llvm-dwarfutil --garbage-collection --tombstone=maxpc %p/Inputs/type-units.o %t1 2>&1 | FileCheck %s -DFILE=%p/Inputs/type-units.o
|
||||||
|
|
||||||
|
# CHECK: [[FILE]]: warning: type units are not currently supported: file will be skipped
|
|
@ -713,7 +713,8 @@ bool DwarfLinkerForBinary::link(const DebugMap &Map) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// link debug info for loaded object files.
|
// link debug info for loaded object files.
|
||||||
GeneralLinker.link();
|
if (Error E = GeneralLinker.link())
|
||||||
|
return error(toString(std::move(E)));
|
||||||
|
|
||||||
StringRef ArchName = Map.getTriple().getArchName();
|
StringRef ArchName = Map.getTriple().getArchName();
|
||||||
if (Error E = emitRemarks(Options, Map.getBinaryPath(), ArchName, RL))
|
if (Error E = emitRemarks(Options, Map.getBinaryPath(), ArchName, RL))
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
#include "DebugInfoLinker.h"
|
#include "DebugInfoLinker.h"
|
||||||
#include "Error.h"
|
#include "Error.h"
|
||||||
|
#include "llvm/ADT/StringSwitch.h"
|
||||||
#include "llvm/DWARFLinker/DWARFLinker.h"
|
#include "llvm/DWARFLinker/DWARFLinker.h"
|
||||||
#include "llvm/DWARFLinker/DWARFStreamer.h"
|
#include "llvm/DWARFLinker/DWARFStreamer.h"
|
||||||
#include "llvm/DebugInfo/DWARF/DWARFContext.h"
|
#include "llvm/DebugInfo/DWARF/DWARFContext.h"
|
||||||
|
@ -210,8 +211,29 @@ private:
|
||||||
const Options &Opts;
|
const Options &Opts;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool linkDebugInfo(object::ObjectFile &File, const Options &Options,
|
static bool knownByDWARFUtil(StringRef SecName) {
|
||||||
raw_pwrite_stream &OutStream) {
|
return llvm::StringSwitch<bool>(SecName)
|
||||||
|
.Case(".debug_info", true)
|
||||||
|
.Case(".debug_types", true)
|
||||||
|
.Case(".debug_abbrev", true)
|
||||||
|
.Case(".debug_loc", true)
|
||||||
|
.Case(".debug_loclists", true)
|
||||||
|
.Case(".debug_frame", true)
|
||||||
|
.Case(".debug_aranges", true)
|
||||||
|
.Case(".debug_ranges", true)
|
||||||
|
.Case(".debug_rnglists", true)
|
||||||
|
.Case(".debug_line", true)
|
||||||
|
.Case(".debug_line_str", true)
|
||||||
|
.Case(".debug_addr", true)
|
||||||
|
.Case(".debug_macro", true)
|
||||||
|
.Case(".debug_macinfo", true)
|
||||||
|
.Case(".debug_str", true)
|
||||||
|
.Case(".debug_str_offsets", true)
|
||||||
|
.Default(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
Error linkDebugInfo(object::ObjectFile &File, const Options &Options,
|
||||||
|
raw_pwrite_stream &OutStream) {
|
||||||
|
|
||||||
auto ReportWarn = [&](const Twine &Message, StringRef Context,
|
auto ReportWarn = [&](const Twine &Message, StringRef Context,
|
||||||
const DWARFDie *Die) {
|
const DWARFDie *Die) {
|
||||||
|
@ -235,8 +257,11 @@ bool linkDebugInfo(object::ObjectFile &File, const Options &Options,
|
||||||
// Create output streamer.
|
// Create output streamer.
|
||||||
DwarfStreamer OutStreamer(OutputFileType::Object, OutStream, nullptr,
|
DwarfStreamer OutStreamer(OutputFileType::Object, OutStream, nullptr,
|
||||||
ReportWarn, ReportWarn);
|
ReportWarn, ReportWarn);
|
||||||
if (!OutStreamer.init(File.makeTriple(), ""))
|
Triple TargetTriple = File.makeTriple();
|
||||||
return false;
|
if (!OutStreamer.init(TargetTriple, formatv("cannot create a stream for {0}",
|
||||||
|
TargetTriple.getTriple())
|
||||||
|
.str()))
|
||||||
|
return createStringError(std::errc::invalid_argument, "");
|
||||||
|
|
||||||
// Create DWARF linker.
|
// Create DWARF linker.
|
||||||
DWARFLinker DebugInfoLinker(&OutStreamer, DwarfLinkerClient::LLD);
|
DWARFLinker DebugInfoLinker(&OutStreamer, DwarfLinkerClient::LLD);
|
||||||
|
@ -256,6 +281,16 @@ bool linkDebugInfo(object::ObjectFile &File, const Options &Options,
|
||||||
|
|
||||||
std::unique_ptr<DWARFContext> Context = DWARFContext::create(File);
|
std::unique_ptr<DWARFContext> Context = DWARFContext::create(File);
|
||||||
|
|
||||||
|
// Unknown debug sections would be removed. Display warning
|
||||||
|
// for such sections.
|
||||||
|
for (SectionName Sec : Context->getDWARFObj().getSectionNames()) {
|
||||||
|
if (isDebugSection(Sec.Name) && !knownByDWARFUtil(Sec.Name))
|
||||||
|
warning(
|
||||||
|
formatv("'{0}' is not currently supported: section will be skipped",
|
||||||
|
Sec.Name),
|
||||||
|
Options.InputFileName);
|
||||||
|
}
|
||||||
|
|
||||||
// Add object files to the DWARFLinker.
|
// Add object files to the DWARFLinker.
|
||||||
AddresssMapForLinking[0] =
|
AddresssMapForLinking[0] =
|
||||||
std::make_unique<ObjFileAddressMap>(*Context, Options, File);
|
std::make_unique<ObjFileAddressMap>(*Context, Options, File);
|
||||||
|
@ -268,9 +303,11 @@ bool linkDebugInfo(object::ObjectFile &File, const Options &Options,
|
||||||
DebugInfoLinker.addObjectFile(*ObjectsForLinking[I]);
|
DebugInfoLinker.addObjectFile(*ObjectsForLinking[I]);
|
||||||
|
|
||||||
// Link debug info.
|
// Link debug info.
|
||||||
DebugInfoLinker.link();
|
if (Error Err = DebugInfoLinker.link())
|
||||||
|
return Err;
|
||||||
|
|
||||||
OutStreamer.finish();
|
OutStreamer.finish();
|
||||||
return true;
|
return Error::success();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end of namespace dwarfutil
|
} // end of namespace dwarfutil
|
||||||
|
|
|
@ -22,8 +22,8 @@ inline bool isDebugSection(StringRef SecName) {
|
||||||
SecName == ".gdb_index";
|
SecName == ".gdb_index";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool linkDebugInfo(object::ObjectFile &file, const Options &Options,
|
Error linkDebugInfo(object::ObjectFile &file, const Options &Options,
|
||||||
raw_pwrite_stream &OutStream);
|
raw_pwrite_stream &OutStream);
|
||||||
|
|
||||||
} // end of namespace dwarfutil
|
} // end of namespace dwarfutil
|
||||||
} // end of namespace llvm
|
} // end of namespace llvm
|
||||||
|
|
|
@ -426,16 +426,14 @@ static Error applyCLOptions(const struct Options &Opts, ObjectFile &InputFile) {
|
||||||
DebugInfoBits LinkedDebugInfo;
|
DebugInfoBits LinkedDebugInfo;
|
||||||
raw_svector_ostream OutStream(LinkedDebugInfo);
|
raw_svector_ostream OutStream(LinkedDebugInfo);
|
||||||
|
|
||||||
if (linkDebugInfo(InputFile, Opts, OutStream)) {
|
if (Error Err = linkDebugInfo(InputFile, Opts, OutStream))
|
||||||
if (Error Err =
|
return Err;
|
||||||
saveLinkedDebugInfo(Opts, InputFile, std::move(LinkedDebugInfo)))
|
|
||||||
return Err;
|
|
||||||
|
|
||||||
return Error::success();
|
if (Error Err =
|
||||||
}
|
saveLinkedDebugInfo(Opts, InputFile, std::move(LinkedDebugInfo)))
|
||||||
|
return Err;
|
||||||
|
|
||||||
return createStringError(std::errc::invalid_argument,
|
return Error::success();
|
||||||
"possible broken debug info");
|
|
||||||
} else if (Opts.BuildSeparateDebugFile) {
|
} else if (Opts.BuildSeparateDebugFile) {
|
||||||
if (Error Err = splitDebugIntoSeparateFile(Opts, InputFile))
|
if (Error Err = splitDebugIntoSeparateFile(Opts, InputFile))
|
||||||
return Err;
|
return Err;
|
||||||
|
|
Loading…
Reference in New Issue