Skip to content

eld looks for version scripts with an absolute path inside of the --sysroot dir #786

@jonathonpenix

Description

@jonathonpenix

Description
When eld is given --sysroot=/some/dir and --version-script=/some/absolute/path it looks for the file at /some/dir/some/absolute/path. In my particular case (cross compiling hwasan with eld, see below), this gives errors. From what I can see, lld and bfd both look into '/some/absolute/path' rather than prepending the sysroot like eld.

Reproducer
It's a bit of a silly/incomplete example, but below should work to reproduce the issue.

A real example in the wild can be seen when trying to build hwasan using eld (qualcomm/cpullvm-toolchain#134, logs are here)

cat > empty.c << '!'
int main() {}
!
touch myvers.vers

# eld errors with the below when given an absolute path:
# Fatal: cannot read file /mysysroot/path/to/working/directory/myvers.vers, because of error No such file or directory
clang --target=riscv32-linux-gnu --sysroot=/mysysroot -shared -fuse-ld=eld -nostartfiles -nostdlib empty.c -Wl,--version-script=$PWD/myvers.vers

# lld and bfd both look in the absolute path, not considering the sysroot.
# For this example, lld produces this error (which, make sense--it found the right file, which is empty):
# ld.lld: error: /path/to/working/directory/myvers.vers:1: unexpected EOF
clang --target=riscv32-linux-gnu --sysroot=/mysysroot -shared -fuse-ld=eld -nostartfiles -nostdlib empty.c -Wl,--version-script=$PWD/myvers.vers

# eld looks at the right file when given a relative path (though interestingly it doesn't error on the empty file):
clang --target=riscv32-linux-gnu --sysroot=/mysysroot -shared -fuse-ld=eld -nostartfiles -nostdlib empty.c -Wl,--version-script=myvers.vers

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions