This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: PATCH: Fix alpha relocation overflow (Re: PATCH: Add _bfd_elf_provide_symbol)
On Mon, Apr 25, 2005 at 10:27:36AM -0700, H. J. Lu wrote:
> 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?
>
>
Wrong patch. This is the updated one.
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:41:25.000000000 -0700
@@ -1463,8 +1463,21 @@ 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;
+ if ((s->flags & SEC_CODE) == 0)
+ break;
+ }
+ }
+ end_val = start_val;
}
_bfd_elf_provide_symbol (&link_info, start, start_val);
_bfd_elf_provide_symbol (&link_info, end, end_val);