[PATCH] D54384: [llvm-objcopy] Add --build-id-link-dir flag

Jake Ehrlich via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 10 15:01:06 PST 2018


jakehehrlich created this revision.
jakehehrlich added reviewers: alexshap, jhenderson, rupprecht.
Herald added subscribers: arichardson, emaste.
Herald added a reviewer: espindola.

This flag does not exist in GNU objcopy but has a major use case. Debugging tools support the .build-id directory structure to find debug binaries. There is no easy way to build this structure up however. One way to do it is by using llvm-readelf and some crazy shell magic. This implements the feature directly. It is most often the case that you'll want to strip a file and send the original to the .build-id directory but if you just want to send a file to the .build-id directory you can copy to /dev/null instead.

I happen to have implemented the "find build id" algorithm like 3 or 4 times now. You can find reference implementations that are known to work here <https://fuchsia.googlesource.com/zircon/+/master/system/ulib/elf-search/elf-search.cpp#113> and here <https://fuchsia.googlesource.com/tools/+/master/elflib/elflib.go#111>.

The .build-id use case documentation can be found here: https://sourceware.org/gdb/onlinedocs/gdb/Separate-Debug-Files.html

In Fuchsia we now have a lot of tools that fetch binaries based on their build id but we do it using this awful non-standard thing we call "ids.txt". This will let us replace it.


Repository:
  rL LLVM

https://reviews.llvm.org/D54384

Files:
  llvm/test/tools/llvm-objcopy/build-id-link-dir.test
  llvm/tools/llvm-objcopy/CopyConfig.cpp
  llvm/tools/llvm-objcopy/CopyConfig.h
  llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp
  llvm/tools/llvm-objcopy/ELF/Note.h
  llvm/tools/llvm-objcopy/ELF/Object.h
  llvm/tools/llvm-objcopy/ObjcopyOpts.td

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54384.173532.patch
Type: text/x-patch
Size: 8769 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181110/cc15cf6f/attachment.bin>


More information about the llvm-commits mailing list