This is the mail archive of the binutils@sources.redhat.com 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: PATCH: Add _bfd_elf_provide_symbol


Hi HJ,

On Tue, 22 Mar 2005, H. J. Lu wrote:

> On Tue, Mar 22, 2005 at 09:11:09PM -0500, Daniel Jacobowitz wrote:
> > On Wed, Mar 23, 2005 at 12:34:57PM +1030, Alan Modra wrote:
> > > On Tue, Mar 22, 2005 at 02:44:22PM -0800, H. J. Lu wrote:
> > > > Here is an upated patch. _bfd_elf_provide_symbol should presever
> > > > st_other. Also it needs to set forced_local to 1. Otherwise, we will
> > > > get global hidden symbols. We don't need those array symbols for
> > > > shared libraries.
> > > 
> > > Looks good.  OK for mainline, and the branch too unless Daniel
> > > disagrees.
> > 
> > That's fine.
> 
> since it can be used to provide section start/end symbols.
> 
> It won't apply to 2.16 since it depends on some other changes in
> mainline.

This patch introduces a regression for linking code with older glibcs on 
alpha, due to this error message:

/usr/lib/libc_nonshared.a(elf-init.oS): In function `__libc_csu_fini':
/usr/src/packages/BUILD/glibc-2.3/csu/elf-init.c:76: relocation truncated 
to fit: GPRELHIGH against symbol `__fini_array_start' defined in *ABS* 
section in <none>

The elf-init.oS has a GPRELHIGH reloc against the __fini_array_start
symbol.  This reloc is complain_overflow_signed.  As it is GP relative the
content of current GP is subtracted from the value of that symbol.  Your
patch defines the value of that symbol to be zero if the section is not
there.  Before your patch the ldscript defined it to be something after
.tbss independent if the .fini_array section was there or not.

So if this section is not there the final value of the relocation with
your patch will be "0 - gp".  This all is mappeg beyond the 32 bit border,
so bit 32 is set.  Hence the negative amount of that doesn't fit into 32
bit, resulting in the above error message.  Before your patch the symbols
value was in reach of 32 bit signed offsets of GP.

I'm not 100% sure what the best alternative would be.  I think simplest 
would be to define it to the start of .got, like in the below patch.  It 
works for me on alpha, but I don't know if that's a sane approach, or if 
.got is available everywhere (I guess with static executables it's not).


Ciao,
Michael.
-- 
--- ld/emultempl/elf32.em.mm	2005-04-25 04:49:34.000000000 +0000
+++ ld/emultempl/elf32.em	2005-04-25 04:50:46.000000000 +0000
@@ -1541,8 +1541,9 @@ gld${EMULATION_NAME}_provide_bound_symbo
     }
   else
     {
-      start_val = 0;
-      end_val = 0;
+      s = bfd_get_section_by_name (output_bfd, ".got");
+      start_val = s ? s->vma : 0;
+      end_val = start_val;
     }
   _bfd_elf_provide_symbol (&link_info, start, start_val);
   _bfd_elf_provide_symbol (&link_info, end, end_val);


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