public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix ppc32 ld.so
@ 2003-05-15 15:18 Jakub Jelinek
  2003-05-16  4:43 ` Ulrich Drepper
  2003-05-16 13:14 ` Franz Sirl
  0 siblings, 2 replies; 3+ messages in thread
From: Jakub Jelinek @ 2003-05-15 15:18 UTC (permalink / raw)
  To: Ulrich Drepper, Roland McGrath, Jack Howarth, Franz Sirl; +Cc: Glibc hackers

Hi!

This is something I cannot understand how it ever worked.
If there is a reloc overflow on ppc32, _dl_reloc_overflow tries to print the
name of the symbol. But unless sym is NULL (and thus errsym = refsym) resp.
equal to refsym, it will print something from the refsym's strtab at index
sym->st_name, ie. a random string at best, worst case segfault.
To print sym's name instead of refsym's (though I don't understand why that
is needed, both sym and refsym ought to always have the same symbol name,
otherwise symbol lookup is broken) we'd have to pass down sym_map as well,
but sym_map is not always computed (ATM only if --with-tls).

2003-05-15  Jakub Jelinek  <jakub@redhat.com>

	* sysdeps/powerpc/powerpc32/dl-machine.c (_dl_reloc_overflow):
	Remove sym argument, always use refsym.
	(__process_machine_rela): Adjust callers.
	* sysdeps/powerpc/powerpc32/dl-machine.h (_dl_reloc_overflow):
	Adjust prototype.

