saito yutaka via llvm-dev
2021-Apr-24 08:52 UTC
[llvm-dev] [lld] linker script error while use "-=" on arm target
Hello. 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 SECTIONS { 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 sample.ld # 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 invocation) # The version of clang I use using is 12. $ clang --version clang version 12.0.0 (https://github.com/llvm/llvm-project/ b978a93635b584db380274d7c8963c73989944a1) Target: x86_64-unknown-linux-gnu Thread model: posix Is there some linker script difference depend on target? Thanks. Saito Yutaka <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> ウイルス フリー。 www.avast.com <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> <#m_-9052632302107401771_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2> -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210424/943e304f/attachment.html>
Fangrui Song via llvm-dev
2021-Apr-24 21:16 UTC
[llvm-dev] [lld] linker script error while use "-=" on arm target
On 2021-04-24, saito yutaka via llvm-dev wrote:>Hello. > >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 >SECTIONS >{ > 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 >sample.ld > ># 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 >invocation)-= is not supported. ld.lld only supports +=. -= is probably too rare in the wild. Actually changing the value of a symbol is hardly a good idea. The evaluation order of expressions is not well defined. Using -= or += may cause difficult-to-explain portability issues across GNU ld and ld.lld.># The version of clang I use using is 12. >$ clang --version >clang version 12.0.0 (https://github.com/llvm/llvm-project/ >b978a93635b584db380274d7c8963c73989944a1) >Target: x86_64-unknown-linux-gnu >Thread model: posix > >Is there some linker script difference depend on target?No.