[llvm-bugs] [Bug 33551] New: Extra PT_LOAD phdr emitted with content of ELF header and PT_PHDR segment

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jun 21 14:22:20 PDT 2017


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

            Bug ID: 33551
           Summary: Extra PT_LOAD phdr emitted with content of ELF header
                    and PT_PHDR segment
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: ELF
          Assignee: unassignedbugs at nondot.org
          Reporter: jakehehrlich at google.com
                CC: llvm-bugs at lists.llvm.org

An extra PT_LOAD segment is being emitted that covers the ELF header and the
PT_PHDR segment. To reproduce use the following linker script and assembly
file.

test.s:
```
.section .text
.global _start

_start:
  ret
```

test.ld:
```
SECTIONS {
  . = 0x2000;
  .text : AT(0x100000) {
    *(.text)
  }
}
```

Run the following commands:
clang -c test.s
ld.lld test.o -T test.ld -o test.exe
llvm-readobj -program-headers test.exe

I get the following output:
```
ProgramHeaders [
  ProgramHeader {
    Type: PT_PHDR (0x6)
    Offset: 0x40
    VirtualAddress: 0x1040
    PhysicalAddress: 0x1040
    FileSize: 224
    MemSize: 224
    Flags [ (0x4)
      PF_R (0x4)
    ]
    Alignment: 8
  }
  ProgramHeader {
    Type: PT_LOAD (0x1)
    Offset: 0x0
    VirtualAddress: 0x1000
    PhysicalAddress: 0x1000
    FileSize: 288
    MemSize: 288
    Flags [ (0x5)
      PF_R (0x4)
      PF_X (0x1)
    ]
    Alignment: 4096
  }
  ProgramHeader {
    Type: PT_LOAD (0x1)
    Offset: 0x1000
    VirtualAddress: 0x2000
    PhysicalAddress: 0x100000
    FileSize: 1
    MemSize: 1
    Flags [ (0x5)
      PF_R (0x4)
      PF_X (0x1)
    ]
    Alignment: 4096
  }
  ProgramHeader {
    Type: PT_GNU_STACK (0x6474E551)
    Offset: 0x0
    VirtualAddress: 0x0
    PhysicalAddress: 0x0
    FileSize: 0
    MemSize: 0
    Flags [ (0x6)
      PF_R (0x4)
      PF_W (0x2)
    ]
    Alignment: 0
  }
]
```

It is expected that such a program header not be emitted.

Bug present in LLD 4.0.0

-- 
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/20170621/711105f0/attachment.html>


More information about the llvm-bugs mailing list