llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.46k stars 11.77k forks source link

[lld][ELF] lld reports error when region name in Memory Command contains symbol - #77286

Open Yunzezhu94 opened 9 months ago

Yunzezhu94 commented 9 months ago

When link with linker script like:

MEMORY
{
    A-XXXX : ORIGIN = 0x0        , LENGTH = 0x20000
    B-YYYY : ORIGIN = 0x200000 , LENGTH = 0x40000
    C-ZZZZ : ORIGIN = 0x400000 , LENGTH = 0x80000
}

lld reports error: : expected, but got - while gnu ld will not report error with same linker script. This is because when processing tokens lld treats string as Expr and split in function tokenizeExpr, so symbol - , rather than symbol : is regard as end of region name.

llvmbot commented 9 months ago

@llvm/issue-subscribers-lld-elf

Author: None (Yunzezhu94)

When link with linker script like: ``` MEMORY { A-XXXX : ORIGIN = 0x0 , LENGTH = 0x20000 B-YYYY : ORIGIN = 0x200000 , LENGTH = 0x40000 C-ZZZZ : ORIGIN = 0x400000 , LENGTH = 0x80000 } ``` lld reports error: `: expected, but got -` while gnu ld will not report error with same linker script. This is because when processing tokens lld treats string as Expr and split in function tokenizeExpr, so symbol - , rather than symbol : is regard as end of region name.