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: .data.rel Section Contains Both Data and Relocatable Symbols


Thank you, Alan and Daniel, for your responses.  I understand now that I
have to:

1) link with the "-q" ld option in order for the relocation records to
exist in the final elf (or look into building a shared library as Alan
suggested)

2) Fixup only those locations in .data.rel that are specified in the
relocation records

The only problem is that I am converting the elf to binary.  How can I
copy the relocation records to the final binary?

Thanks,
Anthony

>>> Alan Modra <amodra@bigpond.net.au> 3/28/2007 10:45 am >>>
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.

Which is wrong, as you have found.

>  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?

By inspecting the relocations at link time.  You'd then need to pass
that information to your loader somehow.  One possibility is to link
your code as a shared library.  Your loader would then need to process
the dynamic relocations.

>  Is this an issue with GCC?

No.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


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