[llvm] [DWARF5][COFF] Fix wrong relocation in .debug_line (PR #83773)

via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 5 22:37:42 PST 2024


timoh-ba wrote:

> (if I were reviewing this in more detail (other reviewers might already be familiar with the context and not need this explained) I'd want to know more/understand why the old code is still in a fallback path/how the code is valid in that case & what that case (`needsDwarfSectionOffsetDirective`) is)

That is actually a good question, I based this commit around other uses of `needsDwarfSectionOffsetDirective` that I found in the code. This variable is only true for COFF files as far as I can tell and is used in other places to call `emitCOFFSecRel32`. As I said, I'm not 100% sure that I'm using this correctly though.

The other code is still in fallback because it seems to be the path for ELF files and everything was working there when I tested it so I didn't want to break anything. Maybe we can always use emitCOFFSecRel32, but the function name suggests that it won't work on ELF :).

> I'm not very familiar with DWARF overall, or what DWARF 5 bring

There is an overview at https://dwarfstd.org/dwarf5std.html which lists the major & breaking changes, one of which being:

> The line number table header is substantially revised.

Which can be seen in MCDwarfLineTableHeader::Emit calling MCDwarfLineTableHeader::emitV5FileDirTables for version 5, which in turn uses the .debug_line_str section if available to reference it. This calls MCDwarfLineStr::emitRef which is where I put my change.

https://github.com/llvm/llvm-project/pull/83773


More information about the llvm-commits mailing list