fork(2) download
  1. #include <stdio.h>
  2.  
  3. void foo(void);
  4. void bar(void);
  5. void print_function_instructions(void *func_ptr, size_t func_len);
  6.  
  7. int main(void) {
  8. void *foo_addr = (void*)foo;
  9. void *bar_addr = (void*)bar;
  10.  
  11. print_function_instructions(foo_addr, bar_addr - foo_addr);
  12.  
  13. return 0;
  14. }
  15.  
  16. void foo(void) {
  17. int i=0;
  18. i++;
  19. printf("i: %d\n", i);
  20. }
  21.  
  22. void bar(void) {
  23. printf("something");
  24. }
  25.  
  26. void print_function_instructions(void *func_ptr, size_t func_len) {
  27. unsigned char i=0;
  28. for(i; i<func_len; i++) {
  29. unsigned char *instruction = (unsigned char*)func_ptr+i;
  30. printf("%p (%2u): %x\n", func_ptr+i, i, *instruction);
  31. }
  32. }
Success #stdin #stdout 0s 2052KB
stdin
Standard input is empty
stdout
0x80484b0 ( 0): 83
0x80484b1 ( 1): ec
0x80484b2 ( 2): 14
0x80484b3 ( 3): 6a
0x80484b4 ( 4): 1
0x80484b5 ( 5): 68
0x80484b6 ( 6): c0
0x80484b7 ( 7): 85
0x80484b8 ( 8): 4
0x80484b9 ( 9): 8
0x80484ba (10): e8
0x80484bb (11): 91
0x80484bc (12): fe
0x80484bd (13): ff
0x80484be (14): ff
0x80484bf (15): 83
0x80484c0 (16): c4
0x80484c1 (17): 1c
0x80484c2 (18): c3
0x80484c3 (19): 8d
0x80484c4 (20): b6
0x80484c5 (21): 0
0x80484c6 (22): 0
0x80484c7 (23): 0
0x80484c8 (24): 0
0x80484c9 (25): 8d
0x80484ca (26): bc
0x80484cb (27): 27
0x80484cc (28): 0
0x80484cd (29): 0
0x80484ce (30): 0
0x80484cf (31): 0