[PATCH] D77779: [ELF] Find files relative to the current linker script for INPUT() and GROUP()
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 8 23:25:42 PDT 2020
MaskRay created this revision.
MaskRay added reviewers: grimar, psmith, ruiu.
Herald added subscribers: llvm-commits, dmgreen, arichardson, emaste.
Herald added a reviewer: espindola.
Herald added a project: LLVM.
Notation: CWD => current working directory
For a relative pathname in INPUT() or GROUP(),
- GNU ld searches in CWD then in -L
- gold searches in the parent directory of the current linker script then in -L. This behavior makes it convenient to replace a .so or .a with a linker script with additional input.
For example, glibc
% cat /usr/lib/x86_64-linux-gnu/libm.a
/* GNU ld script
*/
OUTPUT_FORMAT(elf64-x86-64)
GROUP ( /usr/lib/x86_64-linux-gnu/libm-2.29.a /usr/lib/x86_64-linux-gnu/libmvec.a )
could be simplified as `GROUP(libm-2.29.a libmvec.a)`.
This patch changes lld to searches in the parent directory of the current linker script,
next in CWD, then in -L. I filed a feature request for GNU ld: https://sourceware.org/bugzilla/show_bug.cgi?id=25806
I plan to add a configuration which makes libc++.a a linker script:
INPUT(libc++.a.1 libc++abi.a)
If libc++.a does not include libc++abi.a (or other C++ ABI like libcxxrt.a),
`clang -static -stdlib=libc++` is currently broken (-stdlib= affects
both compiler and linker options).
`clang -static -stdlib=libc++ -lc++abi` translates to `-lc++abi ...
-lc++` which does not work with traditional Unix linkers.
Making libc++.a a linker script is one way to fix `clang -static -stdlib=libc++`
With this feature, libc++.a does not need "relocation" when it is moved
to a different directory..
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D77779
Files:
lld/ELF/ScriptLexer.h
lld/ELF/ScriptParser.cpp
lld/test/ELF/linkerscript/input-relative.s
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77779.256194.patch
Type: text/x-patch
Size: 3598 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200409/4f4e3529/attachment.bin>
More information about the llvm-commits
mailing list