llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[LLD] Unary '+' operator is not supported in linker script

Open partaror opened this issue 2 years ago • 1 comments

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;

partaror avatar Nov 29 '24 04:11 partaror

@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 &gt;1.c &lt;&lt;\EOF
int foo() { return 1; }
int bar() { return 3; }
EOF

cat &gt;script.t &lt;&lt;\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: +
&gt;&gt;&gt; val = +0x1;

llvmbot avatar Nov 29 '24 04:11 llvmbot