On Mon, 25 Nov 2019, Martin Storsjö via lldb-dev wrote:
But now I tested this a bit more with ELF setups, and realized that it
somehow does seem to do the right thing. It might have something to do with
how ELF linkers handle this kind of section that isn't loaded at runtime (and
thus perhaps doesn't really have a virtual address assigned).
So that pretty much clears the question regarding inconsistency, and raises
more questions about how this really works in ELF and MCDwarf.
So, if I make the call to EmitSymbolValue() set the IsSectionRelative
parameter to true, I get the correct, expected relocations for this section:
RELOCATION RECORDS FOR [.debug_frame]:
00000018 IMAGE_REL_I386_SECREL .debug_frame
0000001c IMAGE_REL_I386_DIR32 .text
This matches what GCC produces in similar cases as well.
But with this in place, ELF targets misbehave severely; there's no relocation
produced at all for the .debug_frame symbol, and the second relocation gets
written at the wrong offset.
Ok, it turns out that there's already a flag that indicates exactly this,
asmInfo->needsDwarfSectionOffsetDirective(), which just seems to not be
used here where it should, which seems to encapsulate whether a certain
type of relocation needs to be used (like in COFF) or if different section
types like in ELF seems to handle it automatically with just one kind of
relocation. I had seen it before but didn't really understand its role
until I saw how ELF behaved.
So this is clearly a closed case, and I'll be sending a patch for MCDwarf
soon.
// Martin
_______________________________________________
lldb-dev mailing list
lldb-dev@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev