[llvm-dev] binutils extensions: (1) dependency list in .a (2) SHF_GNU_RETAIN for GC roots in linking

Fangrui Song via llvm-dev llvm-dev at lists.llvm.org
Tue Nov 3 18:00:18 PST 2020


Updates:

On 2020-09-29, Fangrui Song wrote:
>I have recently seen two GNU binutils/GNU ABI extensions on binutils at sourceware.org
>They may potentially affect LLD and LLVM binary utilities, so I bring them
>to your attention:)
>
>https://sourceware.org/pipermail/binutils/2020-September/
>
>(1) "dependency list for static libraries  "
>  This adds a special member __.LIBDEP to an archive to represent
>  something similar to DT_NEEDED in a shared object.
>
>  This currently affects ar. ld is supposed to be affected but there is
>  no patch yet. This may affect llvm-ar and LLD.
>
>  I have one reply at https://sourceware.org/pipermail/binutils/2020-September/113444.html
>  You can click "Next message" to get the author's response.

Peter Smith shared some concerns as well. Still, GNU ar has adopted the change
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f3016d6ce178b76002edde12c30ebe7f608a8e21

The next step is a GNU ld change. If some packages start to adopt the feature,
it can impose some compatibility burden on llvm-ar and LLD as well. If you want
to comment on the thread "dependency list for static libraries"
(https://sourceware.org/pipermail/binutils/2020-November/113997.html), you can
use this tag:

   In-Reply-To: <7b118db2-9502-c45e-9f47-6b6f6a5f9646 at symas.com>

>(2) "[PATCH] Support SHF_GNU_RETAIN ELF section flag" and
>    "[PATCH v2] Support for SHF_GNU_RETAIN ELF Section Flag"
>
>  Basically, add a new section flag from SHF_MASKOS bits to express that
>  a section has GC root semantics (ld --gc-sections).
>  People mentioned GCC __attribute__((used)) could use this and the
>  author appears to be working on it (but a reply says that the frontend
>  feature do not need to hold up this proposal, so there is risk that it
>  is committed before the design is done).
>
>  This may affect Clang, LLVM's integrated assembler and LLD.
>
>  I have one reply at https://sourceware.org/pipermail/binutils/2020-September/113527.html
>  (main points: (a) there are several alternative forms, e.g. SHT_GROUP, a
>  new SHT_* for GC root (b) the way they design the new section flag
>  adds one exception to "gas: error for section type, attr, or entsize
>  change")

This appears to receive good feedback and is likely to be accepted in GNU as
and ld. I personally have no issue with supporting it in LLVM's integrated
assembler and LLD.

There is still a dispute on the assembler directives (`.retain`), though:
https://sourceware.org/pipermail/binutils/2020-November/113993.html (and its replies).


More information about the llvm-dev mailing list