<html>
<head>
<base href="https://llvm.org/bugs/" />
</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 --- - lld has different section attribute merging vs ld.bfd"
href="https://llvm.org/bugs/show_bug.cgi?id=30415">30415</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>lld has different section attribute merging vs ld.bfd
</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>FreeBSD
</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>emaste@freebsd.org
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Blocks</th>
<td>23214
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>LLD is not necessarily wrong here and what ld.bfd is doing is arguably a bug,
but I'm submitting this PR for tracking one of the few outstanding issues
linking FreeBSD/amd64 with LLD while looking for a solution.
We recently migrated to using a linker script instead of the seemingly obsolete
-N command line flag for FreeBSD's boot loader components:
<a href="https://svnweb.freebsd.org/base?view=revision&revision=305353">https://svnweb.freebsd.org/base?view=revision&revision=305353</a>
The linker script is straightforward:
---
/* $FreeBSD$ */
/* Merge text, data and bss together almost no padding */
OUTPUT_FORMAT("elf32-i386-freebsd")
OUTPUT_ARCH(i386)
ENTRY(_start)
SECTIONS {
. = 0x08048000 + SIZEOF_HEADERS;
.text : { *(.text) } =0x90909090 /* Pad with nops, if needed */
.data : { *(.data) } PROVIDE(_edata = .);
.bss : { *(.bss) } PROVIDE(_end = .);
}
---
>From this GNU ld produces an object with all sections packed into a single RWE
segment:
% readelf -l boot2.out
Elf file type is EXEC (Executable file)
Entry point 0x2000
There are 2 program headers, starting at offset 52
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
LOAD 0x000080 0x00002000 0x00002000 0x01456 0x027f8 RWE 0x10
GNU_STACK 0x000000 0x00000000 0x00000000 0x00000 0x00000 RWE 0x4
Section to Segment mapping:
Segment Sections...
00 .text .rodata .data .bss
01
while LLD produces an object with separate segments for sections with different
permissions.</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>