Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

go tool link custom sections in executable

166 views
Skip to first unread message

T Odin

unread,
Oct 1, 2021, 6:54:23 AM10/1/21
to golang-nuts
Hi, 

I'm trying to run an executable built from Go source on a target environment based out of Linux.
Loader on the target machine is customized and expects the elf sections to be in a different order.

I checked the Go source' link option in asm.go where it formats the elf header.

From my understanding, it requires this implementation to be changed to run on my target platform.
Is there any other way, like linker script (used in Linux) which can be used to build Go executable?

Ian Lance Taylor

unread,
Oct 1, 2021, 8:24:50 PM10/1/21
to T Odin, golang-nuts
The Go linker itself doesn't support linker scripts.

It may work to do something like -ldflags="-linkmode=external
-extldflags=-Tmylinkerscript".

Note that it's quite peculiar for a Linux implementation to require
ELF sections to be in a particular order. I don't understand what
would impose such a requirement.

Ian
Reply all
Reply to author
Forward
0 new messages