[PATCH] D25799: Include version string into ".linker-version" section.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 19 14:50:23 PDT 2016

ruiu created this revision.
ruiu added reviewers: mehdi_amini, hfinkel, davide, peter.smith.
ruiu added a subscriber: llvm-commits.

This patch adds a new section, ".linker-version", to an output.
The section contains the linker's version string. You can now
find out whether a binary is created by LLD or not using objdump
command like this.

  $ objdump -j .linker-version -s foo
  foo:     file format elf64-x86-64
  Contents of section .linker-version:
   0000 4c4c4420 342e3020 28687474 70733a2f  LLD 4.0 (https:/
   0010 2f6c6c76 6d2e6f72 672f7376 6e2f6c6c  /llvm.org/svn/ll
   0020 766d2d70 726f6a65 63742f6c 6c642f74  vm-project/lld/t
   0030 72756e6b 20323834 36333429 00        runk 284634).

An alternative considered:

I first tried to add a SHT_NOTE section because GNU gold does that.
A NOTE section starts with a header which contains content type.
It turned out that ld.gold sets type NT_GNU_GOLD_VERSION to their
NOTE section. So the NOTE type is only for GNU gold (surprise!)

I could define NT_GNU_LINKER_VERSION. However, I doubt that we need
a header at all. It doesn't seem useful at all. Thus, I decided to
just set a version string without any header.

Now that it is not a NOTE section, it doesn't make sense to start
a section name with ".note". So I named it just ".linker-version".



-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25799.75234.patch
Type: text/x-patch
Size: 4224 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161019/02ae58bd/attachment.bin>

More information about the llvm-commits mailing list