Skip to content

Sysroot is incorrectly prepended to inputs specified in INPUT / GROUP command #808

@parth-07

Description

@parth-07

Currently, we incorrectly prepend sysroot to inputs specified in INPUT / GROUP linker script commands.

Reproducible example:

#!/usr/bin/env bash

mkdir -p A/lib64
mkdir -p A/script

cat >1.c <<\EOF
int foo() { return 1; }
EOF

cat >script.t <<\EOF
GROUP(/lib64/lib1.so)
EOF

cat >main.c <<\EOF
int main() { return 0; }
EOF

clang -o lib1.so -target x86_64-unknown-elf 1.c -shared -fPIC
clang -o main.o -target x86_64-unknown-elf main.c -c 

mv lib1.so A/lib64/lib1.so

ld.eld --sysroot=A -T script.t main.o 
ld.lld --sysroot=A -T script.t main.o
ld.bfd --sysroot=A -T script.t main.o 

lld and bfd errors out whereas eld incorrectly finds the lib1.so file.

Another example:

#!/usr/bin/env bash

mkdir -p A/lib64
mkdir -p A/script

cat >1.c <<\EOF
int foo() { return 1; }
EOF

cat >script.t <<EOF
GROUP($(pwd)/A/lib64/lib1.so)
EOF

cat >main.c <<\EOF
int main() { return 0; }
EOF

clang -o lib1.so -target x86_64-unknown-elf 1.c -shared -fPIC
clang -o main.o -target x86_64-unknown-elf main.c -c 

mv lib1.so A/lib64/lib1.so

ld.eld --sysroot=A -T script.t main.o 
ld.lld --sysroot=A -T script.t main.o
ld.bfd --sysroot=A -T script.t main.o 

lld and bfd are correctly able to find lib1.so but eld canont find the lib1.so file.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions