<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/54456>54456</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang14/llvm-objdump errors out with invalid empty dynamic section on x86_64
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
kraj
</td>
</tr>
</table>
<pre>
Attached binary is produced for x86_64/musl system using clang14 and then llvm-objcopy is used to create separate debug info file from it with `llvm-objcopy --keep-only-debug` command, now when the debug file is dumped with GNU objdump then it comes out to be ok
GNU objdump -p
```
tmp/work/core2-64-yoe-linux-musl/dhcp-relay/4.4.2p1-r0/packages-split/dhcp-relay-dbg/usr/sbin/.debug/dhcrelay: file format elf64-x86-64
Program Header:
PHDR off 0x0000000000000040 vaddr 0x0000000000000040 paddr 0x0000000000000040 align 2**3
filesz 0x0000000000000230 memsz 0x0000000000000230 flags r--
INTERP off 0x0000000000000270 vaddr 0x0000000000000270 paddr 0x0000000000000270 align 2**0
filesz 0x0000000000000000 memsz 0x0000000000000019 flags r--
LOAD off 0x0000000000000000 vaddr 0x0000000000000000 paddr 0x0000000000000000 align 2**12
filesz 0x0000000000000270 memsz 0x0000000000001be0 flags r--
LOAD off 0x0000000000001000 vaddr 0x0000000000002000 paddr 0x0000000000002000 align 2**12
filesz 0x0000000000000000 memsz 0x00000000000034d3 flags r-x
LOAD off 0x0000000000001000 vaddr 0x0000000000006000 paddr 0x0000000000006000 align 2**12
filesz 0x0000000000000000 memsz 0x00000000000014bc flags r--
LOAD off 0x0000000000001ae0 vaddr 0x0000000000008ae0 paddr 0x0000000000008ae0 align 2**12
filesz 0x0000000000000000 memsz 0x0000000000000ea8 flags rw-
DYNAMIC off 0x0000000000001ae0 vaddr 0x0000000000008af0 paddr 0x0000000000008af0 align 2**3
filesz 0x0000000000000000 memsz 0x0000000000000210 flags rw-
EH_FRAME off 0x0000000000001000 vaddr 0x0000000000006f50 paddr 0x0000000000006f50 align 2**2
filesz 0x0000000000000000 memsz 0x00000000000000ac flags r--
STACK off 0x0000000000000000 vaddr 0x0000000000000000 paddr 0x0000000000000000 align 2**4
filesz 0x0000000000000000 memsz 0x0000000000000000 flags rw-
RELRO off 0x0000000000001ae0 vaddr 0x0000000000008ae0 paddr 0x0000000000008ae0 align 2**0
filesz 0x0000000000000000 memsz 0x0000000000000520 flags r--
Dynamic Section:
```
llvm-objdump -p
```
tmp/work/core2-64-yoe-linux-musl/dhcp-relay/4.4.2p1-r0/packages-split/dhcp-relay-dbg/usr/sbin/.debug/dhcrelay: file format elf64-x86-64
Program Header:
PHDR off 0x0000000000000040 vaddr 0x0000000000000040 paddr 0x0000000000000040 align 2**3
filesz 0x0000000000000230 memsz 0x0000000000000230 flags r--
INTERP off 0x0000000000000270 vaddr 0x0000000000000270 paddr 0x0000000000000270 align 2**0
filesz 0x0000000000000000 memsz 0x0000000000000019 flags r--
LOAD off 0x0000000000000000 vaddr 0x0000000000000000 paddr 0x0000000000000000 align 2**12
filesz 0x0000000000000270 memsz 0x0000000000001be0 flags r--
LOAD off 0x0000000000001000 vaddr 0x0000000000002000 paddr 0x0000000000002000 align 2**12
filesz 0x0000000000000000 memsz 0x00000000000034d3 flags r-x
LOAD off 0x0000000000001000 vaddr 0x0000000000006000 paddr 0x0000000000006000 align 2**12
filesz 0x0000000000000000 memsz 0x00000000000014bc flags r--
LOAD off 0x0000000000001ae0 vaddr 0x0000000000008ae0 paddr 0x0000000000008ae0 align 2**12
filesz 0x0000000000000000 memsz 0x0000000000000ea8 flags rw-
DYNAMIC off 0x0000000000001ae0 vaddr 0x0000000000008af0 paddr 0x0000000000008af0 align 2**3
filesz 0x0000000000000000 memsz 0x0000000000000210 flags rw-
EH_FRAME off 0x0000000000001000 vaddr 0x0000000000006f50 paddr 0x0000000000006f50 align 2**2
filesz 0x0000000000000000 memsz 0x00000000000000ac flags r--
STACK off 0x0000000000000000 vaddr 0x0000000000000000 paddr 0x0000000000000000 align 2**4
filesz 0x0000000000000000 memsz 0x0000000000000000 flags rw-
RELRO off 0x0000000000001ae0 vaddr 0x0000000000008ae0 paddr 0x0000000000008ae0 align 2**0
filesz 0x0000000000000000 memsz 0x0000000000000520 flags r--
llvm-objdump: error: 'tmp/work/core2-64-yoe-linux-musl/dhcp-relay/4.4.2p1-r0/packages-split/dhcp-relay-dbg/usr/sbin/.debug/dhcrelay': invalid empty dynamic section
```
I could reproduce this with llvm-objdump 13 as well.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztWd9zmzgQ_mvwyw4eIX7YfuDBjdNL5to047YP99QRIGxigRhJxPH99beA04YcdOK4ncTTaDRCYtHq208rtIJIJrtwbgyL1zyBKCuY2kGmoVQyqWK8lUoFd9PgW-BZ9H1eaQF6pw3PodJZsYJYsGLleMCKBMyaFyDEbW7L6CaWZaOo0qjESIgVZ4aD5iVTdSXhUbWCrEglpJngkCqZQ2Zgm5k1WAHp6LHtDeelLQuxs5uO-ADEMs9xWIueQSG3sK1HRwh7zY1SHD-p8hIRNGr_uvoKqLK-1YLF8VAL1yArU4OMOMgNWGRhkXlbPuxil3tJQPa5aZq8RGq2Um3wEkvFqR149k5yW2RFdWfXpKEkWcelrbhgO2x4Y29MS8dWBBslizdsxbWtS5GZzqN2Eq3wRqUVlhqnBy_jloHmsVafO4c6tTxKlTMDXKQIAicOscChqbXr4G6vKLUWXCu5UiyHC84Sru5pOpX0YxauLxZLkGla18kd6SSPwC1LEtUnKIcETGSrAqhF55jdR9Ndu5H-93E36hLIed4vSAVbaVC2_cJUXV59OV9eD1BFJwNU1YJeqmpBhyryJKow9VNFnNmroQrgw6f5YsiryJBXkSGvIo-ocujT3GrSz5UT8Qdu9RTQzhBoOgSa9oD-pQz_xO4hH3G9xP1u991RdgdDdgfPsPsooxwvig-cTMb7jZrWgj6jGsFzPHAINOFseg96-8KrdfHP1fzj5dnBXKVDXKXP2gMGqaIOeSVU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