<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 -Ttext 0x600 (as used in FreeBSD boot loader) results in 4GB output on i386"
href="https://llvm.org/bugs/show_bug.cgi?id=31196">31196</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>lld -Ttext 0x600 (as used in FreeBSD boot loader) results in 4GB output on i386
</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>Created <span class=""><a href="attachment.cgi?id=17677" name="attach_17677" title="reproducer for large output with -Ttext 0x0600">attachment 17677</a> <a href="attachment.cgi?id=17677&action=edit" title="reproducer for large output with -Ttext 0x0600">[details]</a></span>
reproducer for large output with -Ttext 0x0600
Found while testing the WIP -N support in <a href="https://reviews.llvm.org/D26888">https://reviews.llvm.org/D26888</a>
The boot0 boot component is linked with the following command line:
ld --eh-frame-hdr -dynamic-linker /libexec/ld-elf.so.1 --hash-style=both
--enable-new-dtags -m elf_i386_fbsd -o boot0 -L/usr/lib32 -Ttext 0x600 -e start
-N -S --oformat binary boot0.o
This produces 4GB output:
% ls -l boot0
-rwxr-xr-x 1 emaste emaste 4294903808 28 Nov 18:01 boot0
Outputting as ELF instead by dropping the --oformat binary:
% /tank/emaste/src/llvm/build-debug/bin/ld.lld --eh-frame-hdr -dynamic-linker
/libexec/ld-elf.so.1 --hash-style=both --enable-new-dtags -m elf_i386_fbsd -o
boot0 -L/usr/lib32 -Ttext 0x600 -e start -N -S boot0.o
lets us see what's going on (note the Off column):
% readelf -S boot0
There are 8 section headers, starting at offset 0xffff0e60:
Section Headers:
[Nr] Name Type Addr Off Size ES Flg Lk Inf
Al
[ 0] NULL 00000000 000000 000000 00 0 0
0
[ 1] .text PROGBITS 00000600 ffff0600 000200 00 AX 0 0
4
[ 2] .data PROGBITS 00000800 ffff0800 000000 00 WA 0 0
4
[ 3] .bss NOBITS 00000800 ffff0800 000000 00 WA 0 0
4
[ 4] .comment PROGBITS 00000000 ffff0800 000055 01 MS 0 0
1
[ 5] .symtab SYMTAB 00000000 ffff0858 0003e0 10 7 61
4
[ 6] .shstrtab STRTAB 00000000 ffff0c38 000035 00 0 0
1
[ 7] .strtab STRTAB 00000000 ffff0c6d 0001f1 00 0 0
1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings)
I (info), L (link order), G (group), x (unknown)
O (extra OS processing required) o (OS specific), p (processor specific)
For reference, here's the output when linked by ld.bfd 2.17.50:
% readelf -S boot0
There are 5 section headers, starting at offset 0x278:
Section Headers:
[Nr] Name Type Addr Off Size ES Flg Lk Inf
Al
[ 0] NULL 00000000 000000 000000 00 0 0
0
[ 1] .text PROGBITS 00000600 000054 000200 00 WAX 0 0
4
[ 2] .shstrtab STRTAB 00000000 000254 000021 00 0 0
1
[ 3] .symtab SYMTAB 00000000 000340 000420 10 4 62
4
[ 4] .strtab STRTAB 00000000 000760 000209 00 0 0
1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings)
I (info), L (link order), G (group), x (unknown)
O (extra OS processing required) o (OS specific), p (processor specific)</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>