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

            Bug ID: 50558
           Summary: Wrong generation of PT_LOAD program headers
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: ELF
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]

For the following simplified test case, ld.lld produces a
"section .data3 load address range overlaps with .data4" error.

Assembly file:
```
.section .a.data, "aw"
.word 0xabcdef01

.section .b.data, "aw"
.word 0xbcdefa12

.text
.globl _start
_start:
    nop
```

Linkerscript:
```
MEMORY
{
    CODE (rx)  : ORIGIN = 0x08000000, LENGTH = 512K
    DATA (rw) : ORIGIN = 0x20000400, LENGTH = 512K
}
SECTIONS
{
    .text :
    {
        *(.text)
    } > CODE

    .data :
    {
        *(.a.data)
    } > DATA AT> CODE

    .data2 (NOLOAD) :
    {
        . += 4;
    } > DATA

    .data3 :
    {
        *(.b.data)
    } > DATA AT> CODE

    .data4 :
    {
        LONG(-1); LONG(-1); LONG(-1);
    } > CODE
}
```

The problem seems to be the way PT_LOAD headers are created in createPhdrs in
this case.
.data starts a new PT_LOAD segment, then .data2 is skipped (because of NOLOAD),
then .data3 continues the previous PT_LOAD.

However, .data2 occupies memory in the DATA memory region, thus .data3 may not
continue the previous PT_LOAD segment.

In this simplified linkerscript, the order of the output sections could be
changed to make the link succeed, however in the actual application there are
several linkerscript fragments that are included into the main script. In this
scenario, the outer context is not known and re-ordering doesn't work.

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

Reply via email to