This is the mail archive of the
mailing list for the binutils project.
Re: Special MIPS relocation - How to?
----- Original Message -----
From: "Alan Modra" <email@example.com>
To: "Francisco Rodriguez" <firstname.lastname@example.org>
Sent: Thursday, July 04, 2002 9:15 AM
Subject: Re: Special MIPS relocation - How to?
> On Wed, Jul 03, 2002 at 09:20:21PM +0200, Francisco Rodriguez wrote:
> > My problem now is, that these relocs should be resolved at link time,
> > but only when all other relocs have been processed. This is because
> > these relocs are based on the final ".text" section contents, not on
> > symbol addresses.
> > And I simply don't know how to do it.
> > I've only reached to tweak the bfd library so ld silently ignore my
> > (in bfd_mips_elf_relocate_section).
> > Could anyone offer a hint about how to do it?
> A general solution might be:
> o Create a fake input bfd. (Example of fake input bfds can be found
> in ppc64elf.em and hppaelf.em.) Further, give the fake bfd an
> input section (zero size ok) with a reloc.
> o In ldemul_after_open, reorder the input bfd list so that the fake
> is last.
> o In bfd_mips_elf_relocate_section, when processing normal input
> bfds, save information about your new relocs somewhere. When
> processing the fake bfd, read the output .text section back from
> disk, and use it and the saved info to produce whatever you
> This will be quite a lot of work.
> You might be able to do something simpler, but you haven't told us
> much about your new relocs.
> Alan Modra
> IBM OzLabs - Linux Technology Centre
Thanks for your solution.
I'm in the process of implementing it, but stopped with a different problem
After all the sections have been relocated,
I use a call to bfd_get_section_contents to get .text section contents,
but the function call returns error. After tracing, the problem seems
to be the file IO: a real fseek and fread are needed because SEC_CONTENTS
flag is not set.
The fseek returns ok, but the fread returns 0 bytes read.
How can this happen? The bfd_get_section_contents call is made
before the output bfd is closed, so it should be ok, shouldn't it?
Any help is again greatly appreciated.
PS: I did not tell you much about the intention of these relocs to avoid
with info which is useless to you (IMHO). I need them as part of my PhD work
(to augment a standard mips processor with a run-time error detection
If any of you want the details, I'll be glad to provide them.