The GSoC'20 comes to an end. My project is adding DWARF support to
yaml2obj. Now, the usability of yaml2obj is improved. Some of the
outstanding improvements are listed below:
* The Length fields of DWARF sections are replaced with Format and Length.
At first, we have to hardcode the TotalLength and TotalLength64 fields
to instruct the tool to emit a proper DWARF32 or a DWARF64 section,
## To handcraft a DWARF32 debug_aranges section. debug_aranges: - Length: TotalLength: 0x1234 Version: 2 ... ## To handcraft a DWARF64 debug_aranges section. debug_aranges: - Length: TotalLength: 0xffffffff TotalLength64: 0x1234 Version: 2 ...
Now, yaml2obj emits DWARF32 sections by default and the Length field
can be omitted, yaml2obj will calculate it for us (Patches that
address this issue: ⚙ D82622 [DWARFYAML][debug_info] Replace 'InitialLength' with 'Format' and 'Length'. ,
⚙ D85880 [DWARFYAML] Replace InitialLength with Format and Length. NFC. , ⚙ D81063 [DWARFYAML][debug_aranges] Replace InitialLength with Format and Length. ,
⚙ D84008 [DWARFYAML] Refactor emitDebugInfo() to make the length be inferred. , ⚙ D86590 [DWARFYAML] Make the unit_length and header_length fields optional. ,
⚙ D84911 [DWARFYAML] Make the 'Length' field of the address range table optional. ).
* yaml2obj supports emitting multiple abbrev tables.
yaml2obj only supported emitting a single abbrev table and multiple
compilation units had to share the same abbrev table before
⚙ D86194 [DWARFYAML] Add support for emitting multiple abbrev tables. and ⚙ D83116 [DWARFYAML] Add support for referencing different abbrev tables. .
Now, yaml2obj is able to emit multiple abbrev tables and compilation
units can be linked to any one of them. We add an optional field ID to
abbrev tables and an optional field AbbrevTableID to compilation
units. Compilation units can use AbbrevTableID to link the abbrev
table with the same ID. Besides, the AbbrOffset field of compilation
units which corresponds to the debug_abbrev_offset field doesn't need
to be specified anymore. yaml2obj is able to calculate it for us after
⚙ D86614 [DWARFYAML] Make the debug_abbrev_offset field optional. .
debug_abbrev: - ID: 0 Table: ... - ID: 1 Table: ... debug_info: - ... AbbrevTableID: 1 ## Reference the second abbrev table. ## AbbrOffset: ... yaml2obj will take care of it. - ... AbbrevTableID: 0 ## Reference the first abbrev table. ## AbbrOffset: ... yaml2obj will take care of it.
* The debug_str_offsets, debug_addr, debug_rnglists and debug_loclists
are supported in yaml2obj.
Check out ⚙ D83624 [DWARFYAML] Implement the .debug_rnglists section. ,
⚙ D84234 [DWARFYAML] Implement the .debug_loclists section. , ⚙ D81541 [ObjectYAML][DWARF] Implement the .debug_addr section. and
⚙ D83853 [DWARFYAML] Implement the .debug_str_offsets section. for more information!
* The DWARF support is added to elf2yaml and improved in macho2yaml.
At first, the output of macho2yaml is noisy. It dumps the DWARF
sections twice, one in the Sections: entry and one in the DWARF:
## The content of the debug_str section is dumped twice! Sections: - sectname: __debug_str ... content: 6D61696E00 ## "main\0" DWARF: debug_str: - main
After ⚙ D85506 [macho2yaml] Refactor the DWARF section dumpers. , if the DWARF parser fails to
parse the DWARF sections into the DWARF: entry, obj2yaml will dump
them as raw content sections, otherwise, they will be presented as
structured DWARF sections in the DWARF: entry. Besides,
⚙ D85094 [obj2yaml] Add support for dumping the .debug_aranges section. adds DWARF support to elf2yaml.
Although it only supports dumping the debug_aranges section, we can
easily extend it in the future.