Which part of go compiler set the symbol "runtime.text" in the final build?
106 views
Skip to first unread message
Zxilly Chou
unread,
Jan 24, 2024, 1:21:59 PM1/24/24
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golang-nuts
Yesterday, I reported an issue on debug/gosym at issues/65232 regarding the difference between the symbol table and gopclntab. A member of the Go team informed me that the start of the .text segment is not always kept the same as 'runtime.text' value. I am curious about how the compiler sets this symbol and if there is a way to obtain this value without relying on the symbol table. Additionally, how does a compiled binary locate it even after being stripped?
Any suggestions would be appreciated.
Def Ceb
unread,
Jan 24, 2024, 2:09:44 PM1/24/24
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golan...@googlegroups.com
The binary stores a lot of ancillary data for runtime access. This
(mostly?) spans out from runtime.pclntab and runtime.firstmoduledata and
all the structures referenced by them. This is uniform across all
platforms too, with the runtime doing the same operations across
different OS-es and executable formats instead of using some
ELF/PE/Mach-O specific features.
Looking at a decompiled cgo binary where .text != runtime.text, some
values that reference runtime.text are:
runtime.pclntab.textStart
runtime.firstmoduledata.minpc
runtime.firstmoduledata.text
I think this should, at the very least, lead you in the right direction.