This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
exporting linker script symbols in statically linked binaries
- From: "Prasad Boddupalli" <p dot boddupalli at gmail dot com>
- To: binutils <binutils at sources dot redhat dot com>
- Date: Tue, 3 Apr 2007 16:11:35 -0700
- Subject: exporting linker script symbols in statically linked binaries
Hello,
In statically linked binaries, certain parts of the data segment are
identified through symbolic names. For example, if the user requires
data pertaining to FAT file system, the linker script looks as
follows:
.rodata : {
...
. = ALIGN(8);
__start_fatfs = ABSOLUTE(.);
*(.fatfs.data);
__end_fatfs = ABSOLUTE(.);
...
}
The program accesses the start of fatfs data by referring to the
address of the symbol '_start_fatfs'. I cannot just declare
'extern char __start_fatfs[]'
in the executable as there could be different data, marked by
different symbols, all of which are not known to the program.
I could not create another section (starting at an agreed-upon name)
that contains <symbol name, address of required data> pairs as the
data to be packed (in the above read only section) exits as sections
in different files. For example, there exists one file 'fatfs.dat'
that contains just the above section '.fatfs.data'.
To date, the binaries were dynamically linked and the program could
access the values of linker script symbols by reading the dynamic
symbol table (that starts at _DYNAMIC symbol). However, the binaries
are now statically linked and .dynsym is not generated.
The binaries are not loaded by another program and hence the
alternative of reading the symbol table from the binary file and
exporting those linker script symbol values is ruled out.
Is there any way of exporting linker script symbols such that they can
be accessed without knowing them apriori ?
regards,
Prasad.