PATCH: Reserve memory for ia64 ld.so (Bug in IA64 runtime linker)

H. J. Lu hjl@lucon.org
Sat Apr 3 19:29:00 GMT 2004


On Fri, Apr 02, 2004 at 08:14:41AM -0800, H. J. Lu wrote:
> On Thu, Apr 01, 2004 at 11:12:12PM +0200, Jakub Jelinek wrote:
> > On Thu, Apr 01, 2004 at 02:59:01PM -0800, H. J. Lu wrote:
> > > On Thu, Apr 01, 2004 at 05:36:48PM -0500, Ed Connell wrote:
> > > > I have a small test case that I believe illustrates a bug in the
> > > > IA64 runtime linker.  If my shared library is loaded with RTLD_LAZY,
> > > > things don't resolve correctly.  The following can be observed on
> > > > RHEL 3 for Itanium.
> > > > 
> > > >  $ as my_lib.s -o my_lib.o
> > > >  $ ld my_lib.o -o my_lib.so -shared
> > > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > > 
> > > Never, ever do that. You should use a compiler driver to create a
> > > shared library. With gcc, it is
> > 
> > Well, that's certainly true.
> > Still, there seems to be a bug, either just in ld, or in both ld and glibc.
> > This library when created in the improper way is special in that it has
> > no PLT relocations.
> > The problem is, that ld in this case creates 8 byte long .got (or with say:
> > static long q;
> > static long *p = &q;
> > and linking with gcc -shared -O2 -fpic -nostdlib only 0 byte long .got),
> > yet there is still IA_64_PLT_RESERVE dynamic tag covering first 24 bytes
> > of .got.
> > And ld.so unconditionally assumes that there is IA_64_PLT_RESERVE tag
> > when lazy.
> > So the option is either to change ld, so that it always reserves first
> > 24 bytes of .got, not just when there are PLT relocs, or to omit
> > IA_64_PLT_RESERVE dynamic tag in that case and change the dynamic linker
> > to cope with the missing tag.
> > Given how unusual shared libs without PLT relocs are and in the sake
> > of compatibility, probably just reserving 3 .got words is better.
> > 
> 
> I will give it a try next week.
> 

Here is a patch.

H.J.
-------------- next part --------------
2004-04-03  H.J. Lu  <hongjiu.lu@intel.com>

	* elfxx-ia64.c (elfNN_ia64_size_dynamic_sections): Always
	reserve the memory for dynamic linker

--- bfd/elfxx-ia64.c.plt	2004-04-02 07:48:50.000000000 -0800
+++ bfd/elfxx-ia64.c	2004-04-03 11:25:45.000000000 -0800
@@ -2959,8 +2959,12 @@ elfNN_ia64_size_dynamic_sections (output
   data.ofs = (data.ofs + 31) & (bfd_vma) -32;
 
   elfNN_ia64_dyn_sym_traverse (ia64_info, allocate_plt2_entries, &data);
-  if (data.ofs != 0)
+  if (data.ofs != 0 || ia64_info->root.dynamic_sections_created)
     {
+      /* FIXME: we always reserve the memory for dynamic linker even if
+	 there are no PLT entries since dynamic linker may assume the
+	 reserved memory always exists.  */
+
       BFD_ASSERT (ia64_info->root.dynamic_sections_created);
 
       ia64_info->plt_sec->_raw_size = data.ofs;


More information about the Binutils mailing list