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

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 6 13:07:18 PST 2024


dwblaikie 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. This calls MCDwarfLineStr::emitRef which is where I put my change.
> 
> Edit: I just researched ELF files a bit and it seems like all relocations for shared objects are always section-relative, which explains why everything is working there; PE files have absolute & relative relocations though and we emitted an absolute one previously.

Ah, fair enough - if there's similar code elsewhere I'm more or less happy to hand-wave/not think about it too much harder. But yeah, some test coverage would be good.

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


More information about the llvm-commits mailing list