Re:LLMs can read and write executables byte by byte from a h...
by kragen on Sunday November 22, 2026 @09:53AM
(#50600248)
Not necessarily, because there is often code that is only accessible through function pointers; for example, C++ virtual methods. (In theory you can compute function pointers dynamically at runtime, too, which is less common.)
In https://canonical.org/~kragen/sw/dev3/qfitzah.s a lot of the function calls are conditionally compiled by the macro `do` (search for `.macro do`) to index into a table of function pointers pointed to by EBP, because that makes the call instructions 3 bytes instead of 5 bytes. Here I've disassembled one of the functions from the parser code from an unstripped version that has debugging symbols:
The actual source code to that subroutine looks like this:
proc read_term
do read_factor
jnz 1f # if it failed, skip ahead
push %eax # save returned term
do read_term # recursive call for tail of term
push %eax
do skip_whitespace
pop %ecx
pop %eax
do cons # XXX tail call
ret
1: setnil %eax # return nil if no factor found
ret
I didn't do this to make it harder to disassemble, but it does have that drawback.
In 32-bit ARM code you have the additional problem that you have to know whether the T bit is intended to be set when the CPU is decoding a particular subroutine. The low bit of the branch destination tells you — which is fine if it's statically reachable, but you may have to guess if it's only dynamically reachable.
In https://canonical.org/~kragen/sw/dev3/qfitzah.s a lot of the function calls are conditionally compiled by the macro `do` (search for `.macro do`) to index into a table of function pointers pointed to by EBP, because that makes the call instructions 3 bytes instead of 5 bytes. Here I've disassembled one of the functions from the parser code from an unstripped version that has debugging symbols:
The actual source code to that subroutine looks like this: I didn't do this to make it harder to disassemble, but it does have that drawback.In 32-bit ARM code you have the additional problem that you have to know whether the T bit is intended to be set when the CPU is decoding a particular subroutine. The low bit of the branch destination tells you — which is fine if it's statically reachable, but you may have to guess if it's only dynamically reachable.