exporting linker script symbols in statically linked binaries
Nick Clifton
nickc@redhat.com
Tue Apr 10 21:22:00 GMT 2007
Hi Prasad,
> Is there any way of exporting linker script symbols such that they can
> be accessed without knowing them apriori ?
I am not really clear as to why your code cannot know the names of
symbols at compile time, but the short answer to your question is "no".
There are tricks that you can try. You could put a magic number into
the data section (eg 0x12345678) followed by linker directives to store
the names of the symbols, and then have your code scan through the data
section looking for this magic number and the names that follow it.
You could get the name of the executable via the argv[0] element and
scan the file system for the corresponding file and then parse that.
You could do what David has suggested and write a script to parse the
output of the linker's -Map option and dump the symbol names/addresses
into a file which is then read by your program.
Cheers
Nick
More information about the Binutils
mailing list