[llvm-bugs] [Bug 38481] New: [LLD] [ELF] ld.lld reserves memory in the LMA region for NOBITS sections

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Aug 8 04:39:40 PDT 2018


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

            Bug ID: 38481
           Summary: [LLD] [ELF] ld.lld reserves memory in the LMA region
                    for NOBITS sections
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: ELF
          Assignee: unassignedbugs at nondot.org
          Reporter: konstantin.schwarz at hightec-rt.com
                CC: llvm-bugs at lists.llvm.org

In the following linker script, an LMA region is explicitly set for .sec1.
ld.lld expands that region subsequently, although .sec1 has only NOBITS
contents

MEMORY
{
    RODATA : org = 0x08000000, len = 100K
    DATA   : org = 0x20000000, len = 100K
}

SECTIONS
{

    .text : { } > RODATA

    .sec1 : { . += 4K; } > DATA AT > RODATA

    .sec2 : { . += 4K; } > DATA

    .sec3 : { . += 4k; } > RODATA
}


readelf gives the following output: 

Section Headers:
  [Nr] Name              Type             Address           Offset
       Size              EntSize          Flags  Link  Info  Align
  [ 0]                   NULL             0000000000000000  00000000
       0000000000000000  0000000000000000           0     0     0
  [ 1] .text             PROGBITS         0000000008000000  00001000
       0000000000000000  0000000000000000  AX       0     0     4
  [ 2] .sec1             NOBITS           0000000020000000  00001000
       0000000000001000  0000000000000000  AX       0     0     1
  [ 3] .sec2             NOBITS           0000000020001000  00001000
       0000000000001000  0000000000000000  AX       0     0     1
  [ 4] .sec3             NOBITS           0000000008001000  00001000
       0000000000001000  0000000000000000  AX       0     0     1
[...]

Program Headers:
  Type           Offset             VirtAddr           PhysAddr
                 FileSiz            MemSiz              Flags  Align
  LOAD           0x0000000000001000 0x0000000020000000 0x0000000008000000
                 0x0000000000000000 0x0000000000002000  R E    1000
  LOAD           0x0000000000001000 0x0000000008001000 0xfffffffff0001000
                 0x0000000000000000 0x0000000000001000  R E    1000
  GNU_STACK      0x0000000000000000 0x0000000000000000 0x0000000000000000
                 0x0000000000000000 0x0000000000000000  RW     0

 Section to Segment mapping:
  Segment Sections...
   00     .sec1 .sec2 
   01     .sec3 
   02

Although the file size of the first program header is 0, the virtual address of
the next header starts at 0x0000000008001000

Moreover, the physical address of the second program header seems wrong.

-- 
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/20180808/d9f5821a/attachment.html>


More information about the llvm-bugs mailing list