Is it possible to build a Go binary without the runtime ?

320 views
Skip to first unread message

Karolina GORNA

unread,
Jan 23, 2024, 5:28:28 PM1/23/24
to golang-nuts
Hi everyone,

I would like to build my Go program and to reverse-engineer it. I would find it easier to build it without the runtime and to statically analyse only the binary of the program.

Is it possible and if yes, how please ?

Thank you for your time.

Les informations contenues dans ce message électronique ainsi que celles contenues dans les documents attachés sont strictement confidentielles et sont destinées à l'usage exclusif du (des) destinataire(s) nommé(s).
Toute divulgation, distribution ou reproduction, même partielle, en est strictement interdite sauf autorisation écrite et expresse de l’émetteur.
Si vous recevez ce message par erreur, veuillez le notifier immédiatement à son émetteur par retour, et le détruire ainsi que tous les documents qui y sont attachés.

The information contained in this email and in any document enclosed is strictly confidential and is intended solely for the use of the individual or entity to which it is addressed.
Partial or total disclosure, distribution or reproduction of its contents is strictly prohibited unless expressly approved in writing by the sender.
If you have received this communication in error, please notify us immediately by responding to this email, and then delete the message and its attached files from your system.

Def Ceb

unread,
Jan 23, 2024, 6:19:26 PM1/23/24
to golan...@googlegroups.com
No, this is not possible. This is the case for practically every other
language, even C. Unless you intend on inspecting assembly text instead
of a real working binary.
The symbol table + debug symbols built into the binary by default should
make finding the `main.main` function trivial with just about any
reverse engineering tool.

'Karolina GORNA' via golang-nuts:
> Hi everyone,
>
> I would like to build my Go program and to reverse-engineer it. I would
> find it easier to build it without the runtime and to statically analyse
> only the binary of the program.
>
> Is it possible and if yes, how please ?
>
> Thank you for your time.
> ------------------------------------------------------------------------
> Les informations contenues dans ce message électronique ainsi que celles
> contenues dans les documents attachés sont strictement confidentielles
> et sont destinées à l'usage exclusif du (des) destinataire(s) nommé(s).
> Toute divulgation, distribution ou reproduction, même partielle, en est
> strictement interdite sauf autorisation écrite et expresse de l’émetteur.
> Si vous recevez ce message par erreur, veuillez le notifier
> immédiatement à son émetteur par retour, et le détruire ainsi que tous
> les documents qui y sont attachés.
>
> The information contained in this email and in any document enclosed is
> strictly confidential and is intended solely for the use of the
> individual or entity to which it is addressed.
> Partial or total disclosure, distribution or reproduction of its
> contents is strictly prohibited unless expressly approved in writing by
> the sender.
> If you have received this communication in error, please notify us
> immediately by responding to this email, and then delete the message and
> its attached files from your system.
> ------------------------------------------------------------------------
>
> --
> 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...@googlegroups.com
> <mailto:golang-nuts...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/9e309ee6-18ca-48b2-bf6b-e5a9e7325838n%40googlegroups.com <https://groups.google.com/d/msgid/golang-nuts/9e309ee6-18ca-48b2-bf6b-e5a9e7325838n%40googlegroups.com?utm_medium=email&utm_source=footer>.

Raffaele Sena

unread,
Jan 23, 2024, 6:50:40 PM1/23/24
to Def Ceb, golan...@googlegroups.com
Well, if it's a package/module you could build it as a library archive (go build -buildmode=archive) and then disassemble/decompile the library.


To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/a7746ded-49cb-4a8c-aa00-e2bb8676b23a%40gmail.com.

Def Ceb

unread,
Jan 23, 2024, 7:15:01 PM1/23/24
to golan...@googlegroups.com, Raffaele Sena
Interesting proposition, though from what I can tell, you're just going
to end up with goobj files, a somewhat obscure internal format of the
compiler, rather than a more typical object file format.

Raffaele Sena:
> <mailto:golang-nuts%2Bunsu...@googlegroups.com>
> > <mailto:golang-nuts...@googlegroups.com
> <mailto:golang-nuts%2Bunsu...@googlegroups.com>>.
> > To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/golang-nuts/9e309ee6-18ca-48b2-bf6b-e5a9e7325838n%40googlegroups.com <https://groups.google.com/d/msgid/golang-nuts/9e309ee6-18ca-48b2-bf6b-e5a9e7325838n%40googlegroups.com> <https://groups.google.com/d/msgid/golang-nuts/9e309ee6-18ca-48b2-bf6b-e5a9e7325838n%40googlegroups.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/golang-nuts/9e309ee6-18ca-48b2-bf6b-e5a9e7325838n%40googlegroups.com?utm_medium=email&utm_source=footer>>.
>
> --
> 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...@googlegroups.com
> <mailto:golang-nuts%2Bunsu...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/a7746ded-49cb-4a8c-aa00-e2bb8676b23a%40gmail.com <https://groups.google.com/d/msgid/golang-nuts/a7746ded-49cb-4a8c-aa00-e2bb8676b23a%40gmail.com>.
>

