<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><span class="vcard"><a class="email" href="mailto:i@maskray.me" title="Fangrui Song <i@maskray.me>"> <span class="fn">Fangrui Song</span></a>
</span> changed
<a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED INVALID - [LLD/ELF] LLD change inflates elf binary size when linked with no-rosegment"
href="https://bugs.llvm.org/show_bug.cgi?id=43997">bug 43997</a>
<br>
<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>What</th>
<th>Removed</th>
<th>Added</th>
</tr>
<tr>
<td style="text-align:right;">Status</td>
<td>NEW
</td>
<td>RESOLVED
</td>
</tr>
<tr>
<td style="text-align:right;">Resolution</td>
<td>---
</td>
<td>INVALID
</td>
</tr></table>
<p>
<div>
<b><a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED INVALID - [LLD/ELF] LLD change inflates elf binary size when linked with no-rosegment"
href="https://bugs.llvm.org/show_bug.cgi?id=43997#c4">Comment # 4</a>
on <a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED INVALID - [LLD/ELF] LLD change inflates elf binary size when linked with no-rosegment"
href="https://bugs.llvm.org/show_bug.cgi?id=43997">bug 43997</a>
from <span class="vcard"><a class="email" href="mailto:i@maskray.me" title="Fangrui Song <i@maskray.me>"> <span class="fn">Fangrui Song</span></a>
</span></b>
<pre>If I remove --no-rosegment, the file will be 4.9M
Type Offset VirtAddr PhysAddr FileSiz MemSiz
Flg Align
PHDR 0x000040 0x0000000000200040 0x0000000000200040 0x0002a0
0x0002a0 R 0x8
LOAD 0x000000 0x0000000000200000 0x0000000000200000 0x0002e0
0x0002e0 R 0x1000
LOAD 0x001000 0x0000000060000000 0x0000000060000000 0x245dc6
0x245dc6 R E 0x1000
LOAD 0x246dc8 0x0000000060246dc8 0x0000000060246dc8 0x177964
0x177964 R 0x1000<Paste>
[Nr] Name Type Address Off Size ES Flg
Lk Inf Al
[ 1] .text PROGBITS 0000000060000000 001000 245dc6 00 AX
0 0 32
If I keep it, the file will be 1.6G
Type Offset VirtAddr PhysAddr FileSiz MemSiz
Flg Align
PHDR 0x000040 0x0000000000200040 0x0000000000200040 0x0001f8
0x0001f8 R 0x8
LOAD 0x000000 0x0000000000200000 0x0000000000200000 0x601bed00
0x601bed00 R E 0x1000
LOAD 0x601bed00 0x00000000603bfd00 0x00000000603bfd00 0x0008e0
0x0008e0 RW 0x1000
[Nr] Name Type Address Off Size ES Flg
Lk Inf Al
[ 1] .text PROGBITS 0000000060000000 5fe00000 245dc6 00
AX 0 0 32
The large file size is due to the large sh_offset of .text, which is to meet
the requirement of `--Ttext 0x60000000`.
A lot of -Ttext assumes the traditional GNU ld layout where there is a RX
segment but no R segment.
Before "[ELF] Map the ELF header at imageBase", we had a weird layout where the
ELF header and PT_PHDR is mapped high addresses. So the commit actually fixed a
problem.
Type Offset VirtAddr PhysAddr FileSiz MemSiz
Flg Align
PHDR 0x000040 0x000000005ffff040 0x000000005ffff040 0x0001f8
0x0001f8 R 0x8
LOAD 0x000000 0x000000005ffff000 0x000000005ffff000 0x3bfd00
0x3bfd00 R E 0x1000
LOAD 0x3bfd00 0x00000000603bfd00 0x00000000603bfd00 0x0008e0
0x0008e0 RW 0x1000
To get that behavior, you may need to add --image-base=0x5ffff000 beside -Ttext
0x60000000.
I have looked at my /usr/bin/qemu-x86_64-static, which maps the ELF header at
0x60000000, instead of 0x5ffff000.
So I believe the better fix is to remove -Ttext and add
--image-base=0x60000000.</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>