This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC 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]

Getting information on symbols and linkages at run-time


Hello,
	I am interested in methods of obtaining, at run-time, information
on the symbols in a program and the linkage that gcc used for functions
in the program.  In my case the program is the Linux kernel.

People who are curious as to why I want this information can find out why
at http://www.schemix.org/

At the moment I am relying on the kallsyms patch to lookup a given named
symbol at run-time.  The patch gives me the address that the symbol refers
to, and the size in bytes of the memory reserved for it.  It would be nice
if I could get information on the type of each symbol but that is beyond
the scope of the kallsyms patch.

A more pressing problem for me is calling arbitrary kernel functions.  I
plan to do this with some assembler glue that loops through a list of
user-supplied arguments and, depending on the linkage of the C function
being called, either pushes the arguments onto the stack or loads them
into registers.  Unfortunately the required information on linkage is not
available at run-time and I can't see any patches to Linux that record the
information.  Could sombody suggest a way of getting this information?
Perhaps if I compile the kernel with the '-g' debug switch the information
will be stored somewhere?  If so how do I find and decode that
information?

I'm not sure that paragraph was very clear.  My problem is:
1) The user names a function, e.g. "printk", and a list of args,
   e.g. "hello".
2) The address of the function can be obtained by looking its name up
   using the kallsyms patch to Linux.
3) I loop through the supplied argument list and do what?  Push each arg?
   Load it into a register?
4) I call the function.

The reason I'm not simply writing wrappers for each function is that
1) they would take up a lot of space
2) loadable kernel modules
3) they would add a lot of extra overhead to the job of maintaining
   Schemix

Any ideas would be very welcome.

Thanks for your help.
Best wishes,
		Bill.
-- 
Dr. William Bland.                          Computer Programmer, UK.
www.abstractnonsense.com


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