Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamic Symbol Resolution of Executable Using LLVM

I am currently using LLVM's ObjectFile (documented here) to represent an executable. I have successfully read in an executable to the ObjectFile and would like to determine which call destination addresses in my executable correspond to symbol names contained in the symbol_iterator obtained by a call to the begin_dynamic_symbols() function. Iterating over each of the symbols in the symbol_iterator gives me the name of each symbol and its address, but since the symbols are dynamic, the address of each symbol is -1; this indicates that the ObjectFile does not associate symbol names directly with their corresponding call destination addresses.

Is there any way to determine which call destination addresses map to which dynamic symbols in an ObjectFile? I would rather not manually calculate all the jumps through the PLT and GOT if I can avoid doing so.

like image 600
RouteMapper Avatar asked May 03 '13 17:05

RouteMapper


1 Answers

Dynamic symbols' addresses are only calculated when the object files gets loaded into memory and linked into the program's symbol table. In general, it's impossible to determine their final address before linking.

You may be able to get the data you want using LLVM's Link-Time Optimization module instead of ObjectFile, as that does perform address linking when loading a module, if I recall correctly.

Good luck!

like image 108
Marc Ordinas i Llopis Avatar answered Nov 07 '22 15:11

Marc Ordinas i Llopis