llvm-project
llvm-project copied to clipboard
[LLD] Unary '+' operator is not supported in linker script
LLD does not support unary '+' operator in linker scripts. We should perhaps support this for compatibility with GNU linker.
Reproducible example:
#!/usr/bin/env bash
cat >1.c <<\EOF
int foo() { return 1; }
int bar() { return 3; }
EOF
cat >script.t <<\EOF
val = +0x1;
EOF
clang-18 -o 1.o 1.c -c -ffunction-sections
ld.bfd -o 1.bdf.out 1.o -T script.t
ld.lld -o 1.lld.out 1.o -T script.t
GNU LD produces no error, whereas LLD reports:
ld.lld: error: script.t:1: malformed number: +
>>> val = +0x1;
@llvm/issue-subscribers-lld-elf
Author: Parth Arora (partaror)
LLD does not support unary '+' operator in linker scripts. We should perhaps support this for compatibility with GNU linker.
Reproducible example:
#!/usr/bin/env bash
cat >1.c <<\EOF
int foo() { return 1; }
int bar() { return 3; }
EOF
cat >script.t <<\EOF
val = +0x1;
EOF
clang-18 -o 1.o 1.c -c -ffunction-sections
ld.bfd -o 1.bdf.out 1.o -T script.t
ld.lld -o 1.lld.out 1.o -T script.t
GNU LD produces no error, whereas LLD reports:
ld.lld: error: script.t:1: malformed number: +
>>> val = +0x1;