[PATCH] D18091: ELF: Implement --build-id.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 11 10:10:32 PST 2016


ruiu created this revision.
ruiu added reviewers: emaste, rafael, silvas.
ruiu added a subscriber: llvm-commits.

This patch implements --build-id. After the linker creates an output file
in the memory buffer, it computes the FNV1 hash of the resulting file
and set the hash to the .note section as a build-id.

GNU ld and gold has the same feature, but their default choice of the hash
function is different. Their default is SHA1.

We made a deliberate choice to not use a secure hash function for the
sake of performance. Computing a secure hash is slow -- for example,
MD5 throughput is usually 400 MB/s or so. SHA1 is slower than that.

As a result, if you pass --build-id to gold, then the linker becomes about
10% slower than that without the option. We observed a similar degradation
in an experimental implementation of build-id to LLD. On the other hand,
we observed only 1-2% performance degradation with the FNV hash.

Since build-id is not for digital certificate or anything, we think that
a very small probability of collision is acceptable.

GNU linkers accepts --build-id=<style> option where style is one of
"MD5", "SHA1", or an arbitrary hex string. That option is out of scope
of this patch.

http://reviews.llvm.org/D18091

Files:
  ELF/Config.h
  ELF/Driver.cpp
  ELF/Options.td
  ELF/OutputSections.cpp
  ELF/OutputSections.h
  ELF/Writer.cpp
  test/ELF/build-id.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18091.50445.patch
Type: text/x-patch
Size: 8239 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160311/05d43c0a/attachment.bin>


More information about the llvm-commits mailing list