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]

Re: exporting linker script symbols in statically linked binaries


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


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