This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: .data.rel Section Contains Both Data and Relocatable Symbols
- From: Daniel Jacobowitz <drow at false dot org>
- To: Anthony DeRosa <aderosa at evitechnology dot com>
- Cc: binutils at sourceware dot org
- Date: Wed, 28 Mar 2007 10:33:01 -0400
- Subject: Re: .data.rel Section Contains Both Data and Relocatable Symbols
- References: <s60a3e2f.088@opal.evitechnology.com>
On Wed, Mar 28, 2007 at 10:06:13AM -0400, Anthony DeRosa wrote:
> I am writing position independent code for a MIPS embedded system. When
> our embedded bootloader loads our code, it fixes up the .data.rel
> section by adding the base address of the code to every 4-byte word in
> that section. In other words, it treats everything in that section as a
> symbol that needs to be relocated. However, this means that only
> relocatable symbols can exist in that .data.rel section. But what
> happens when we have a global structure that contains both plain data
> and relocatable symbols? The entire structure will be put in the
> .data.rel section, and the data part of the structure will incorrectly
> be modified by the bootloader, which thinks the data is a relocatable
> symbol. How do we know what part of the .data.rel section needs to be
> relocated and which part is data? Is this an issue with GCC? Is there
> another way to do this?
If you ignore the relocation entries, you get what you deserve :-)
You need to process the ELF relocation sections. See readelf -r for
more information, or the ELF generic ABI (gABI).
--
Daniel Jacobowitz
CodeSourcery