Say for example I've got this C function:
void f(int *x, int *y)
{
(*x) = (*x) * (*y);
}
When saved to
f.c
, compiling with gcc -c f.c
produces f.o
. objdump -d f.o
gives this:
f.o: file format elf64-x86-64
Disassembly of section .text:
0000000000000000 :
0: 55 push %rbp
1: 48 89 e5 mov %rsp,%rbp
4: 48 89 7d f8 mov %rdi,-0x8(%rbp)
8: 48 89 75 f0 mov %rsi,-0x10(%rbp)
c: 48 8b 45 f8 mov -0x8(%rbp),%rax
10: 8b 10 mov (%rax),%edx
12: 48 8b 45 f0 mov -0x10(%rbp),%rax
16: 8b 00 mov (%rax),%eax
18: 0f af d0 imul %eax,%edx
1b: 48 8b 45 f8 mov -0x8(%rbp),%rax
1f: 89 10 mov %edx,(%rax)
21: 5d pop %rbp
22: c3 retq
I'd like it to output something more like this:
55 48 89 e5 48 89 7d f8 48 89 75 f0 48 8b 45 f8 8b 10 48 8b 45 f0 8b 00 0f af d0 48 8b 45 f8 89 10 5d c3
I.e., just the hexadecimal values of the function. Is there some objdump
flag to do this? Otherwise, what tools can I use (e.g. awk, sed, cut, etc) to get this desired output?
Asked by MD XF
(241 rep)
Feb 3, 2018, 12:30 AM
Last activity: May 29, 2023, 07:28 PM
Last activity: May 29, 2023, 07:28 PM