This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Retrieving function addresses in an object file


Hello All,

I am in the process of creating a simple, custom object file format (with position independent code) with the following principal layout:

obj_file_header
function_1_header
function_2_header
...
function_n_header
function_1
function_2
...
function_n

function_x is the actual start of the entire function_x code. It should be possible to jump to any of the functions directly by using the function header information (function_x_header).

function_x_header could look like the following:

typedef uint32_t function_start; //Holds the start address of the function

The aim is to have a very simple loader which takes as input the function to run, e.g. function_2 and then parses the object file to locate function_2_header. The loader should then be able to read the value of function_start and use that information to begin to execute function_2.

The question is how to accomplish this with ld and gcc? It would be very convenient if one could do something like the following in the source code:

/*pseudo code*/
function_start function_2 = "offset from start of object file to start of function_2"

The loader could then easily use this information to simply jump to the given offset from the start of the object file to begin to execute function_2.

Is it possible to achieve something like this?

Thanks for any help,
Fredric

__________________________________________________
Använder du Yahoo!?
Är du trött på spam?  Yahoo! E-post har det bästa spamskyddet som finns 
http://se.mail.yahoo.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]