Followed David feedback on emitting offset of macinfo entry into compiler unit DIE.
New code is using delta between labels rather than explicitly calculating size/offset of macro entry.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
Thanks for going through this again! I'll defer to dblaikie who is more familiar with this code than I am.
lib/CodeGen/AsmPrinter/DwarfDebug.cpp | ||
---|---|---|
627 ↗ | (On Diff #45173) | This seems wrong - a delta isn't a section offset. Once this DWARF is relocated (eg: linked with another object file containing DWARF) these deltas would become incorrect. A label delta is constant, not a dynamic/link time relocation - representing the distance between two labels. That doesn't change when the debug info is linked and multiple macinfo sections are concatenated together. But DWARF requires the sec_offset to represent the final offset within the section of the linked debug info. So I assume, much like DW_AT_stmt_list and DW_AT_ranges. Like those two attributes, I assume this one should be emitted using "addSectionOffset" to ensure it has the right kind of relocation, etc. (& on MachO it doesn't use a reloc - addSectionOffset handles that case too) |
lib/CodeGen/AsmPrinter/DwarfDebug.h | ||
211 ↗ | (On Diff #45173) | Rather than adding a map, the MCSymbol should probably just be part of the DwarfCompileUnit itself? (you can check DwarfCompileUnit::attachRangesOrLowHighPC, used to add DW_AT_ranges to the DW_TAG_compile_unit (& elsewhere) for some inspiration - though it won't match that exactly (that one builds a range list, keeps a label for it, attaches a reloc to that label, later on emits the range list with the label - some of that should be similar to what you need/want, without the need to build an intermediate data structure like the range list)) |
Thanks David for the comments.
I uploaded a new patch.
Please, let me know if this looks right now.
lib/CodeGen/AsmPrinter/DwarfDebug.cpp | ||
---|---|---|
627 ↗ | (On Diff #45173) | I should check more for similar cases before highjack the addLabelDelta. Thanks for pointing that out. Also, I had a bug there, because I wanted to calculate the offset from the beginning of the section and not from the previous section! I reverted the change in addLabelDelta function and now is using addSectionDelta function, hope that it is the right one. do you agree? |
lib/CodeGen/AsmPrinter/DwarfDebug.cpp | ||
---|---|---|
565 ↗ | (On Diff #45394) | We don't support non-existence of other DWARF sections (we don't generally check for null return from TLOF.getDwarf* functions elsewhere, so far as I can see/recall) - is there any reason we need to do it in this particular case? |
566 ↗ | (On Diff #45394) | I think this is the wrong API (looking at how setBeginSymbol is called elsewhere) to create the section start symbol - but in any case, again, we don't create section start symbols anywhere in the DWARF codegen, so I don't think we need to do it for Macro info either. We just rely on their existence in all other cases, it seems? It's probably worth doing a little test of your own to build two separate objects with macro info, link them together & check that dumping/values all make sense - that the two CU's references to their macinfo actually get relocated during linking, etc. (no need to commit a test like this - we could have a test that checks that there is a relocation for the macinfo attribute, but I'm not /too/ fussed about that, it's awkward and probably annoyingly platform specific, etc) |
629 ↗ | (On Diff #45394) | addSectionDelta isn't quite right - because it doesn't account for the MachO case where relocations are not used. DwarfCompileUnit::addSectionLabel handles this case and wraps addSectionDelta. |
1511 ↗ | (On Diff #45394) | Please commit these unrelated comment fixes separately. No need for further review on that, you can just commit them directly yourself. |
Thanks David for the comments.
I will upload a new patch soon.
lib/CodeGen/AsmPrinter/DwarfDebug.cpp | ||
---|---|---|
565 ↗ | (On Diff #45394) | No specific reason. Anyway, I removed the checks. |
566 ↗ | (On Diff #45394) | Sorry for my lack of understanding how the section handling works. I will do the manual test to verify that the generated object file is accepted by the linker. |
629 ↗ | (On Diff #45394) | Now, I understand what you mean. I modified the code to use "addSectionLabel". |