[llvm-bugs] [Bug 36535] New: Error when manually setting location counter

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Feb 27 04:19:01 PST 2018


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

            Bug ID: 36535
           Summary: Error when manually setting location counter
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: ELF
          Assignee: unassignedbugs at nondot.org
          Reporter: konstantin.schwarz at hightec-rt.com
                CC: llvm-bugs at lists.llvm.org

Consider the following assembly file:

// test.s
.text
.globl _start
_start:

.section .foo.1,"a"
 .quad 1

.section .foo.2,"a"
 .quad 2

// linker.script
MEMORY
{
  ram (rwx): org = 0x0, len = 32K
}

SECTIONS
{
  .foo.1 : 
  {
    *(.foo.1)
    . += 0x1000;
  } > ram

  .foo.2 :
  {
    *(.foo.2)
  } > ram
}

In the ".foo.1" output section, the location counter is incremented by 0x1000
to reserve additional memory.

Linking this example with ld.bfd results in no error and the following layout:


Name             Origin             Length             Attributes
ram              0x0000000000000000 0x0000000000008000 xrw
*default*        0x0000000000000000 0xffffffffffffffff

Linker script and memory map


.text           0x0000000000000000        0x0
 .text          0x0000000000000000        0x0 test.o

.foo.1          0x0000000000000000     0x1008
 *(.foo.1)
 .foo.1         0x0000000000000000        0x8 test.o
                0x0000000000001008                . = (. + 0x1000)
 *fill*         0x0000000000000008     0x1000 

.foo.2          0x0000000000001008        0x8
 *(.foo.2)
 .foo.2         0x0000000000001008        0x8 test.o


Linking with ld.lld returns the following errors: 

ld.lld: error: section .foo.1 file range overlaps with .foo.2
>>> .foo.1 range is [0x1000 -> 0x2007]
>>> .foo.2 range is [0x1008 -> 0x100F]

ld.lld: error: section .foo.1 file range overlaps with .comment
>>> .foo.1 range is [0x1000 -> 0x2007]
>>> .comment range is [0x1010 -> 0x1085]

ld.lld: error: section .foo.1 file range overlaps with .symtab
>>> .foo.1 range is [0x1000 -> 0x2007]
>>> .symtab range is [0x1088 -> 0x10B7]

ld.lld: error: section .foo.1 file range overlaps with .shstrtab
>>> .foo.1 range is [0x1000 -> 0x2007]
>>> .shstrtab range is [0x10B8 -> 0x10EF]

ld.lld: error: section .foo.1 file range overlaps with .strtab
>>> .foo.1 range is [0x1000 -> 0x2007]
>>> .strtab range is [0x10F0 -> 0x10F7]

ld.lld: error: section .foo.1 virtual address range overlaps with .foo.2
>>> .foo.1 range is [0x0 -> 0x1007]
>>> .foo.2 range is [0x8 -> 0xF]

ld.lld: error: section .foo.1 load address range overlaps with .foo.2
>>> .foo.1 range is [0x0 -> 0x1007]
>>> .foo.2 range is [0x8 -> 0xF]

-- 
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/20180227/52e74c0d/attachment.html>


More information about the llvm-bugs mailing list