Raffaele Sena

unread,
Jan 23, 2024, 7:40:40 PM1/23/24
to Def Ceb, golan...@googlegroups.com
Yes, but there are tools to access the object files. I.e. you can do "go tool objdump module.a" and get the assembly for your module.

Def Ceb

unread,
Jan 23, 2024, 8:11:23 PM1/23/24
to Raffaele Sena, golan...@googlegroups.com
Ah, true.
Though you'd be limited to analyzing the assembly text instead of a
binary. And RE typically involves tools that work on binaries rather
than pre-compilation assembly in a text file.
Unless there's some way to convert this assembly into a working
stand-alone .o/.obj file which could be analyzed with typical reverse
engineering tools, then for the purposes of learning how to reverse
engineer binaries, I'd stick to full binaries. With debug info as
training wheels to start off with.

Raffaele Sena:
> Yes, but there are tools to access the object files. I.e. you can do "go
> tool objdump module.a" and get the assembly for your module.
>
>
> On Tue, Jan 23, 2024 at 4:14 PM Def Ceb <mikk....@gmail.com
> <mailto:mikk....@gmail.com>> wrote:
>
> Interesting proposition, though from what I can tell, you're just going
> to end up with goobj files, a somewhat obscure internal format of the
> compiler, rather than a more typical object file format.
>
> Raffaele Sena:
> > Well, if it's a package/module you could build it as a library
> archive
> > (go build -buildmode=archive) and then disassemble/decompile the
> library.
> >
> >
> > On Tue, Jan 23, 2024 at 3:18 PM Def Ceb <mikk....@gmail.com
> <mailto:mikk....@gmail.com>
> >     <mailto:golang-nuts%2Bunsu...@googlegroups.com
> <mailto:golang-nuts%252Buns...@googlegroups.com>>
> >      > <mailto:golang-nuts...@googlegroups.com
> <mailto:golang-nuts%2Bunsu...@googlegroups.com>
> >     <mailto:golang-nuts%2Bunsu...@googlegroups.com
> <mailto:golang-nuts%252Buns...@googlegroups.com>>>.
> >      > To view this discussion on the web visit
> >      >
> >
> https://groups.google.com/d/msgid/golang-nuts/9e309ee6-18ca-48b2-bf6b-e5a9e7325838n%40googlegroups.com <https://groups.google.com/d/msgid/golang-nuts/9e309ee6-18ca-48b2-bf6b-e5a9e7325838n%40googlegroups.com> <https://groups.google.com/d/msgid/golang-nuts/9e309ee6-18ca-48b2-bf6b-e5a9e7325838n%40googlegroups.com <https://groups.google.com/d/msgid/golang-nuts/9e309ee6-18ca-48b2-bf6b-e5a9e7325838n%40googlegroups.com>> <https://groups.google.com/d/msgid/golang-nuts/9e309ee6-18ca-48b2-bf6b-e5a9e7325838n%40googlegroups.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/golang-nuts/9e309ee6-18ca-48b2-bf6b-e5a9e7325838n%40googlegroups.com?utm_medium=email&utm_source=footer> <https://groups.google.com/d/msgid/golang-nuts/9e309ee6-18ca-48b2-bf6b-e5a9e7325838n%40googlegroups.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/golang-nuts/9e309ee6-18ca-48b2-bf6b-e5a9e7325838n%40googlegroups.com?utm_medium=email&utm_source=footer>>>.
> >
> >     --
> >     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...@googlegroups.com
> <mailto:golang-nuts%2Bunsu...@googlegroups.com>
> >     <mailto:golang-nuts%2Bunsu...@googlegroups.com
> <mailto:golang-nuts%252Buns...@googlegroups.com>>.
> >     To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/golang-nuts/a7746ded-49cb-4a8c-aa00-e2bb8676b23a%40gmail.com <https://groups.google.com/d/msgid/golang-nuts/a7746ded-49cb-4a8c-aa00-e2bb8676b23a%40gmail.com> <https://groups.google.com/d/msgid/golang-nuts/a7746ded-49cb-4a8c-aa00-e2bb8676b23a%40gmail.com <https://groups.google.com/d/msgid/golang-nuts/a7746ded-49cb-4a8c-aa00-e2bb8676b23a%40gmail.com>>.
> >
>

Jaon Dorb

unread,
Jan 24, 2024, 1:31:54 AM1/24/24
to golang-nuts
نعم 
Reply all
Reply to author
Forward
0 new messages