--- libc/sysdeps/powerpc/powerpc32/dl-machine.c.jj	2003-04-24 13:56:31.000000000 -0400
+++ libc/sysdeps/powerpc/powerpc32/dl-machine.c	2003-05-15 10:57:20.000000000 -0400
@@ -372,22 +372,20 @@ void
 _dl_reloc_overflow (struct link_map *map,
 		    const char *name,
 		    Elf32_Addr *const reloc_addr,
-		    const Elf32_Sym *sym,
 		    const Elf32_Sym *refsym)
 {
   char buffer[128];
   char *t;
-  const Elf32_Sym *errsym = sym ?: refsym;
   t = stpcpy (buffer, name);
   t = stpcpy (t, " relocation at 0x00000000");
   _itoa_word ((unsigned) reloc_addr, t, 16, 0);
-  if (errsym)
+  if (refsym)
     {
       const char *strtab;
 
       strtab = (const void *) D_PTR (map, l_info[DT_STRTAB]);
       t = stpcpy (t, " for symbol `");
-      t = stpcpy (t, strtab + errsym->st_name);
+      t = stpcpy (t, strtab + refsym->st_name);
       t = stpcpy (t, "'");
     }
   t = stpcpy (t, " out of range");
@@ -424,19 +422,19 @@ __process_machine_rela (struct link_map 
 
     case R_PPC_ADDR24:
       if (__builtin_expect (finaladdr > 0x01fffffc && finaladdr < 0xfe000000, 0))
-	_dl_reloc_overflow (map,  "R_PPC_ADDR24", reloc_addr, sym, refsym);
+	_dl_reloc_overflow (map,  "R_PPC_ADDR24", reloc_addr, refsym);
       *reloc_addr = (*reloc_addr & 0xfc000003) | (finaladdr & 0x3fffffc);
       break;
 
     case R_PPC_ADDR16:
       if (__builtin_expect (finaladdr > 0x7fff && finaladdr < 0xffff8000, 0))
-	_dl_reloc_overflow (map,  "R_PPC_ADDR16", reloc_addr, sym, refsym);
+	_dl_reloc_overflow (map,  "R_PPC_ADDR16", reloc_addr, refsym);
       *(Elf32_Half*) reloc_addr = finaladdr;
       break;
 
     case R_PPC_UADDR16:
       if (__builtin_expect (finaladdr > 0x7fff && finaladdr < 0xffff8000, 0))
-	_dl_reloc_overflow (map,  "R_PPC_UADDR16", reloc_addr, sym, refsym);
+	_dl_reloc_overflow (map,  "R_PPC_UADDR16", reloc_addr, refsym);
       ((char *) reloc_addr)[0] = finaladdr >> 8;
       ((char *) reloc_addr)[1] = finaladdr;
       break;
@@ -457,7 +455,7 @@ __process_machine_rela (struct link_map 
     case R_PPC_ADDR14_BRTAKEN:
     case R_PPC_ADDR14_BRNTAKEN:
       if (__builtin_expect (finaladdr > 0x7fff && finaladdr < 0xffff8000, 0))
-	_dl_reloc_overflow (map,  "R_PPC_ADDR14", reloc_addr, sym, refsym);
+	_dl_reloc_overflow (map,  "R_PPC_ADDR14", reloc_addr, refsym);
       *reloc_addr = (*reloc_addr & 0xffff0003) | (finaladdr & 0xfffc);
       if (rinfo != R_PPC_ADDR14)
 	*reloc_addr = ((*reloc_addr & 0xffdfffff)
@@ -469,7 +467,7 @@ __process_machine_rela (struct link_map 
       {
 	Elf32_Sword delta = finaladdr - (Elf32_Word) reloc_addr;
 	if (delta << 6 >> 6 != delta)
-	  _dl_reloc_overflow (map,  "R_PPC_REL24", reloc_addr, sym, refsym);
+	  _dl_reloc_overflow (map,  "R_PPC_REL24", reloc_addr, refsym);
 	*reloc_addr = (*reloc_addr & 0xfc000003) | (delta & 0x3fffffc);
       }
       break;
@@ -568,7 +566,7 @@ __process_machine_rela (struct link_map 
     inline void do_reloc16 (const char *r_name, Elf32_Addr value)
       {
 	if (__builtin_expect (value > 0x7fff && value < 0xffff8000, 0))
-	  _dl_reloc_overflow (map, r_name, reloc_addr, sym, refsym);
+	  _dl_reloc_overflow (map, r_name, reloc_addr, refsym);
 	*(Elf32_Half *) reloc_addr = value;
       }
     inline void do_reloc16_LO (const char *r_name, Elf32_Addr value)
--- libc/sysdeps/powerpc/powerpc32/dl-machine.h.jj	2003-04-24 13:56:31.000000000 -0400
+++ libc/sysdeps/powerpc/powerpc32/dl-machine.h	2003-05-15 10:57:58.000000000 -0400
@@ -347,7 +347,6 @@ extern void __process_machine_rela (stru
 extern void _dl_reloc_overflow (struct link_map *map,
 				const char *name,
 				Elf32_Addr *const reloc_addr,
-				const Elf32_Sym *sym,
 				const Elf32_Sym *refsym) attribute_hidden;
 
 /* Perform the relocation specified by RELOC and SYM (which is fully resolved).

	Jakub

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix ppc32 ld.so
  2003-05-15 15:18 [PATCH] Fix ppc32 ld.so Jakub Jelinek
@ 2003-05-16  4:43 ` Ulrich Drepper
  2003-05-16 13:14 ` Franz Sirl
  1 sibling, 0 replies; 3+ messages in thread
From: Ulrich Drepper @ 2003-05-16  4:43 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Roland McGrath, Jack Howarth, Franz Sirl, Glibc hackers

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Jakub Jelinek wrote:

> 2003-05-15  Jakub Jelinek  <jakub@redhat.com>
> 
> 	* sysdeps/powerpc/powerpc32/dl-machine.c (_dl_reloc_overflow):
> 	Remove sym argument, always use refsym.
> 	(__process_machine_rela): Adjust callers.
> 	* sysdeps/powerpc/powerpc32/dl-machine.h (_dl_reloc_overflow):
> 	Adjust prototype.

I've checked in the patch and also changed the ppc64 code.

- -- 
- --------------.                        ,-.            444 Castro Street
Ulrich Drepper \    ,-----------------'   \ Mountain View, CA 94041 USA
Red Hat         `--' drepper at redhat.com `---------------------------
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE+xGds2ijCOnn/RHQRAt/zAKCX2u/f+ZE9nF8lwvaM7h0XZ7Yj2ACgj1cb
RF+pNumB0tQeWFu0vFSKX/s=
=D6va
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix ppc32 ld.so
  2003-05-15 15:18 [PATCH] Fix ppc32 ld.so Jakub Jelinek
  2003-05-16  4:43 ` Ulrich Drepper
@ 2003-05-16 13:14 ` Franz Sirl
  1 sibling, 0 replies; 3+ messages in thread
From: Franz Sirl @ 2003-05-16 13:14 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Ulrich Drepper, Roland McGrath, Jack Howarth, Glibc hackers

At 17:16 15.05.2003, Jakub Jelinek wrote:
>Hi!
>
>This is something I cannot understand how it ever worked.
>If there is a reloc overflow on ppc32, _dl_reloc_overflow tries to print the
>name of the symbol. But unless sym is NULL (and thus errsym = refsym) resp.
>equal to refsym, it will print something from the refsym's strtab at index
>sym->st_name, ie. a random string at best, worst case segfault.
>To print sym's name instead of refsym's (though I don't understand why that
>is needed, both sym and refsym ought to always have the same symbol name,
>otherwise symbol lookup is broken) we'd have to pass down sym_map as well,
>but sym_map is not always computed (ATM only if --with-tls).

Hmm, IIRC that was a mere result of try and error. I think I used the first 
version that produced sensible results with the (small) binutils testcases. 
Certainly you have more insight in that relocation code and I believe you 
if you say that it just worked by luck :-).

Franz.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-05-16 13:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-15 15:18 [PATCH] Fix ppc32 ld.so Jakub Jelinek
2003-05-16  4:43 ` Ulrich Drepper
2003-05-16 13:14 ` Franz Sirl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).