This is the mail archive of the
mailing list for the binutils project.
Custom symbol table with linker plugin
- From: "Smets, Jan (Nokia - BE/Antwerp)" <jan dot smets at nokia dot com>
- To: "binutils at sourceware dot org" <binutils at sourceware dot org>
- Date: Thu, 30 Mar 2017 15:59:34 +0000
- Subject: Custom symbol table with linker plugin
- Authentication-results: sourceware.org; auth=none
- Authentication-results: sourceware.org; dkim=none (message not signed) header.d=none;sourceware.org; dmarc=none action=none header.from=nokia.com;
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
I'm attempting to build a custom symbol table which I would like to include in the loadable segments of the executable.
The only documentation I found about linker plugins is the GCC WHOPR @ https://gcc.gnu.org/wiki/whopr/driver
Is there any other documentation available? I've also found some test plugins in the testsuites. (and the gcc lto plugin)
To access the linker's view of the symbol table I first assumed that I only had to subscribe to the "all symbols read" event and that I could access it from there.
I've tried to record the file handles from each input file (claim_file_hook) and tried to use get_symbols(), without success. (I didn't claim the file as I just want the linker to handle it)
My questions are:
a) how can I access the linker's view of the symbol table before it starts resolving relocations and starts building the output file (ie, in the "all symbols read" event) (after GC)
b) The symbol table format I need is an array of structs, holding a pointer to the symbol, a pointer to the name and some bitfields for symbol size/type. (I have litte and big endian targets)
What would be the recommended way to get this data in the output file? (from within the plugin - and have the linker resolve relocations etc)
This is for an embedded system which just loads up text/data.
If there is another way make the standard SYMTAB/STRTAB loadable and place it in the data segment, before bss, that would work too and be a lot easier as well.