[llvm-bugs] [Bug 41169] New: Symbol assignments within output sections are not relative to enclosing section

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Mar 20 23:32:57 PDT 2019


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: unassignedbugs at nondot.org
          Reporter: pkmx.tw at gmail.com
                CC: llvm-bugs at lists.llvm.org, peter.smith at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190321/baab5c2b/attachment.html>


More information about the llvm-bugs mailing list