What minimum informations must contain an elf executable to be loaded?

Hi,

I'm trying to write a tiny elf under *BSD by writing his own elf header with GNU Assembler. Concretely, I write his elf header, 3 program header (for interpreter,code,dynamic) and no section header. The code works under linux (with /lib/ld-linux.so) but it segfaults under freebsd. So I'm wondering if under *BSD an elf executable need to have an additional information to work?

Main code is here.

Kind regards.
 
Specify the FreeBSD ABI (i.e. 9):
Code:
.byte 0x7F, 'E', 'L', 'F', 1, 1, 1, 9, 0

Push a return value when you exit (e.g. 0):
Code:
push 0
xor eax,eax
inc eax
int 0x80
 
Hmm.. weird, I though compiled the freebsd kernel with the System V compatibility. Otherwise, now it doesn't segfault but it says:

Code:
/libexec/ld-elf.so.1: /usr/home/user/dev/sym/main: Shared object has no run-time symbol table

I guess it requires at least a section header table. I will see this tomorrow.
Thanks for reply.

Kind regards.
 
Back
Top