I've worked on this some more now, and it turns out that while directly 
executing the result of `upx -9` breaks,
you can use `upx --exact -9` to compress your exe and then `upx -d` to 
decompress it later. The decompressed
executable works with the .debug file.

On Wednesday, August 12, 2020 at 3:56:13 PM UTC-4, Ethan Pailes wrote:
>
> Wow, that works perfectly! Thank you so much!
>
> The --add-gnu-debuglink=x.debug bit was what I was missing.
>
> Unfortunately, it doesn't seem like delve supports separate debug info 
> yet, so I'll have to stick with gdb in these situations.
>
> Also, it seems that upx[1] breaks the debuglink, which doesn't seem 
> entirely unreasonable (I'm mostly including this tidbit in case someone 
> else in a similar situation to mine finds this post)
>
> [1]: https://upx.github.io/
>
> On Wednesday, August 12, 2020 at 12:26:24 PM UTC-4, Ian Lance Taylor wrote:
>>
>> On Wed, Aug 12, 2020 at 8:43 AM ethan.pailes via golang-nuts 
>> <golan...@googlegroups.com> wrote: 
>> > 
>> > The C ecosystem allows one to generate a separate file containing debug 
>> info so that you can initially install a stripped library or binary and 
>> then only pull in the debug info as needed. I'm interested in doing the 
>> same for go, but I have not been able to find an equivalent to the 
>> -gsplit-dwarf compiler flag. I've tried using `objcopy --only-keep-debug` 
>> to generate a .debug file, but it didn't seem to take. 
>> > 
>> > Has anyone else gone down this road? I would also be glad to hear that 
>> this is just known not to be possible at this point so that I can stop 
>> digging. 
>> > 
>> > For a little context as to why I want to do this, we are using go on 
>> embedded devices and we would like to keep our payload size down for OTA 
>> updates so we would rather avoid shipping debug info that will only be used 
>> rarely. 
>>
>> I would expect the objcopy approach to work. 
>>
>> go build x 
>> objcopy --only-keep-debug x x.debug 
>> objcopy --strip-debug --add-gnu-debuglink=x.debug x x.stripped 
>>
>> Where does that go wrong? 
>>
>> Ian 
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/ad61979a-6801-48ea-8bcb-58f3c7260e21o%40googlegroups.com.

Reply via email to