diff --git a/elf/linker-script.cc b/elf/linker-script.cc index ef13d6a844..2b5e098379 100644 --- a/elf/linker-script.cc +++ b/elf/linker-script.cc @@ -170,6 +170,11 @@ static MappedFile> *resolve_path(Context &ctx, std::string_view to if (str.starts_with("-l")) return find_library(ctx, str.substr(2)); + if (!str.starts_with('/')) + if (MappedFile> *mf = + open_library(ctx, path_clean(ctx.script_file->name + "/../" + str))) + return mf; + if (MappedFile> *mf = open_library(ctx, str)) return mf; diff --git a/test/elf/linker-script5.sh b/test/elf/linker-script5.sh new file mode 100755 index 0000000000..f31b29b5aa --- /dev/null +++ b/test/elf/linker-script5.sh @@ -0,0 +1,14 @@ +#!/bin/bash +. $(dirname $0)/common.inc + +mkdir -p $t/foo + +cat < $t/foo/b.script +INPUT(a.o) +EOF + +$CC -B. -o $t/exe $t/foo/b.script