<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/82170>82170</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[llvm-objcopy] seems to fail to add a gnu-debuglink on Go ld-output binaries on ppc64le
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
nekopsykose
</td>
</tr>
</table>
<pre>
(and maybe aarch64?)
for a start, i built https://github.com/yggdrasil-network/yggdrasil-go :
```console
$ mkdir out
$ go build -o out/ ./cmd/...
```
then, i simulated splitting debuginfo and adding back a debuglink:
```
$ llvm-objcopy --only-keep-debug out/yggdrasilctl x
$ llvm-objcopy --add-gnu-debuglink="$PWD"/x out/yggdrasilctl
$ llvm-objdump -s -j .gnu_debuglink out/yggdrasilctl
out/yggdrasilctl: file format elf64-powerpcle
llvm-objdump: warning: section '.gnu_debuglink' mentioned in a -j/--section option, but not found in any input file
$ llvm-readelf -a out/yggdrasilctl >/dev/null
llvm-readelf: warning: 'out/yggdrasilctl': SHT_STRTAB string table section [index 9] is non-null terminated
llvm-readelf: error: 'out/yggdrasilctl': SHT_STRTAB string table section [index 9] is non-null terminated
```
seemingly, something exploded here. but, using ld.lld instead (/usr/bin/ld is lld, and external linkmode makes go not use its own linker and invoke ld normally):
```
go build -o out/ -ldflags="-linkmode external" ./cmd/...
```
then works fine:
```
$ llvm-objcopy --only-keep-debug out/yggdrasilctl x
$ llvm-objcopy --add-gnu-debuglink="$PWD"/x out/yggdrasilctl
$ llvm-objdump -s -j .gnu_debuglink out/yggdrasilctl
out/yggdrasilctl: file format elf64-powerpcle
Contents of section .gnu_debuglink:
0000 78000000 5b3c64ed x...[<d.
```
so, i am not sure if:
- the go linker is broken on these architectures in some way and makes an invalid output (?)
- llvm objcopy is not handling something here from the output. note the errors reported in llvm-readelf are not reported right after the binary is made- they only show up after running objcopy
for reference, the `yggdrasilctl` ppc64le binaries can be found here: https://img.ayaya.dev/3jO9b8kXBdbx
(a .tar.zst). those are the go build outputs before any objcopy.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsVk9v47YT_TT0ZSBBpvxPBx-SzU-_3lp0F2hvi5E4khlTpEBS67ifvhjKTuLUu2gvPdUIJIVDzjzOm3kkhqB7S7QX60exflrgFA_O7y0d3RjORxdo0Th13gu5Q6tgwHNDgOjbw2YlylrICkAUT6J4mJ-d84AQIvoo5CfQ0EzaRDjEOAZRPghZC1n3Oh6mJm_dIGR97nvlMWiTWYon5483Y70DUT7chBCbYv5rnQ3O0GVUrmA4Ku3BTfFtqHcJgYLMJYOsIReybgclZJ3n-QeX7-PEA9l5D0EPk8FICsJodIza9qComXptOwecF1SKBxtsj4CzzWh7ZOj3sb8hNObbkLnmuXXjGbLMWXPOjkRjlrxcQL8mpI0GXr67GJXKejtl7wA8CSmFXP3y2_xRv9zx-Fd_ahpGyAJkz5D3dvr66vD7q9PzjrV8EEXVaUPQOT9gBDLdZpWN7kR-bK_0vQ_MWTuht9r2_BmojdpZEHJ7i0XILQxk2UgKtAWE7FnIOsuuS9zILyaxmSJYF6Fzk53n2jNoO04RGNuHDHhCRaaDDO_lX5T_E7JW9E3I2k7GvNvBZeGHHQi5vZMYuWXb55--fP385dcvD48QouciitgYetv1-lFbRS9QifUT6ADW2YyjQiQ_aMtleR8Aee_8vxf-bg8FokHb3pyZg-AGigeOQS-jcYoUHMhTzuSwfQpsMyo3hikKkVCBkDsh6yl4IetGWyFrNgYwRvEabj56ieQtGuCiGJwiGPBIgXufKZ8CgY4B3MmmGeTTKm2_uSOBUWC5Lg1jrL6rNfO_d9QkM6oz2Ie507JXCFdQQsp_pDjAEhig05b-U4-_qx6fnI1kmePutXI_aEV5iQFFURSw3RXpB-umbDcrUnDn98JsrR9F-Un9iLXg5lMCh1RuYfIEuvtYSRnEA3FJXkpQB2i8O5IFZ9kUCPhU1ZHaOHkKrFHcMHD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