mirror of
https://github.com/rui314/mold.git
synced 2024-09-11 21:17:28 +03:00
[ELF] Fix absolute paths handling in linker scripts
With toolchains using a relative sysroot, like crosstool-ng, gcc/clang will call the linker with something like "--sysroot=/path/bin/../machine/sysroot". The is_in_sysroot detection wasn't working in this case. Since to_abs_path() uses lexically_normal() for relative paths, it seems consistent to do the same for absolute paths instead of modifying is_in_sysroot().
This commit is contained in:
parent
903fff7701
commit
467b08a782
@ -20,7 +20,7 @@ std::string path_clean(std::string_view path) {
|
||||
|
||||
std::filesystem::path to_abs_path(std::filesystem::path path) {
|
||||
if (path.is_absolute())
|
||||
return path;
|
||||
return path.lexically_normal();
|
||||
return (std::filesystem::current_path() / path).lexically_normal();
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
. $(dirname $0)/common.inc
|
||||
|
||||
mkdir -p $t/sysroot/foo
|
||||
mkdir -p $t/bin $t/sysroot/foo
|
||||
|
||||
cat <<EOF > $t/a.script
|
||||
INPUT(=/foo/x.o)
|
||||
@ -37,3 +37,6 @@ EOF
|
||||
|
||||
$CC -B. -o $t/exe -Wl,--sysroot=$t/sysroot \
|
||||
$t/a.script $t/sysroot/b.script $t/c.o
|
||||
|
||||
$CC -B. -o $t/exe -Wl,--sysroot=$(realpath $t)/bin/../sysroot \
|
||||
$t/a.script $t/sysroot/b.script $t/c.o
|
||||
|
Loading…
Reference in New Issue
Block a user