Maybe this The elfutils project
Dunno, it's one of those esoteric things to want to do.
Like you're the maintainer for binutils and you're porting to a completely new architecture.
Enjoy.
Code:
$ cat foo.c
int foo ( ) {
return 42;
}
$ gcc -c foo.c # generate the object code
$ gcc -c -S foo.c # generate the asm
$ cat foo.s
.file "foo.c"
.text
.globl foo
.type foo, @function
foo:
.LFB0:
.cfi_startproc
endbr64
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
movl $42, %eax
popq %rbp
.cfi_def_cfa 7, 8
ret
.cfi_endproc
<< snipped boilerplate >>
$ objdump -d foo.o
foo.o: file format elf64-x86-64
Disassembly of section .text:
0000000000000000 <foo>:
0: f3 0f 1e fa endbr64
4: 55 push %rbp
5: 48 89 e5 mov %rsp,%rbp
8: b8 2a 00 00 00 mov $0x2a,%eax
d: 5d pop %rbp
e: c3 retq
$ hd foo.o | head -20
00000000 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 |.ELF............|
00000010 01 00 3e 00 01 00 00 00 00 00 00 00 00 00 00 00 |..>.............|
00000020 00 00 00 00 00 00 00 00 58 02 00 00 00 00 00 00 |........X.......|
00000030 00 00 00 00 40 00 00 00 00 00 40 00 0c 00 0b 00 |....@.....@.....|
00000040 f3 0f 1e fa 55 48 89 e5 b8 2a 00 00 00 5d c3 00 |....UH...*...]..|
00000050 47 43 43 3a 20 28 55 62 75 6e 74 75 20 39 2e 33 |GCC: (Ubuntu 9.3|
00000060 2e 30 2d 31 37 75 62 75 6e 74 75 31 7e 32 30 2e |.0-17ubuntu1~20.|
00000070 30 34 29 20 39 2e 33 2e 30 00 00 00 00 00 00 00 |04) 9.3.0.......|
There's your program instructions in your ELF.
Go getem tex!