<div dir="ltr"><div dir="ltr">On Mon, Aug 31, 2020 at 5:54 PM Fangrui Song <<a href="mailto:maskray@google.com" target="_blank">maskray@google.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">>> 1. Teach lld how to emit a separated debuginfo output file <br>
>>directly, without requiring an objcopy step.<br>
<br>
This is very similar to Solaris's ancillary objects (ET_SUNW_ANCILLARY).<br>
There are more details on <a href="http://www.linker-aliens.org/blogs/ali/entry/ancillary_objects_separate_debug_elf/" rel="noreferrer" target="_blank">http://www.linker-aliens.org/blogs/ali/entry/ancillary_objects_separate_debug_elf/</a><br>
In short, Solari's `ld -z ancillary[=outfile]` writes non-SHF_ALLOC sections to the<br>
ancillary object. Perhaps we will need some coordination with GNU. Some<br>
GNU folks are interested in a new object file type:<br>
<a href="https://groups.google.com/forum/#!topic/generic-abi/tJq7anc6WKs" rel="noreferrer" target="_blank">https://groups.google.com/forum/#!topic/generic-abi/tJq7anc6WKs</a><br>
<br>
<br>
A debug file created by {,llvm-}objcopy --only-keep-debug has different<br>
contents (see <a href="https://reviews.llvm.org/D67137" rel="noreferrer" target="_blank">https://reviews.llvm.org/D67137</a> for details):<br>
non-SHF_ALLOC sections and SHT_NOTE sections. <a href="http://www.linker-aliens.org/blogs/ali/entry/ancillary_objects_separate_debug_elf/" rel="noreferrer" target="_blank">http://www.linker-aliens.org/blogs/ali/entry/ancillary_objects_separate_debug_elf/</a><br>
does not say whether program headers are retained in the debug file, but<br>
{,llvm-}objcopy --only-keep-debug keeps one copy (neither gdb/lldb needs<br>
the program headers).</blockquote><div><br></div><div>What I meant that lld should emit the same files you'd get via `objcopy --strip-debug; objcopy --only-keep-debug; objcopy --add-gnu-debuglink` (or `eu-strip -f foo.debug foo`). Only difference is that it's directly output from the linker, instead of via a post-processing step. Could be invoked like `ld.lld -o foo -s --debug-output=foo.debug`, or with `-S`, instead, if you want to keep the symtab in the binary instead of the debuginfo.</div><div><br></div><div><div>The original GNU proposal for the new object type flag in that thread was just a tiny modification of the existing formats, to enable identifying a debuginfo file. We can easily implement that extra flag, if it happens. It's not clear to me that introducing some other new behavior here would be particularly interesting or useful -- even having seen that thread.</div><div></div></div><div><br></div><div><div></div><div></div></div></div></div>