Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Error when manually setting location counter #35508

Closed Quuxplusone closed 6 years ago

Quuxplusone commented 6 years ago
Bugzilla Link PR36535
Status RESOLVED FIXED
Importance P normal
Reported by Konstantin Schwarz (konstantin.schwarz@hightec-rt.com)
Reported on 2018-02-27 04:19:01 -0800
Last modified on 2018-03-05 02:57:27 -0800
Version unspecified
Hardware PC Windows NT
CC grimar@accesssoftek.com, llvm-bugs@lists.llvm.org
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
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]
Quuxplusone commented 6 years ago

Looking.

Quuxplusone commented 6 years ago

Fix: https://reviews.llvm.org/D43999

Quuxplusone commented 6 years ago

r326688