This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
PATCH: Fix alpha relocation overflow (Re: PATCH: Add _bfd_elf_provide_symbol)
- From: "H. J. Lu" <hjl at lucon dot org>
- To: Michael Matz <matz at suse dot de>
- Cc: binutils at sources dot redhat dot com
- Date: Mon, 25 Apr 2005 10:27:36 -0700
- Subject: PATCH: Fix alpha relocation overflow (Re: PATCH: Add _bfd_elf_provide_symbol)
- References: <20050322050314.GE27445@bubble.modra.org> <20050322170758.GA1330@lucon.org> <20050322204903.GA4693@lucon.org> <20050322224422.GA6367@lucon.org> <20050323020457.GM30711@bubble.modra.org> <20050323021109.GA19226@nevyn.them.org> <20050323041924.GA11208@lucon.org> <Pine.LNX.4.58.0504250625140.20714@wotan.suse.de> <20050425145458.GA32362@lucon.org> <Pine.LNX.4.58.0504251703020.20714@wotan.suse.de>
On Mon, Apr 25, 2005 at 05:17:24PM +0200, Michael Matz wrote:
> > Do you have a simple testcase for alpha which I can run on Linux/i386?
>
> I've packed together the elf-init.oS file from the system, a small c file
> providing some symbols needed from that .oS, and this file precompiled for
> alpha. So you should be able to reproduce the problem with:
>
> % ld elf-init.oS a.o
>
> with a cross linker. This will of course not create a functioning
> executable, but will demonstrate the linking error. With my patch this
> works. Hope this helps.
>
How about this patch?
H.J.
----
2005-04-25 H.J. Lu <hongjiu.lu@intel.com>
* emultempl/elf32.em (gld${EMULATION_NAME}_provide_bound_symbols):
Use the first SEC_ALLOC section which isn't SEC_CODE or the
last SEC_CODE section if the section doesn't exist.
--- ld/emultempl/elf32.em.alpha 2005-04-25 09:24:59.000000000 -0700
+++ ld/emultempl/elf32.em 2005-04-25 10:19:53.000000000 -0700
@@ -1463,8 +1463,22 @@ gld${EMULATION_NAME}_provide_bound_symbo
}
else
{
+ /* We have to choose those values very carefully. Some targets,
+ like alpha, may have relocation overflow with 0. We use the
+ first SEC_ALLOC section which isn't SEC_CODE or the last
+ SEC_CODE section. */
start_val = 0;
end_val = 0;
+ for (s = output_bfd->sections; s != NULL; s = s->next)
+ {
+ if ((s->flags & SEC_ALLOC) != 0)
+ {
+ start_val = s->vma;
+ end_val = start_val + s->size;
+ if ((s->flags & SEC_CODE) == 0)
+ break;
+ }
+ }
}
_bfd_elf_provide_symbol (&link_info, start, start_val);
_bfd_elf_provide_symbol (&link_info, end, end_val);