summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1999-07-21 16:58:06 +0000
committerRoland McGrath <roland@gnu.org>1999-07-21 16:58:06 +0000
commit421c80d27e2dda29efd8e53dd18090b22546867c (patch)
tree978d5ff557f7e1178ee7e21591460cfe12a9e337
parente26996aa991c92637310c12f37e266ad3931b289 (diff)
1999-07-21 Roland McGrath <roland@baalperazim.frob.com>
* elf/dl-reloc.c (_dl_reloc_bad_type): New function. * elf/ldsodefs.h: Declare it. * sysdeps/sparc/sparc64/dl-machine.h (elf_machine_rela): Use it instead of assert. (elf_machine_lazy_rel): Likewise. Take new arg MAP. * sysdeps/sparc/sparc32/dl-machine.h (elf_machine_rela): Likewise. (elf_machine_lazy_rel): Likewise. * sysdeps/mips/dl-machine.h (elf_machine_rel): Likewise. (elf_machine_lazy_rel): Likewise. * sysdeps/mips/mips64/dl-machine.h (elf_machine_rel): Likewise. (elf_machine_lazy_rel): Likewise. * sysdeps/m68k/dl-machine.h (elf_machine_rela): Likewise. (elf_machine_lazy_rel): Likewise. * sysdeps/i386/dl-machine.h (elf_machine_rel): Likewise. (elf_machine_lazy_rel): Likewise. * sysdeps/generic/dl-machine.h (elf_machine_rel): Likewise. * sysdeps/arm/dl-machine.h (elf_machine_rel): Likewise. (elf_machine_lazy_rel): Likewise. * sysdeps/alpha/dl-machine.h (elf_machine_rela): Likewise. (elf_machine_lazy_rel): Likewise. * sysdeps/powerpc/dl-machine.h (elf_machine_lazy_rel): Likewise. * sysdeps/powerpc/dl-machine.c (__process_machine_rela): Use _dl_reloc_bad_type instead of _dl_signal_error. * elf/do-rel.h (elf_dynamic_do_rel): Pass MAP to elf_machine_lazy_rel.
-rw-r--r--ChangeLog27
-rw-r--r--elf/dl-reloc.c24
-rw-r--r--elf/do-rel.h2
-rw-r--r--elf/ldsodefs.h7
-rw-r--r--sysdeps/alpha/dl-machine.h8
-rw-r--r--sysdeps/arm/dl-machine.h13
-rw-r--r--sysdeps/generic/dl-machine.h5
-rw-r--r--sysdeps/i386/dl-machine.h13
-rw-r--r--sysdeps/m68k/dl-machine.h13
-rw-r--r--sysdeps/mips/dl-machine.h6
-rw-r--r--sysdeps/mips/mips64/dl-machine.h6
-rw-r--r--sysdeps/powerpc/dl-machine.c3
-rw-r--r--sysdeps/powerpc/dl-machine.h5
-rw-r--r--sysdeps/sparc/sparc32/dl-machine.h8
-rw-r--r--sysdeps/sparc/sparc64/dl-machine.h8
15 files changed, 104 insertions, 44 deletions
diff --git a/ChangeLog b/ChangeLog
index bc01740f44..846ed84863 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,30 @@
+1999-07-21 Roland McGrath <roland@baalperazim.frob.com>
+
+ * elf/dl-reloc.c (_dl_reloc_bad_type): New function.
+ * elf/ldsodefs.h: Declare it.
+ * sysdeps/sparc/sparc64/dl-machine.h (elf_machine_rela): Use it
+ instead of assert.
+ (elf_machine_lazy_rel): Likewise. Take new arg MAP.
+ * sysdeps/sparc/sparc32/dl-machine.h (elf_machine_rela): Likewise.
+ (elf_machine_lazy_rel): Likewise.
+ * sysdeps/mips/dl-machine.h (elf_machine_rel): Likewise.
+ (elf_machine_lazy_rel): Likewise.
+ * sysdeps/mips/mips64/dl-machine.h (elf_machine_rel): Likewise.
+ (elf_machine_lazy_rel): Likewise.
+ * sysdeps/m68k/dl-machine.h (elf_machine_rela): Likewise.
+ (elf_machine_lazy_rel): Likewise.
+ * sysdeps/i386/dl-machine.h (elf_machine_rel): Likewise.
+ (elf_machine_lazy_rel): Likewise.
+ * sysdeps/generic/dl-machine.h (elf_machine_rel): Likewise.
+ * sysdeps/arm/dl-machine.h (elf_machine_rel): Likewise.
+ (elf_machine_lazy_rel): Likewise.
+ * sysdeps/alpha/dl-machine.h (elf_machine_rela): Likewise.
+ (elf_machine_lazy_rel): Likewise.
+ * sysdeps/powerpc/dl-machine.h (elf_machine_lazy_rel): Likewise.
+ * sysdeps/powerpc/dl-machine.c (__process_machine_rela): Use
+ _dl_reloc_bad_type instead of _dl_signal_error.
+ * elf/do-rel.h (elf_dynamic_do_rel): Pass MAP to elf_machine_lazy_rel.
+
1999-07-20 Mark Kettenis <kettenis@gnu.org>
* sysdeps/mach/_strerror.c: Include <libintl.h>.
diff --git a/elf/dl-reloc.c b/elf/dl-reloc.c
index 54a2acc065..0bf39a8b5e 100644
--- a/elf/dl-reloc.c
+++ b/elf/dl-reloc.c
@@ -129,3 +129,27 @@ _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[],
}
}
}
+
+#include "../stdio-common/_itoa.h"
+#define DIGIT(b) _itoa_lower_digits[(b) & 0xf];
+
+void
+internal_function
+_dl_reloc_bad_type (struct link_map *map, uint_fast8_t type, int plt)
+{
+ extern const char _itoa_lower_digits[];
+ if (plt)
+ {
+ char msg[] = "unexpected reloc type 0x??";
+ msg[sizeof msg - 2] = DIGIT(type >> 8);
+ msg[sizeof msg - 1] = DIGIT(type);
+ _dl_signal_error (0, map->l_name, msg);
+ }
+ else
+ {
+ char msg[] = "unexpected PLT reloc type 0x??";
+ msg[sizeof msg - 2] = DIGIT(type >> 8);
+ msg[sizeof msg - 1] = DIGIT(type);
+ _dl_signal_error (0, map->l_name, msg);
+ }
+}
diff --git a/elf/do-rel.h b/elf/do-rel.h
index 803d250bba..955acfef77 100644
--- a/elf/do-rel.h
+++ b/elf/do-rel.h
@@ -48,7 +48,7 @@ elf_dynamic_do_rel (struct link_map *map,
/* Doing lazy PLT relocations; they need very little info. */
ElfW(Addr) l_addr = map->l_addr;
for (; r < end; ++r)
- elf_machine_lazy_rel (l_addr, r);
+ elf_machine_lazy_rel (map, l_addr, r);
}
else
{
diff --git a/elf/ldsodefs.h b/elf/ldsodefs.h
index 844e479283..483e85b085 100644
--- a/elf/ldsodefs.h
+++ b/elf/ldsodefs.h
@@ -326,6 +326,13 @@ extern void _dl_relocate_object (struct link_map *map,
struct r_scope_elem *scope[],
int lazy, int consider_profiling);
+/* Call _dl_signal_error with a message about an unhandled reloc type.
+ TYPE is the result of ELFW(R_TYPE) (r_info), i.e. an R_<CPU>_* value.
+ PLT is nonzero if this was a PLT reloc; it just affects the message. */
+extern void _dl_reloc_bad_type (struct link_map *map,
+ uint_fast8_t type, int plt)
+ internal_function;
+
/* Check the version dependencies of all objects available through
MAP. If VERBOSE print some more diagnostics. */
extern int _dl_check_all_versions (struct link_map *map, int verbose)
diff --git a/sysdeps/alpha/dl-machine.h b/sysdeps/alpha/dl-machine.h
index 21059f5e4f..78a6f502ed 100644
--- a/sysdeps/alpha/dl-machine.h
+++ b/sysdeps/alpha/dl-machine.h
@@ -26,7 +26,6 @@
#define ELF_MACHINE_NAME "alpha"
-#include <assert.h>
#include <string.h>
@@ -490,12 +489,13 @@ elf_machine_rela (struct link_map *map,
*reloc_addr = sym_value;
}
else
- assert (! "unexpected dynamic reloc type");
+ _dl_reloc_bad_type (map, r_type, 0);
}
}
static inline void
-elf_machine_lazy_rel (Elf64_Addr l_addr, const Elf64_Rela *reloc)
+elf_machine_lazy_rel (struct link_map *map,
+ Elf64_Addr l_addr, const Elf64_Rela *reloc)
{
Elf64_Addr * const reloc_addr = (void *)(l_addr + reloc->r_offset);
unsigned long const r_type = ELF64_R_TYPE (reloc->r_info);
@@ -509,7 +509,7 @@ elf_machine_lazy_rel (Elf64_Addr l_addr, const Elf64_Rela *reloc)
else if (r_type == R_ALPHA_NONE)
return;
else
- assert (! "unexpected PLT reloc type");
+ _dl_reloc_bad_type (map, r_type, 1);
}
#endif /* RESOLVE */
diff --git a/sysdeps/arm/dl-machine.h b/sysdeps/arm/dl-machine.h
index 754a6caa13..d112e3fa9f 100644
--- a/sysdeps/arm/dl-machine.h
+++ b/sysdeps/arm/dl-machine.h
@@ -24,8 +24,6 @@
#include <sys/param.h>
-#include <assert.h>
-
/* Return nonzero iff E_MACHINE is compatible with the running host. */
static inline int __attribute__ ((unused))
elf_machine_matches_host (Elf32_Half e_machine)
@@ -438,19 +436,22 @@ elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc,
break;
}
default:
- assert (! "unexpected dynamic reloc type");
+ _dl_reloc_bad_type (map, ELF32_R_TYPE (reloc->r_info), 0);
break;
}
}
}
static inline void
-elf_machine_lazy_rel (Elf32_Addr l_addr, const Elf32_Rel *reloc)
+elf_machine_lazy_rel (struct link_map *map,
+ Elf32_Addr l_addr, const Elf32_Rel *reloc)
{
Elf32_Addr *const reloc_addr = (void *) (l_addr + reloc->r_offset);
/* Check for unexpected PLT reloc type. */
- assert (ELF32_R_TYPE (reloc->r_info) == R_ARM_JUMP_SLOT);
- *reloc_addr += l_addr;
+ if (ELF32_R_TYPE (reloc->r_info) == R_ARM_JUMP_SLOT)
+ *reloc_addr += l_addr;
+ else
+ _dl_reloc_bad_type (map, ELF32_R_TYPE (reloc->r_info), 1);
}
#endif /* RESOLVE */
diff --git a/sysdeps/generic/dl-machine.h b/sysdeps/generic/dl-machine.h
index f787df3500..da6c74bcaa 100644
--- a/sysdeps/generic/dl-machine.h
+++ b/sysdeps/generic/dl-machine.h
@@ -1,5 +1,5 @@
/* Machine-dependent ELF dynamic relocation inline functions. Stub version.
- Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+ Copyright (C) 1995, 1996, 1997, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -19,7 +19,6 @@
#define ELF_MACHINE_NAME "stub"
-#include <assert.h>
#include <string.h>
#include <link.h>
@@ -81,7 +80,7 @@ elf_machine_rel (Elf32_Addr loadaddr, Elf32_Dyn *info[DT_NUM],
memcpy (reloc_addr, (void *) (loadbase + sym->st_value), sym->st_size);
break;
default:
- assert (! "unexpected dynamic reloc type");
+ _dl_reloc_bad_type (map, ELF32_R_TYPE (reloc->r_info), 0);
break;
}
}
diff --git a/sysdeps/i386/dl-machine.h b/sysdeps/i386/dl-machine.h
index 9007f64704..0377157bd7 100644
--- a/sysdeps/i386/dl-machine.h
+++ b/sysdeps/i386/dl-machine.h
@@ -24,8 +24,6 @@
#include <sys/param.h>
-#include <assert.h>
-
/* Return nonzero iff E_MACHINE is compatible with the running host. */
static inline int __attribute__ ((unused))
elf_machine_matches_host (Elf32_Half e_machine)
@@ -377,19 +375,22 @@ elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc,
*reloc_addr += (value - (Elf32_Addr) reloc_addr);
break;
default:
- assert (! "unexpected dynamic reloc type");
+ _dl_reloc_bad_type (map, ELFW(R_TYPE) (reloc->r_info), 0);
break;
}
}
}
static inline void
-elf_machine_lazy_rel (Elf32_Addr l_addr, const Elf32_Rel *reloc)
+elf_machine_lazy_rel (struct link_map *map,
+ Elf32_Addr l_addr, const Elf32_Rel *reloc)
{
Elf32_Addr *const reloc_addr = (void *) (l_addr + reloc->r_offset);
/* Check for unexpected PLT reloc type. */
- assert (ELF32_R_TYPE (reloc->r_info) == R_386_JMP_SLOT);
- *reloc_addr += l_addr;
+ if (ELF32_R_TYPE (reloc->r_info) == R_386_JMP_SLOT)
+ *reloc_addr += l_addr;
+ else
+ _dl_reloc_bad_type (map, ELFW(R_TYPE) (reloc->r_info), 1);
}
#endif /* RESOLVE */
diff --git a/sysdeps/m68k/dl-machine.h b/sysdeps/m68k/dl-machine.h
index afa68efe1b..f9f9bf7626 100644
--- a/sysdeps/m68k/dl-machine.h
+++ b/sysdeps/m68k/dl-machine.h
@@ -24,8 +24,6 @@
#include <sys/param.h>
-#include <assert.h>
-
/* Return nonzero iff E_MACHINE is compatible with the running host. */
static inline int
elf_machine_matches_host (Elf32_Half e_machine)
@@ -313,18 +311,21 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
case R_68K_NONE: /* Alright, Wilbur. */
break;
default:
- assert (! "unexpected dynamic reloc type");
+ _dl_reloc_bad_type (map, ELF32_R_TYPE (reloc->r_info), 0);
break;
}
}
}
static inline void
-elf_machine_lazy_rel (Elf32_Addr l_addr, const Elf32_Rela *reloc)
+elf_machine_lazy_rel (struct link_map *map,
+ Elf32_Addr l_addr, const Elf32_Rela *reloc)
{
Elf32_Addr *const reloc_addr = (void *) (l_addr + reloc->r_offset);
- assert (ELF32_R_TYPE (reloc->r_info) == R_68K_JMP_SLOT);
- *reloc_addr += l_addr;
+ if (ELF32_R_TYPE (reloc->r_info) == R_68K_JMP_SLOT)
+ *reloc_addr += l_addr;
+ else
+ _dl_reloc_bad_type (map, ELF32_R_TYPE (reloc->r_info), 1);
}
#endif /* RESOLVE */
diff --git a/sysdeps/mips/dl-machine.h b/sysdeps/mips/dl-machine.h
index 6896e53546..5811b78b29 100644
--- a/sysdeps/mips/dl-machine.h
+++ b/sysdeps/mips/dl-machine.h
@@ -25,7 +25,6 @@
#define ELF_MACHINE_NO_PLT
-#include <assert.h>
#include <entry.h>
#ifndef ENTRY_POINT
@@ -567,13 +566,14 @@ elf_machine_rel (struct link_map *map, const ElfW(Rel) *reloc,
case R_MIPS_NONE: /* Alright, Wilbur. */
break;
default:
- assert (! "unexpected dynamic reloc type");
+ _dl_reloc_bad_type (map, ELFW(R_TYPE) (reloc->r_info), 0);
break;
}
}
static inline void
-elf_machine_lazy_rel (ElfW(Addr) l_addr, const ElfW(Rel) *reloc)
+elf_machine_lazy_rel (struct link_map *map,
+ ElfW(Addr) l_addr, const ElfW(Rel) *reloc)
{
/* Do nothing. */
}
diff --git a/sysdeps/mips/mips64/dl-machine.h b/sysdeps/mips/mips64/dl-machine.h
index e2b62b8199..f200fcda64 100644
--- a/sysdeps/mips/mips64/dl-machine.h
+++ b/sysdeps/mips/mips64/dl-machine.h
@@ -25,7 +25,6 @@
#define ELF_MACHINE_NO_PLT
-#include <assert.h>
#include <entry.h>
#ifndef ENTRY_POINT
@@ -562,13 +561,14 @@ elf_machine_rel (struct link_map *map, const ElfW(Rel) *reloc,
case R_MIPS_NONE: /* Alright, Wilbur. */
break;
default:
- assert (! "unexpected dynamic reloc type");
+ _dl_reloc_bad_type (map, ELFW(R_TYPE) (reloc->r_info), 0);
break;
}
}
static inline void
-elf_machine_lazy_rel (struct link_map *map, const ElfW(Rel) *reloc)
+elf_machine_lazy_rel (struct link_map *map, ElfW(Addr) l_addr,
+ const ElfW(Rel) *reloc)
{
/* Do nothing. */
}
diff --git a/sysdeps/powerpc/dl-machine.c b/sysdeps/powerpc/dl-machine.c
index 040f5ebc95..cf918fab03 100644
--- a/sysdeps/powerpc/dl-machine.c
+++ b/sysdeps/powerpc/dl-machine.c
@@ -426,8 +426,7 @@ __process_machine_rela (struct link_map *map,
return;
default:
- _dl_sysdep_error (_dl_argv[0] ?: "<program name unknown>",
- ": Unknown relocation type\n", NULL);
+ _dl_reloc_bad_type (map, rinfo, 0);
return;
}
diff --git a/sysdeps/powerpc/dl-machine.h b/sysdeps/powerpc/dl-machine.h
index 79fa274450..77454b246e 100644
--- a/sysdeps/powerpc/dl-machine.h
+++ b/sysdeps/powerpc/dl-machine.h
@@ -1,5 +1,5 @@
/* Machine-dependent ELF dynamic relocation inline functions. PowerPC version.
- Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+ Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -239,7 +239,8 @@ extern int __elf_machine_runtime_setup (struct link_map *map,
#define elf_machine_runtime_setup __elf_machine_runtime_setup
static inline void
-elf_machine_lazy_rel (Elf32_Addr l_addr, const Elf32_Rela *reloc)
+elf_machine_lazy_rel (struct link_map *map,
+ Elf32_Addr l_addr, const Elf32_Rela *reloc)
{
/* elf_machine_runtime_setup handles this. */
}
diff --git a/sysdeps/sparc/sparc32/dl-machine.h b/sysdeps/sparc/sparc32/dl-machine.h
index 4985afda32..e6debe05ac 100644
--- a/sysdeps/sparc/sparc32/dl-machine.h
+++ b/sysdeps/sparc/sparc32/dl-machine.h
@@ -19,7 +19,6 @@
#define ELF_MACHINE_NAME "sparc"
-#include <assert.h>
#include <string.h>
#include <sys/param.h>
#include <elf/ldsodefs.h>
@@ -430,14 +429,15 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
case R_SPARC_NONE: /* Alright, Wilbur. */
break;
default:
- assert (! "unexpected dynamic reloc type");
+ _dl_reloc_bad_type (map, ELFW(R_TYPE) (reloc->r_info), 0);
break;
}
}
}
static inline void
-elf_machine_lazy_rel (Elf32_Addr l_addr, const Elf32_Rela *reloc)
+elf_machine_lazy_rel (struct link_map *map,
+ Elf32_Addr l_addr, const Elf32_Rela *reloc)
{
switch (ELF32_R_TYPE (reloc->r_info))
{
@@ -446,7 +446,7 @@ elf_machine_lazy_rel (Elf32_Addr l_addr, const Elf32_Rela *reloc)
case R_SPARC_JMP_SLOT:
break;
default:
- assert (! "unexpected PLT reloc type");
+ _dl_reloc_bad_type (map, ELFW(R_TYPE) (reloc->r_info), 1);
break;
}
}
diff --git a/sysdeps/sparc/sparc64/dl-machine.h b/sysdeps/sparc/sparc64/dl-machine.h
index 5a86ec57d8..554321ffe2 100644
--- a/sysdeps/sparc/sparc64/dl-machine.h
+++ b/sysdeps/sparc/sparc64/dl-machine.h
@@ -19,7 +19,6 @@
#define ELF_MACHINE_NAME "sparc64"
-#include <assert.h>
#include <string.h>
#include <sys/param.h>
#include <elf/ldsodefs.h>
@@ -310,14 +309,15 @@ elf_machine_rela (struct link_map *map, const Elf64_Rela *reloc,
break;
default:
- assert (! "unexpected dynamic reloc type");
+ _dl_reloc_bad_type (map, ELFW(R_TYPE) (reloc->r_info), 0);
break;
}
}
}
static inline void
-elf_machine_lazy_rel (Elf64_Addr l_addr, const Elf64_Rela *reloc)
+elf_machine_lazy_rel (struct link_map *map,
+ Elf64_Addr l_addr, const Elf64_Rela *reloc)
{
switch (ELF64_R_TYPE (reloc->r_info))
{
@@ -326,7 +326,7 @@ elf_machine_lazy_rel (Elf64_Addr l_addr, const Elf64_Rela *reloc)
case R_SPARC_JMP_SLOT:
break;
default:
- assert (! "unexpected PLT reloc type");
+ _dl_reloc_bad_type (map, ELFW(R_TYPE) (reloc->r_info), 1);
break;
}
}