https://bugs.llvm.org/show_bug.cgi?id=41169

            Bug ID: 41169
           Summary: Symbol assignments within output sections are not
                    relative to enclosing section
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: ELF
          Assignee: unassignedb...@nondot.org
          Reporter: pkmx...@gmail.com
                CC: llvm-bugs@lists.llvm.org, peter.sm...@linaro.org

To reproduce:

$ cat > test.ld <<EOF
SECTIONS {
  .foo 0x10000 : {
    . = 4;
    foo = .;
  }
}
EOF

$ clang -xc - -o empty.o < /dev/null
$ ld.lld empty.o -Ttest.ld
ld.lld: error: test.ld:3: unable to move location counter backward for: .foo
ld.lld: error: section .foo at 0x10000 of size 0xFFFFFFFFFFFF0004 exceeds
available address space

It works with ld.bfd:

$ ld.bfd empty.o -Ttest.ld
$ readelf -s a.out | grep foo
     4: 0000000000010004     0 NOTYPE  GLOBAL DEFAULT    1 foo

---------------------------------

ld.bfd treats numbers in an output section as relative to the beginning of the
section
(https://sourceware.org/binutils/docs/ld/Expression-Section.html#Expression-Section),
so the assignment `. = 4` actually moves dot to 0x10004.

In lld, `. = 4` tries to move dot backwards to absolute address 4, which is not
allowed within an output section.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to