This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc 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]

[PATCH] Handle R_*_COPY (was Re: Prelinking and LD_PRELOAD)


Hi!

On Fri, Nov 15, 2002 at 10:00:34PM +0100, Jakub Jelinek wrote:
> On Fri, Nov 15, 2002 at 08:42:35PM +0000, Stefan Jones wrote:
> > More infomation: ( now split into two problems )
> > 
> > 1) 
> > 
> > The results from 
> > LD_DEBUG=all LD_PRELOAD=/usr/lib/libfakeroot/libfakeroot.so.0.0.1 moc -v
> > can be found at http://cvs.gentoo.org/~cretin/preloaded.log.bz2 (22k)
> > This is the one which results in "unexpected reloc type 0x05"
> > 
> > ldd  moc gives
> > 	libstdc++.so.5 => /usr/lib/gcc-lib/i586-pc-linux-gnu/3.2/libstdc++.so.5
> > (0x412ec000)
> > 	libm.so.6 => /lib/libm.so.6 (0x4120a000)
> > 	libgcc_s.so.1 => /usr/lib/gcc-lib/i586-pc-linux-gnu/3.2/libgcc_s.so.1
> > (0x412e2000)
> > 	libc.so.6 => /lib/libc.so.6 (0x41015000)
> > 	/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x41000000)
> > 
> > cat /etc/ld.so.conf 
> > /usr/local/lib
> > /usr/lib/gcc-lib/i586-pc-linux-gnu/3.2
> > /usr/lib/opengl/xfree/lib
> > /usr/X11R6/lib
> > /usr/qt/3/lib
> > /usr/kde/3.1/lib
> > 
> > I am at a loss with this error.
> 
> Can I have the moc binary too?
> I will post a patch soon, but would like to see the binary first.

Should be fixed by following patch.
If .rel.dyn of a binary needs to be converted into .rela.dyn because there
are R_386_PC32 relocs or R_386_32 relocs with non-zero addend and there are
R_386_COPY relocs, if prelinking cannot be used, then elf_machine_rela
really has to handle COPY relocs. They are not needed for dl-conflict.c
though.

2002-11-15  Jakub Jelinek  <jakub@redhat.com>

	* sysdeps/i386/dl-machine.h (elf_machine_rela): Handle R_386_COPY.
	* sysdeps/arm/dl-machine.h (elf_machine_rela): Likewise.

--- libc/sysdeps/arm/dl-machine.h.jj	2002-09-30 11:23:46.000000000 +0200
+++ libc/sysdeps/arm/dl-machine.h	2002-11-15 23:50:01.000000000 +0100
@@ -560,6 +560,28 @@ elf_machine_rela (struct link_map *map, 
 
       switch (r_type)
 	{
+#  ifndef RESOLVE_CONFLICT_FIND_MAP
+	  /* Not needed for dl-conflict.c.  */
+	case R_ARM_COPY:
+	  if (sym == NULL)
+	    /* This can happen in trace mode if an object could not be
+	       found.  */
+	    break;
+	  if (sym->st_size > refsym->st_size
+	      || (GL(dl_verbose) && sym->st_size < refsym->st_size))
+	    {
+	      const char *strtab;
+
+	      strtab = (const void *) D_PTR (map, l_info[DT_STRTAB]);
+	      _dl_error_printf ("\
+%s: Symbol `%s' has different size in shared object, consider re-linking\n",
+				rtld_progname ?: "<program name unknown>",
+				strtab + refsym->st_name);
+	    }
+	  memcpy (reloc_addr, (void *) value, MIN (sym->st_size,
+						   refsym->st_size));
+	  break;
+#  endif /* !RESOLVE_CONFLICT_FIND_MAP */
 	case R_ARM_GLOB_DAT:
 	case R_ARM_JUMP_SLOT:
 	case R_ARM_ABS32:
--- libc/sysdeps/i386/dl-machine.h.jj	2002-10-21 19:14:53.000000000 +0200
+++ libc/sysdeps/i386/dl-machine.h	2002-11-15 23:49:14.000000000 +0100
@@ -568,6 +568,29 @@ elf_machine_rela (struct link_map *map, 
 	  CHECK_STATIC_TLS (map, sym_map);
 	  break;
 # endif	/* use TLS */
+# ifndef RESOLVE_CONFLICT_FIND_MAP
+	  /* Not needed for dl-conflict.c.  */
+	case R_386_COPY:
+	  if (sym == NULL)
+	    /* This can happen in trace mode if an object could not be
+	       found.  */
+	    break;
+	  if (__builtin_expect (sym->st_size > refsym->st_size, 0)
+	      || (__builtin_expect (sym->st_size < refsym->st_size, 0)
+		  && GL(dl_verbose)))
+	    {
+	      const char *strtab;
+
+	      strtab = (const char *) D_PTR (map, l_info[DT_STRTAB]);
+	      _dl_error_printf ("\
+%s: Symbol `%s' has different size in shared object, consider re-linking\n",
+				rtld_progname ?: "<program name unknown>",
+				strtab + refsym->st_name);
+	    }
+	  memcpy (reloc_addr, (void *) value, MIN (sym->st_size,
+						   refsym->st_size));
+	  break;
+# endif /* !RESOLVE_CONFLICT_FIND_MAP */
 	default:
 	  /* We add these checks in the version to relocate ld.so only
 	     if we are still debugging.  */

	Jakub


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