[llvm-dev] [lld] linker script error while use "-=" on arm target

saito yutaka via llvm-dev llvm-dev at lists.llvm.org
Sat Apr 24 01:52:39 PDT 2021


I got link error when I try build code on arm target.
It seems that It could'n use "-=" operation when using arm.
The following is what we tried.

$ cat sample.c
void __init_array_start(void){};
void __init_array_end(void){};
int main()
     return 0;

$ cat sample.ld
    sample = 0;
    sample += 1;
    sample -= 1;
    . = 0x08048000 + SIZEOF_HEADERS;
    .text : {*(.text)}
    .rodata : {*(.rodata)}
    .data : {*(.data)}
    .bss : {*(.bss)}

# There is no error that build x86_64 target.
$ clang -fPIE -target x86_64-unknown-none-elf -nodefaultlibs sample.c -T

# But I get a error when build arm target.
$ clang  -target arm-none-eabi -march=armv7-m -mcpu=cortex-m4
-nodefaultlibs sample.c -T sample.ld
ld.lld: error: sample.ld:5: malformed number: =
>>>     sample -= 1;
>>>             ^
clang-12: error: ld.lld command failed with exit code 1 (use -v to see

# The version of clang I use using is 12.
$ clang --version
clang version 12.0.0 (https://github.com/llvm/llvm-project/
Target: x86_64-unknown-linux-gnu
Thread model: posix

Is there some linker script difference depend on target?

Saito Yutaka

フリー。 www.avast.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210424/943e304f/attachment.html>

More information about the llvm-dev mailing list