<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Extra PT_LOAD phdr emitted with content of ELF header and PT_PHDR segment"
href="https://bugs.llvm.org/show_bug.cgi?id=33551">33551</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Extra PT_LOAD phdr emitted with content of ELF header and PT_PHDR segment
</td>
</tr>
<tr>
<th>Product</th>
<td>lld
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>ELF
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>jakehehrlich@google.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>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</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>