{"title":"My Journey with LLVM (GSoC'20 Phase 2)","date_published":"2020-07-30T07:31:21.000Z","tags":["post","GSoC","LLVM"],"attributes":[{"trait_type":"xlog_slug","value":"my-journey-with-llvm-ii"}],"content":"---\ntitle: \"My Journey with LLVM (GSoC'20 Phase 2)\"\ndate: 2020-07-30T15:31:21+08:00\ntags: [\"GSoC\", \"LLVM\"]\n---\n\nDuring the second coding period, we’ve implemented the `.debug_str_offsets`, `.debug_rnglists` and `.debug_loclists` section. We’re able to handcraft these 3 sections via the following syntax.\n\n\n| Section | Syntax |\n|:--------|:-------|\n| debug_str_offsets |
debug_str_offsets:|\n| debug_rnglists |
- Format: DWARF32 ## Optional
Length: 0x1234 ## Optional
Version: 5 ## Optional
Padding: 0x00 ## Optional
Offsets: [ 0x01, 0x02, 0x03 ]
debug_rnglists:|\n| debug_loclists
- Format: DWARF32 ## Optional
Length: 0x1234 ## Optional
Version: 5 ## Optional
AddressSize: 0x08 ## Optional
SegmentSelectorSize: 0x00 ## Optional
OffsetEntryCount: 2 ## Optional
Offsets: [ 0x01, 0x02 ] ## Optional
Lists:
- Entries:
- Operator: DW_RLE_blah
Values: [ 0x01, 0x02 ]
debug_loclists:|\n\nWe’ve also taught `yaml2obj` to infer the compilation unit’s length for us. Now, we’re able to handcraft the `.debug_info` section without caring about the length field.\n\n| Section | Syntax |\n|:--------|:-------|\n| debug_info |
- Format: DWARF32 ## Optional
Length: 0x1234 ## Optional
Version: 5 ## Optional
AddressSize: 8 ## Optional
SegmentSelectorSize: 0 ## Optional
OffsetEntryCount: 1 ## Optional
Offsets: [ 1 ] ## Optional
Lists:
- Entries:
- Operator: DW_LLE_blah
Values: [ 0x1234, 0x4321 ]
DescriptorsLength: 0x1234 ## Optional
Descriptors:
- Operator: DW_OP_blah
Values: [ 0x1234 ]
debug_info:|\n\nYou’ve probably noticed that we still have to calculate the `AbbrOffset` field manually and it makes handcrafting the `.debug_info` section a nightmare. In the next coding period, we’re going to address this issue and make `yaml2obj` able to interlink some DWARF sections. If time permits, we’d also like to add DWARF support to `obj2yaml`.\n\n### Areas in Need of Improvements\n\nIn the second coding period, I’m not good at splitting a huge change into several pieces of small patches which brings inconvenience to reviewers. I will try to avoid it in the future. Just as what James has pointed out, I should communicate more with others. When I was implementing these DWARF sections, I should learn about people’s requirements and ask others opinions rather than do it myself and implement what I have in my own mind. I haven’t realized it until I work on the `.debug_loclists` section. Pavel Labath gives me some good advice and comments that I haven’t thought of before!\n\n### Accepted Patches\n\nD84496 [[DWARFYAML] Replace 'Format', 'Version', etc with 'FormParams'. NFC.](https://reviews.llvm.org/D84496)
- Format: DWARF32 ## Optional
Length: 0x1234 ## Optional
Version: 4
AbbrOffset: 0x00
AddrSize: 0x08 ## Optional
Entries:
- AbbrCode: 1
Values:
- Value: 0x1234
- Value: 0x4321