Everything in this course so far started life as C. Plenty of software does not. C++ is everywhere in large applications and games, Go is common in network tools and, increasingly, in malware, and Rust shows up in more places every year. All three compile to machine code, so the tools are the same. What changes is how much the compiler adds around the author's logic, and the habits you built on C need adjusting.
This lesson is a tour and not a full treatment. Each of these languages could fill a course. The aim is that you can tell which one you are looking at, know what its oddities mean, and find the author's code.
The download holds three small programs and their sources: shapes in C++, word-go in Go and word-rs in Rust.
Start with the size:
wc -c shapes word-go word-rs 14360 shapes2611793 word-go4505144 word-rs7131297 totalEach of these programs is about twenty lines of source. The C++ one is the size of a C program. The other two are measured in megabytes, because Go and Rust both link their standard libraries into the binary, as the static program did in Statically-Linked Binaries.
Compilers usually sign their work. The quickest checks:
strings word-go | grep -m1 '^go1\.'go1.26.10-X:nodwarf5strings word-rs | grep -m1 /rustc/Word: flush failed/rustc/0ef1bc386059596dada8fb65b50425aab2ea637a/library/std/src/io/stdio.rsreadelf -p .comment shapes | grep GCC [ 0] GCC: (GNU) 16.2.1 20260819 (Red Hat 16.2.1-2) [ 2e] GCC: (GNU) 16.2.1 20261029 (Red Hat 16.2.1-3)A Go binary contains its compiler version as a string. A Rust binary is full of source paths starting /rustc/ followed by the compiler's commit hash, left there for error messages. A C or C++ binary built with GCC has a .comment section naming the compiler. file reports some of this too, and prints a Go BuildID for Go.
When those are stripped or missing, the function names and strings still give the language away, as the next three sections show. As a quick reference:
| Sign | Language |
|---|---|
Symbols beginning _Z, names like std:: and operator new | C++ |
Symbols like main.main, runtime., fmt.; a go1. version string | Go |
Symbols beginning _R or _ZN…17h; paths starting /rustc/; core:: and alloc:: | Rust |
echo circle | ./shapesShape: area: 12.5664C++ is the closest to home. It uses the C calling convention, usually links dynamically, and Ghidra handles it well. Three things are new.
C++ lets many functions share a name, as long as they belong to different classes or take different arguments. The linker needs every symbol to be unique, so the compiler encodes the class and the argument types into each name. This is called name mangling:
nm shapes | grep area0000000000400620 W _ZNK6Circle4areaEv0000000000400640 W _ZNK6Square4areaEvnm -C shapes | grep area0000000000400620 W Circle::area() const0000000000400640 W Square::area() const_ZNK6Circle4areaEv reads, once you know the scheme, as the const method area of the class Circle, taking no arguments. You never need to decode these by hand. nm -C does it, the c++filt command does it, and Ghidra does it during analysis. Just recognize that a symbol starting _Z is C++.
Mangled names are a gift. In a C++ binary that has not been stripped, they give you every class name and every method's argument types, which is more than a C symbol table ever tells you.
thisA method is an ordinary function with one hidden parameter: a pointer to the object it was called on. Ghidra shows it:
1/* Circle::area() const */
2
3double __thiscall Circle::area(Circle *this)
4{
5 return DAT_00401798 The source says return 3.14159 * radius * radius;. In the binary, radius is the 8 bytes at offset 8 of the object. This is the struct access from Data & Types: a class is a struct, its fields live at fixed offsets from this, and you recover and name them the same way.
The question is what sits at offset 0. main shows it:
1 if (local_30 == 6) {
2 iVar1 = memcmp(local_38,"circle",6);operator_new(0x10) allocates 16 bytes for an object. The second 8 bytes get the radius or the side length. The first 8 bytes get a pointer into a table, a different table for Circle and for Square. That table is the class's vtable: a list of the addresses of its virtual methods. Every object of a class with virtual methods starts with a pointer to its class's vtable.
Then comes the call, and it is the line to learn to read:
dVar4 = (double)(**(code **)(*plVar2 + 0x10))(plVar2);From the inside: *plVar2 fetches the vtable pointer from the object. + 0x10 moves to the third entry in that table. The outer * fetches the function address stored there, and it is called with plVar2, the object, as its argument, which is this. The source for all of that is shape->area().
The program does not know at this line whether it is calling Circle::area or Square::area. It calls whatever the object's table says. For a reverse engineer that means an indirect call has no cross-reference to follow. To find where it goes, work out which class the object is, find that class's vtable in the Listing, and read the entry at that offset. Ghidra labels the vtables, and nm -C lists them as vtable for Circle.
One last thing in that listing: the comparison name == "circle" came out as a length check, local_30 == 6, followed by a memcmp. A C++ std::string stores a pointer and a length side by side, and the three locals local_38, local_30 and local_28 are one string object that Ghidra has shown in pieces.
echo gopher | ./word-goWord: Correct.A Go binary is its own world. It is statically linked and carries the Go runtime, which includes a memory manager, a garbage collector and a scheduler. Ghidra finds 2,048 functions in this one. Our source file has two, and after the compiler merged them, one is left.
The good news is that Go keeps its function names. They are stored in a table the runtime uses to print stack traces, and that table survives strip. Recent versions of Ghidra read it, so the functions arrive named:
nm word-go | grep ' main\.'00000000004aa300 T main.mainGo names are package.function. Everything the author wrote is in the package main, or in packages with the author's own project name. Everything in runtime., fmt., strings., os. and similar is the standard library. Filter the Symbol Tree for main. and you have the author's code. That is the single most useful fact about Go binaries. Note that the program's real starting function is main.main. There is no C-style main.
Three things in the decompilation look strange until you know them.
Every function begins with a stack check:
1 while (&uStack0000000000000000 <= CURRENT_G.stackguard0) {
2 runtime::runtime_morestack_noctxt();
3 }Go grows its stacks on demand, so each function first checks whether it has room and asks for more if not. It is at the top of nearly every Go function. Skip it.
Strings are not C strings. A Go string is a pointer and a length, and the bytes are not followed by a zero. The compiler packs all of a program's string data together with nothing in between, which makes strings output hard to read:
strings word-go | grep -o '.\{10\}Wrong\..\{10\}'sse3Word: Wrong.StringFormWord: and Wrong. are two separate strings from our program, run together with unrelated library text on both sides. Where one ends is recorded only in the code that uses it, as a length. In the decompilation, look for a pointer and a number travelling together.
And the calling convention is Go's own. Arguments go in registers, but in a different set and order from C: rax, rbx, rcx, rdi, rsi, r8 and onward. Ghidra knows this for Go binaries, but when you check a call in the assembly, do not expect rdi to be the first argument.
With those in mind, the check is readable:
1 sVar1 = strings::strings_ToUpper(*local_10);
2 if (((sVar1.len == 6) && (The source is strings.ToUpper(word) == "GOPHER". The compiler placed our check function inline in main.main and turned the string comparison into a length test and two number comparisons. 0x48504f47 is GOPH read backwards and 0x5245 is ER, the technique from Strings & Constants. The input is upper-cased first, so gopher in any mix of case passes.
echo rust | ./word-rsWord: Correct.Rust sits between the two. Like C++ it mangles names and links the C library dynamically. Like Go it compiles its own standard library into the binary and uses strings with a length and no terminator. Ghidra finds 631 functions here.
Rust symbols start with _R, or in older binaries with _ZN and end in 17h and a hash. Ghidra demangles both, into paths like core::ptr::drop_glue and std::rt::lang_start. As with Go, the author's code is under the program's own name, here word::main, and core::, alloc:: and std:: are the library. The C-style main that __libc_start_main receives is a small stub that calls std::rt::lang_start, which eventually calls the real one.
Two features dominate Rust decompilation.
The first is error handling. Rust programs check everything, and each check that fails calls a function that prints a message and stops the program, which Rust calls a panic:
1 auVar19 = (*(code *)PTR_read_line_00154b70)(&local_50,&local_48);
2 pbVar4 = local_40;
The source for this is one line: io::stdin().read_line(&mut word).expect("read failed");. The branch that calls unwrap_failed is the path taken when reading fails. Treat every block that ends in a panic as an error path and read past it. What remains is the normal flow. These blocks are also informative: the message is the author's own, passed with its length, 0xb for the 11 characters of read failed, and the last argument points at the source file name and line number.
The second is how much code one line turns into. Rust builds a separate copy of each generic function for every type it is used with, and then optimizes hard. Our check function is three lines:
1fn check(word: &str) -> bool {
2 let reversed: String = word.trim(There is no check in the binary. It was placed inline in main, and trim, chars, rev and collect went inline with it. Ghidra's main is about 280 lines long, most of them loops that decode text one character at a time and skip whitespace. None of those loops are the author's logic. The part that is comes near the end:
if (iVar1 == 0x72757374) {0x72757374 is tsur read backwards. The input is trimmed, reversed and compared with tsur, so the word is rust.
With Rust, do not try to read main from top to bottom. Find the landmarks, which are the strings, the panic messages and the comparisons against constants, and read outward from them only as far as you need.
The amount of code changes most. C gave us binaries where nearly every function was the author's. In Go and Rust the author's share is a fraction of one percent, and the first job is always to find it: main. in Go, the crate's own name in Rust, the class names in C++.
Assumptions about strings change. A length passed next to a pointer is the rule in Go, Rust and C++, and strings output runs together.
Some calls become indirect, through vtables in C++ and similar tables in the other two, and those cannot be followed by cross-reference.
The method stays the same. Identify the file. Find where the author's code starts. Use strings, constants and library calls as landmarks. Name things as you understand them. Decide what not to read. Each lesson in this course applies here unchanged, with a longer list of things to skip.
_Z for C++, main.main and runtime. for Go, _R and /rustc/ for Rust.this parameter, and virtual calls through a vtable stored at the start of each object.main.*, skip the stack check at the top of each function, and expect strings with lengths and no terminators.The last lesson in this section, Anti-Analysis, looks at binaries built on purpose to make all of this fail.