A) Flat binaries are horrible.
B) I want to write programs in C.
I chose a.out. The only reasonable source I found was this:
https://www.freebsd.org/cgi/man.cgi?query=a.out&apropos=0&sektion=0&manpath=NetBSD+1.4&format=html
There are very detailed descriptions of structures used in a.out and information that the file starts with the exec structure in this text. Unfortunately, there is no information where the rest of them is in the file. Moreover, the sizes of these structures read from the exec header do not add up to the total file size. The file size is 80 bytes. The text segment is 20 bytes long. The size of the symbol table is 12 and the size of the text relocation table is 8. Additionally, exec structure has 32 bytes, so the file is 8 bytes longer than it should be. I obtained this file by assembling this code with NASM:
Code: Select all
BITS 32
mov edi, msg
mov eax, 0x125716
call eax
ret
msg:
db 'TEST', 10, 0
Code: Select all
nasm -f aout aout_test.asm -o aout_test
Code: Select all
0000000 0107 0064 0014 0000 0000 0000 0000 0000
0000010 000c 0000 0000 0000 0008 0000 0000 0000
0000020 0dbf 0000 b800 5716 0012 d0ff 54c3 5345
0000030 0a54 9000 0001 0000 0004 0400 0004 0000
0000040 0004 0000 000d 0000 0008 0000 736d 0067
0000050
Code: Select all
{a_midmag = 6553863, a_text = 20, a_data = 0, a_bss = 0, a_syms = 12, a_entry = 0, a_trsize = 8, a_drsize = 0}