0

I have printed the address of the function in U-boot by adding the following print.

  printf("initcall: %pS \n", (char *)*init_fnc_ptr - reloc_ofs);

Following line printed by adding debug prints. Is there anyway to know the function name from the function address.

  initcall: 80809c05
user3693586
  • 1,227
  • 5
  • 18
  • 40
  • 1
    https://stackoverflow.com/questions/351134/how-to-get-functions-name-from-functions-pointer-in-c probably? – Moritz Schmidt Apr 17 '19 at 02:26
  • In U-boot we will not be having /proc/, backtrace() also not available in U-boot. – user3693586 Apr 17 '19 at 02:50
  • Subtract the load address and then look up the symbol table of the compiled binary – andi8086 Apr 17 '19 at 13:26
  • regarding the example output: "initcall: 80809c05" This is NOT the output from the posted code, because the call to `printf()` has a 'S' after the address. – user3629249 Apr 18 '19 at 19:50
  • The output format specifier is expecting a `void*`, not a `char*` – user3629249 Apr 18 '19 at 19:51
  • regarding: `printf("initcall: %pS \n", (char *)*init_fnc_ptr - reloc_ofs);` why not simply use: `printf("initcall: %s\n", "init_fnc_ptr");` or, more generic: `printf("initcall: %s \n", __func__);` – user3629249 Apr 18 '19 at 19:57

1 Answers1

0

When building U-Boot a file u-boot.map is written. You can look up the the addresses of the functions (before relocation) there.

Xypron
  • 2,215
  • 1
  • 12
  • 24