mirror of
https://github.com/rui314/mold.git
synced 2024-11-15 14:36:25 +03:00
parent
18156f3965
commit
0fd62ce693
@ -142,15 +142,17 @@ read_output_format(Context<E> &ctx, std::span<std::string_view> tok) {
|
||||
template <typename E>
|
||||
static bool is_in_sysroot(Context<E> &ctx, std::string path) {
|
||||
std::string sysroot = path_clean(ctx.arg.sysroot);
|
||||
path = path_clean(path);
|
||||
return std::string_view(sysroot).starts_with(path_dirname(path));
|
||||
path = path_clean(path_to_absolute(path));
|
||||
return path_dirname(path).starts_with(sysroot);
|
||||
}
|
||||
|
||||
template <typename E>
|
||||
static MemoryMappedFile<E> *resolve_path(Context<E> &ctx, std::string_view tok) {
|
||||
std::string str(unquote(tok));
|
||||
|
||||
if (str.starts_with('/') && is_in_sysroot(ctx, str))
|
||||
// GNU ld prepends the sysroot if a pathname starts with '/' and the
|
||||
// script being processed is in the sysroot. We do the same.
|
||||
if (str.starts_with('/') && is_in_sysroot(ctx, current_file<E>->name))
|
||||
return MemoryMappedFile<E>::must_open(ctx, ctx.arg.sysroot + str);
|
||||
|
||||
if (str.starts_with("-l"))
|
||||
|
@ -22,6 +22,6 @@ void foo();
|
||||
int main() { foo(); }
|
||||
EOF
|
||||
|
||||
clang -o $t/exe $t/c.o -Wl,--sysroot=$t/ $t/foo/bar/b.script
|
||||
clang -fuse-ld=`pwd`/../mold -o $t/exe $t/c.o -Wl,--sysroot=$t/ $t/foo/bar/b.script
|
||||
|
||||
echo OK
|
||||
|
Loading…
Reference in New Issue
Block a user