[PATCH] D51833: ELF: Add --build-id-link-dir=DIR switch

Petr Hosek via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 10 17:18:15 PDT 2018


phosek added a comment.

In https://reviews.llvm.org/D51833#1229776, @ruiu wrote:

> I think I don't understand the use case of the feature yet.
>
> - If you hard-link two files, they have the identical contents (strictly speaking there is only one file with two filenames). If a debugger can find an executable having debug info in .build-id/xx/xxxxx directory, it should be able to find it in the executable that's being debugged. So, how does it work?


We would strip the binary and that's what's being executed. This doesn't apply only to executables, but also to shared libraries. So when the debugger connects to a process, it'd find all the ELF files mapped into memory and see their build-ids, from there it needs a way to map those back to files that contain the debug information. On Fuchsia, we're always cross-compiling and producing a system image as the output that contains all stripped binaries, but we need to keep debugging binaries around so we can debug or symbolize them remotely. Ideally we would then point all debugging tools at the `.build-id` root to lookup the binaries using their build-id.

> - If it is the only problem that llvm-objdump's output is not machine-readable, you can add a new option to llvm-objdump to print out a build-id, can't you?

We considered it but that's going to be really complicated since `llvm-objdump`/`llvm-readobj` doesn't have any reasonable in-memory representation that we can easily serialize into a machine readable format (e.g. JSON), those tools are really optimized for printing out (formatted) output. Also this solution still requires some post-processing and we would need to ensure that this works on all platforms.


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D51833





More information about the llvm-commits mailing list