From ceb579a3f8b7698868817f4fb0a36742f0494b28 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sat, 21 Oct 2000 00:02:39 +0000 Subject: [PATCH] Update. 2000-10-19 H.J. Lu * elf/Makefile (distribute): Add neededtest.c, neededobj1.c, neededobj2.c and neededobj3.c. (tests): Add neededtest. (modules-names): Add neededobj1, neededobj2 and neededobj3. ($(objpfx)neededobj1.so): New target. ($(objpfx)neededobj2.so): Likewise. ($(objpfx)neededobj3.so): Likewise. ($(objpfx)neededtest): Likewise. ($(objpfx)neededtest.out): Likewise. * elf/neededtest.c: New. Based on the bug report from Allen Bauer . * elf/neededobj1.c: Likewise. * elf/neededobj2.c: Likewise. * elf/neededobj3.c: Likewise. 2000-10-20 Ulrich Drepper * elf/dl-close.c (_dl_close): Decrement reference counter for all dependencies even if the DSO does not get unloaded. * elf/dl-load.c (_dl_map_object_from_fd): Pass pointer to ELF header to elf_machine_matches_host. * sysdeps/alpha/dl-machine.h (elf_machine_matches_host): Parameter is now pointer to ELF header. * sysdeps/arm/dl-machine.h: Likewise. * sysdeps/generic/dl-machine.h: Likewise. * sysdeps/hppa/dl-machine.h: Likewise. * sysdeps/i386/dl-machine.h: Likewise. * sysdeps/ia64/dl-machine.h: Likewise. * sysdeps/m68k/dl-machine.h: Likewise. * sysdeps/mips/dl-machine.h: Likewise. * sysdeps/mips/mips64/dl-machine.h: Likewise. * sysdeps/powerpc/dl-machine.h: Likewise. * sysdeps/s390/dl-machine.h: Likewise. * sysdeps/sh/dl-machine.h: Likewise. * sysdeps/sparc/sparc32/dl-machine.h: Likewise. * sysdeps/sparc/sparc64/dl-machine.h: Likewise. Patch by Martin Schwidefsksy . 2000-10-20 Jakub Jelinek * include/limits.h: Include bits/wordsize.h, use #if __WORDSIZE == 64 check instead of #ifdef __alpha__. * include/bits/xopen_lim.h (WORD_BIT, LONG_BIT): Don't count on INT_MAX, __INT_MAX__, LONG_MAX or __LONG_MAX__ being defined when this is included. * posix/wordexp-tst.sh (testout): Place output file in build directory. Patch by Joseph S. Myers . --- ChangeLog | 52 +++++++++++++++ elf/Makefile | 17 ++++- elf/dl-close.c | 14 ++-- elf/dl-load.c | 2 +- elf/neededobj1.c | 4 ++ elf/neededobj2.c | 7 ++ elf/neededobj3.c | 9 +++ elf/neededtest.c | 104 +++++++++++++++++++++++++++++ include/bits/xopen_lim.h | 51 +++++++++++--- include/limits.h | 6 +- localedata/locales/iso14651_t1 | 6 +- posix/wordexp-tst.sh | 6 +- sysdeps/alpha/dl-machine.h | 6 +- sysdeps/arm/dl-machine.h | 14 ++-- sysdeps/generic/dl-machine.h | 6 +- sysdeps/hppa/dl-machine.h | 10 +-- sysdeps/i386/dl-machine.h | 12 +--- sysdeps/ia64/dl-machine.h | 6 +- sysdeps/m68k/dl-machine.h | 12 +--- sysdeps/mips/dl-machine.h | 6 +- sysdeps/mips/mips64/dl-machine.h | 6 +- sysdeps/powerpc/dl-machine.h | 8 +-- sysdeps/s390/dl-machine.h | 12 +--- sysdeps/sh/dl-machine.h | 12 +--- sysdeps/sparc/sparc32/dl-machine.h | 8 +-- sysdeps/sparc/sparc64/dl-machine.h | 6 +- 26 files changed, 299 insertions(+), 103 deletions(-) create mode 100644 elf/neededobj1.c create mode 100644 elf/neededobj2.c create mode 100644 elf/neededobj3.c create mode 100644 elf/neededtest.c diff --git a/ChangeLog b/ChangeLog index 4065905a7d..4f7f7de249 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,57 @@ +2000-10-19 H.J. Lu + + * elf/Makefile (distribute): Add neededtest.c, neededobj1.c, + neededobj2.c and neededobj3.c. + (tests): Add neededtest. + (modules-names): Add neededobj1, neededobj2 and neededobj3. + ($(objpfx)neededobj1.so): New target. + ($(objpfx)neededobj2.so): Likewise. + ($(objpfx)neededobj3.so): Likewise. + ($(objpfx)neededtest): Likewise. + ($(objpfx)neededtest.out): Likewise. + * elf/neededtest.c: New. Based on the bug report from + Allen Bauer . + * elf/neededobj1.c: Likewise. + * elf/neededobj2.c: Likewise. + * elf/neededobj3.c: Likewise. + 2000-10-20 Ulrich Drepper + * elf/dl-close.c (_dl_close): Decrement reference counter for all + dependencies even if the DSO does not get unloaded. + + * elf/dl-load.c (_dl_map_object_from_fd): Pass pointer to ELF header + to elf_machine_matches_host. + * sysdeps/alpha/dl-machine.h (elf_machine_matches_host): Parameter + is now pointer to ELF header. + * sysdeps/arm/dl-machine.h: Likewise. + * sysdeps/generic/dl-machine.h: Likewise. + * sysdeps/hppa/dl-machine.h: Likewise. + * sysdeps/i386/dl-machine.h: Likewise. + * sysdeps/ia64/dl-machine.h: Likewise. + * sysdeps/m68k/dl-machine.h: Likewise. + * sysdeps/mips/dl-machine.h: Likewise. + * sysdeps/mips/mips64/dl-machine.h: Likewise. + * sysdeps/powerpc/dl-machine.h: Likewise. + * sysdeps/s390/dl-machine.h: Likewise. + * sysdeps/sh/dl-machine.h: Likewise. + * sysdeps/sparc/sparc32/dl-machine.h: Likewise. + * sysdeps/sparc/sparc64/dl-machine.h: Likewise. + Patch by Martin Schwidefsksy . + +2000-10-20 Jakub Jelinek + + * include/limits.h: Include bits/wordsize.h, use #if __WORDSIZE == 64 + check instead of #ifdef __alpha__. + * include/bits/xopen_lim.h (WORD_BIT, LONG_BIT): Don't count on + INT_MAX, __INT_MAX__, LONG_MAX or __LONG_MAX__ being defined when + this is included. + +2000-10-20 Ulrich Drepper + + * posix/wordexp-tst.sh (testout): Place output file in build + directory. Patch by Joseph S. Myers . + * sysdeps/powerpc/fpu/bits/mathinline.h: Pretty print. 2000-10-19 Ulrich Drepper diff --git a/elf/Makefile b/elf/Makefile index 917a745146..d38524d040 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -53,7 +53,8 @@ distribute := $(rtld-routines:=.c) dynamic-link.h do-rel.h dl-machine.h \ nodlopenmod.c nodelete.c nodelmod1.c nodelmod2.c \ nodelmod3.c nodelmod4.c nodlopen.c dl-osinfo.h \ reldepmod1.c reldepmod2.c reldepmod3.c reldepmod4.c \ - nextmod1.c nextmod2.c + nextmod1.c nextmod2.c \ + neededtest.c neededobj1.c neededobj2.c neededobj3.c include ../Makeconfig @@ -95,7 +96,7 @@ ifeq (yes,$(build-shared)) tests = loadtest restest1 preloadtest loadfail multiload origtest resolvfail \ constload1 order $(tests-vis-$(have-protected)) noload filter unload \ reldep reldep2 reldep3 next $(tests-nodelete-$(have-z-nodelete)) \ - $(tests-nodlopen-$(have-z-nodlopen)) + $(tests-nodlopen-$(have-z-nodlopen)) neededtest tests-vis-yes = vismain tests-nodelete-yes = nodelete tests-nodlopen-yes = nodlopen @@ -105,7 +106,8 @@ modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \ dep1 dep2 dep3 dep4 $(modules-vis-$(have-protected)) \ $(modules-nodelete-$(have-z-nodelete)) \ $(modules-nodlopen-$(have-z-nodlopen)) filtmod1 filtmod2 \ - reldepmod1 reldepmod2 reldepmod3 reldepmod4 nextmod1 nextmod2 + reldepmod1 reldepmod2 reldepmod3 reldepmod4 nextmod1 nextmod2 \ + neededobj1 neededobj2 neededobj3 modules-vis-yes = vismod1 vismod2 vismod3 modules-nodelete-yes = nodelmod1 nodelmod2 nodelmod3 nodelmod4 modules-nodlopen-yes = nodlopenmod @@ -249,6 +251,10 @@ $(objpfx)dep4.so: $(objpfx)dep3.so $(objpfx)nodelmod3.so: $(objpfx)nodelmod4.so $(objpfx)nextmod1.so: $(libdl) +$(objpfx)neededobj1.so: $(libdl) +$(objpfx)neededobj2.so: $(objpfx)neededobj1.so $(libdl) +$(objpfx)neededobj3.so: $(objpfx)neededobj1.so $(objpfx)neededobj2.so $(libdl) + # filtmod1.so has a special rule $(filter-out $(objpfx)filtmod1.so, $(test-modules)): $(objpfx)%.so: $(objpfx)%.os $(build-module) @@ -258,6 +264,11 @@ LDFLAGS-loadtest = -rdynamic $(objpfx)loadtest.out: $(test-modules) +$(objpfx)neededtest: $(libdl) + +$(objpfx)neededtest.out: $(objpfx)neededobj1.so $(objpfx)neededobj2.so \ + $(objpfx)neededobj3.so + $(objpfx)restest1: $(objpfx)testobj1.so $(objpfx)testobj1_1.so $(libdl) LDFLAGS-restest1 = -rdynamic diff --git a/elf/dl-close.c b/elf/dl-close.c index 8426e73ec9..03c38d906f 100644 --- a/elf/dl-close.c +++ b/elf/dl-close.c @@ -61,6 +61,9 @@ _dl_close (void *_map) /* Acquire the lock. */ __libc_lock_lock (_dl_load_lock); + list = map->l_searchlist.r_list; + nsearchlist = map->l_searchlist.r_nlist; + /* Decrement the reference count. */ if (map->l_opencount > 1 || map->l_type != lt_loaded) { @@ -78,14 +81,17 @@ _dl_close (void *_map) "\n", NULL); } - --map->l_opencount; + /* Even if we don't unload it now, we still have to decrement + `l_opencount' of the dependencies. Otherwise, they may not + get unloaded later. */ + for (i = 0; i < nsearchlist; ++i) + if (! (list[i]->l_flags_1 & DF_1_NODELETE)) + --list[i]->l_opencount; + __libc_lock_unlock (_dl_load_lock); return; } - list = map->l_searchlist.r_list; - nsearchlist = map->l_searchlist.r_nlist; - rellist = map->l_reldeps; nrellist = map->l_reldepsact; diff --git a/elf/dl-load.c b/elf/dl-load.c index 81ac23371b..b2f5ad7a1c 100644 --- a/elf/dl-load.c +++ b/elf/dl-load.c @@ -851,7 +851,7 @@ _dl_map_object_from_fd (const char *name, int fd, char *realname, if (__builtin_expect (header->e_version, EV_CURRENT) != EV_CURRENT) LOSE (0, N_("ELF file version does not match current one")); - if (! __builtin_expect (elf_machine_matches_host (header->e_machine), 1)) + if (! __builtin_expect (elf_machine_matches_host (header), 1)) LOSE (0, N_("ELF file machine architecture does not match")); if (__builtin_expect (header->e_phentsize, sizeof (ElfW(Phdr))) != sizeof (ElfW(Phdr))) diff --git a/elf/neededobj1.c b/elf/neededobj1.c new file mode 100644 index 0000000000..12c5184cc8 --- /dev/null +++ b/elf/neededobj1.c @@ -0,0 +1,4 @@ +void +c_function (void) +{ +} diff --git a/elf/neededobj2.c b/elf/neededobj2.c new file mode 100644 index 0000000000..22b0e4c794 --- /dev/null +++ b/elf/neededobj2.c @@ -0,0 +1,7 @@ +extern void c_function (void); + +void +b_function (void) +{ + c_function(); +} diff --git a/elf/neededobj3.c b/elf/neededobj3.c new file mode 100644 index 0000000000..0fc94e2112 --- /dev/null +++ b/elf/neededobj3.c @@ -0,0 +1,9 @@ +extern void b_function (void); +extern void c_function (void); + +void +a_function (void) +{ + b_function (); + c_function (); +} diff --git a/elf/neededtest.c b/elf/neededtest.c new file mode 100644 index 0000000000..053d5528aa --- /dev/null +++ b/elf/neededtest.c @@ -0,0 +1,104 @@ +#include +#include +#include +#include +#include + +static int +check_loaded_objects (const char **loaded) +{ + struct link_map *lm; + int n; + int *found = NULL; + int errors = 0; + + for (n = 0; loaded[n]; n++) + /* NOTHING */; + + if (n) + { + found = (int *) alloca (sizeof (int) * n); + memset (found, 0, sizeof (int) * n); + } + + printf(" Name\n"); + printf(" --------------------------------------------------------\n"); + for (lm = _r_debug.r_map; lm; lm = lm->l_next) + { + if (lm->l_name && lm->l_name[0]) + printf(" %s\n", lm->l_name); + if (lm->l_type == lt_loaded && lm->l_name) + { + int match = 0; + for (n = 0; loaded[n] != NULL; n++) + { + if (strcmp (basename (loaded[n]), basename (lm->l_name)) == 0) + { + found[n] = 1; + match = 1; + break; + } + } + + if (match == 0) + { + ++errors; + printf ("ERRORS: %s is not unloaded\n", lm->l_name); + } + } + } + + for (n = 0; loaded[n] != NULL; n++) + { + if (found[n] == 0) + { + ++errors; + printf ("ERRORS: %s is not loaded\n", loaded[n]); + } + } + + return errors; +} + +int +main (void) +{ + void *obj2; + void *obj3; + const char *loaded[] = { NULL, NULL, NULL, NULL }; + int errors = 0; + + printf ("\nThis is what is in memory now:\n"); + errors += check_loaded_objects (loaded); + printf( "Loading shared object neededobj3.so\n"); + obj3 = dlopen( "neededobj3.so", RTLD_LAZY); + if (obj3 == NULL) + { + printf ("%s\n", dlerror ()); + exit (1); + } + printf ("And this is what is now in memory\n"); + loaded[0] = "neededobj1.so"; + loaded[1] = "neededobj2.so"; + loaded[2] = "neededobj3.so"; + errors += check_loaded_objects (loaded); + printf ("Now loading shared object neededobj2.so\n"); + obj2 = dlopen ("neededobj2.so", RTLD_LAZY); + if (obj2 == NULL) + { + printf ("%s\n", dlerror ()); + exit (1); + } + printf ("Again, this is what is in memory\n"); + errors += check_loaded_objects (loaded); + printf ("Closing neededobj2.so\n"); + dlclose (obj2); + errors += check_loaded_objects (loaded); + printf ("Closing neededobj3.so\n"); + dlclose (obj3); + loaded[0] = NULL; + errors += check_loaded_objects (loaded); + if (errors != 0) + printf ("%d errorss found\n", errors); + return errors; +} diff --git a/include/bits/xopen_lim.h b/include/bits/xopen_lim.h index 823c801e48..e874dba73c 100644 --- a/include/bits/xopen_lim.h +++ b/include/bits/xopen_lim.h @@ -92,23 +92,54 @@ /* Number of bits in a word of type `int'. */ -#if INT_MAX == 32767 -# define WORD_BIT 16 -#else -# if INT_MAX == 2147483647 -# define WORD_BIT 32 +#ifdef INT_MAX +# if INT_MAX == 32767 +# define WORD_BIT 16 # else +# if INT_MAX == 2147483647 +# define WORD_BIT 32 +# else /* Safe assumption. */ -# define WORD_BIT 64 +# define WORD_BIT 64 +# endif # endif +#elif defined __INT_MAX__ +# if __INT_MAX__ == 32767 +# define WORD_BIT 16 +# else +# if __INT_MAX__ == 2147483647 +# define WORD_BIT 32 +# else +/* Safe assumption. */ +# define WORD_BIT 64 +# endif +# endif +#else +# define WORD_BIT 32 #endif /* Number of bits in a word of type `long int'. */ -#if LONG_MAX == 2147483647 -# define LONG_BIT 32 -#else +#ifdef LONG_MAX +# if LONG_MAX == 2147483647 +# define LONG_BIT 32 +# else /* Safe assumption. */ -# define LONG_BIT 64 +# define LONG_BIT 64 +# endif +#elif defined __LONG_MAX__ +# if __LONG_MAX__ == 2147483647 +# define LONG_BIT 32 +# else +/* Safe assumption. */ +# define LONG_BIT 64 +# endif +#else +# include +# if __WORDSIZE == 64 +# define LONG_BIT 64 +# else +# define LONG_BIT 32 +# endif #endif #endif /* bits/xopen_lim.h */ diff --git a/include/limits.h b/include/limits.h index d0c3d613f5..0e8eb9c6b3 100644 --- a/include/limits.h +++ b/include/limits.h @@ -42,6 +42,8 @@ # ifndef _LIMITS_H # define _LIMITS_H 1 +#include + /* We don't have #include_next. Define ANSI for standard 32-bit words. */ @@ -82,7 +84,7 @@ # define UINT_MAX 4294967295U /* Minimum and maximum values a `signed long int' can hold. */ -# ifdef __alpha__ +# if __WORDSIZE == 64 # define LONG_MAX 9223372036854775807L # else # define LONG_MAX 2147483647L @@ -90,7 +92,7 @@ # define LONG_MIN (-LONG_MAX - 1L) /* Maximum value an `unsigned long int' can hold. (Minimum is 0.) */ -# ifdef __alpha__ +# if __WORDSIZE == 64 # define ULONG_MAX 18446744073709551615UL # else # define ULONG_MAX 4294967295UL diff --git a/localedata/locales/iso14651_t1 b/localedata/locales/iso14651_t1 index 4f1f3a960c..6ca63358e0 100644 --- a/localedata/locales/iso14651_t1 +++ b/localedata/locales/iso14651_t1 @@ -245,6 +245,7 @@ collating-symbol collating-symbol collating-symbol collating-symbol +collating-symbol collating-symbol collating-symbol collating-symbol @@ -501,6 +502,7 @@ collating-symbol + @@ -1428,7 +1430,7 @@ order_start ;forward;forward;forward;forward,position ;;;IGNORE ;;;IGNORE ;;;IGNORE - ;;;IGNORE + ;;;IGNORE ;;;IGNORE ;;;IGNORE ;;;IGNORE @@ -1473,7 +1475,7 @@ order_start ;forward;forward;forward;forward,position ;;;IGNORE ;;;IGNORE ;;;IGNORE - ;;;IGNORE + ;;;IGNORE ;;;IGNORE ;;;IGNORE ;;;IGNORE diff --git a/posix/wordexp-tst.sh b/posix/wordexp-tst.sh index 8fe697e07d..9654457f5a 100755 --- a/posix/wordexp-tst.sh +++ b/posix/wordexp-tst.sh @@ -7,10 +7,8 @@ common_objpfx=$1; shift elf_objpfx=$1; shift rtld_installed_name=$1; shift -logfile=$common_objpfx/posix/wordexp-tst.out - -: ${TMPDIR=${common_objpfx}posix} -testout=$TMPDIR/wordexp-test-result +logfile=${common_objpfx}posix/wordexp-tst.out +testout=${common_objpfx}posix/wordexp-test-result result=0 rm -f $logfile diff --git a/sysdeps/alpha/dl-machine.h b/sysdeps/alpha/dl-machine.h index 69845b4b01..d9aeb18764 100644 --- a/sysdeps/alpha/dl-machine.h +++ b/sysdeps/alpha/dl-machine.h @@ -29,11 +29,11 @@ #include -/* Return nonzero iff E_MACHINE is compatible with the running host. */ +/* Return nonzero iff ELF header is compatible with the running host. */ static inline int -elf_machine_matches_host (Elf64_Word e_machine) +elf_machine_matches_host (const Elf64_Ehdr *ehdr) { - return e_machine == EM_ALPHA; + return ehdr->e_machine == EM_ALPHA; } /* Return the link-time address of _DYNAMIC. The multiple-got-capable diff --git a/sysdeps/arm/dl-machine.h b/sysdeps/arm/dl-machine.h index cbef92f3ae..9b40e6f98b 100644 --- a/sysdeps/arm/dl-machine.h +++ b/sysdeps/arm/dl-machine.h @@ -43,17 +43,11 @@ : "a1"); \ } -/* Return nonzero iff E_MACHINE is compatible with the running host. */ +/* Return nonzero iff ELF header is compatible with the running host. */ static inline int __attribute__ ((unused)) -elf_machine_matches_host (Elf32_Half e_machine) +elf_machine_matches_host (const Elf32_Ehdr *ehdr) { - switch (e_machine) - { - case EM_ARM: - return 1; - default: - return 0; - } + return ehdr->e_machine == EM_ARM; } @@ -491,7 +485,7 @@ elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc, newvalue = value - (Elf32_Addr)reloc_addr + (addend << 2); if (newvalue & 0xfc000003) - newvalue = fix_bad_pc24(reloc_addr, value) + newvalue = fix_bad_pc24(reloc_addr, value) - (Elf32_Addr)reloc_addr + (addend << 2); newvalue = newvalue >> 2; diff --git a/sysdeps/generic/dl-machine.h b/sysdeps/generic/dl-machine.h index a23f178034..b8502f71cc 100644 --- a/sysdeps/generic/dl-machine.h +++ b/sysdeps/generic/dl-machine.h @@ -23,11 +23,11 @@ #include -/* Return nonzero iff E_MACHINE is compatible with the running host. */ +/* Return nonzero iff ELF header is compatible with the running host. */ static inline int -elf_machine_matches_host (Elf32_Half e_machine) +elf_machine_matches_host (const Elf32_Ehdr *ehdr) { - switch (e_machine) + switch (ehdr->e_machine) { default: return 0; diff --git a/sysdeps/hppa/dl-machine.h b/sysdeps/hppa/dl-machine.h index e6782b3481..89ad542cdd 100644 --- a/sysdeps/hppa/dl-machine.h +++ b/sysdeps/hppa/dl-machine.h @@ -59,11 +59,11 @@ extern int __fptr_count; extern Elf32_Addr __hppa_make_fptr (const struct link_map *, Elf32_Addr, struct hppa_fptr **, struct hppa_fptr *); -/* Return nonzero iff E_MACHINE is compatible with the running host. */ +/* Return nonzero iff ELF header is compatible with the running host. */ static inline int -elf_machine_matches_host (Elf32_Half e_machine) +elf_machine_matches_host (const Elf32_Ehdr *ehdr) { - return e_machine == EM_PARISC; + return ehdr->e_machine == EM_PARISC; } @@ -252,7 +252,7 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile) .text .globl _start .type _start,@function -_start: +_start: /* The kernel does not give us an initial stack frame. */ ldo 64(%sp),%sp /* Save the relevant arguments (yes, those are the correct @@ -357,7 +357,7 @@ _dl_start_user: ldw RT'_dl_loaded(%r1),%r26 ldw 0(%r26),%r26 /* envp = argv + argc + 1 */ - sh2add %r25,%r24,%r23 + sh2add %r25,%r24,%r23 bl _dl_init,%r2 ldo 4(%r23),%r23 /* delay slot */ diff --git a/sysdeps/i386/dl-machine.h b/sysdeps/i386/dl-machine.h index 61b419c091..8029469e9f 100644 --- a/sysdeps/i386/dl-machine.h +++ b/sysdeps/i386/dl-machine.h @@ -24,17 +24,11 @@ #include -/* Return nonzero iff E_MACHINE is compatible with the running host. */ +/* Return nonzero iff ELF header is compatible with the running host. */ static inline int __attribute__ ((unused)) -elf_machine_matches_host (Elf32_Half e_machine) +elf_machine_matches_host (const Elf32_Ehdr *ehdr) { - switch (e_machine) - { - case EM_386: - return 1; - default: - return 0; - } + return ehdr->e_machine == EM_386; } diff --git a/sysdeps/ia64/dl-machine.h b/sysdeps/ia64/dl-machine.h index 5c4870dc9b..92aad5af47 100644 --- a/sysdeps/ia64/dl-machine.h +++ b/sysdeps/ia64/dl-machine.h @@ -53,11 +53,11 @@ extern int __fptr_count; extern Elf64_Addr __ia64_make_fptr (const struct link_map *, Elf64_Addr, struct ia64_fptr **, struct ia64_fptr *); -/* Return nonzero iff E_MACHINE is compatible with the running host. */ +/* Return nonzero iff ELF header is compatible with the running host. */ static inline int -elf_machine_matches_host (Elf64_Word e_machine) +elf_machine_matches_host (const Elf64_Ehdr *ehdr) { - return e_machine == EM_IA_64; + return ehdr->e_machine == EM_IA_64; } diff --git a/sysdeps/m68k/dl-machine.h b/sysdeps/m68k/dl-machine.h index 06c9db64a8..3381d6f25e 100644 --- a/sysdeps/m68k/dl-machine.h +++ b/sysdeps/m68k/dl-machine.h @@ -24,17 +24,11 @@ #include -/* Return nonzero iff E_MACHINE is compatible with the running host. */ +/* Return nonzero iff ELF header is compatible with the running host. */ static inline int -elf_machine_matches_host (Elf32_Half e_machine) +elf_machine_matches_host (const Elf32_Ehdr *ehdr) { - switch (e_machine) - { - case EM_68K: - return 1; - default: - return 0; - } + return ehdr->e_machine == EM_68K; } diff --git a/sysdeps/mips/dl-machine.h b/sysdeps/mips/dl-machine.h index c0ece38719..8051dc670c 100644 --- a/sysdeps/mips/dl-machine.h +++ b/sysdeps/mips/dl-machine.h @@ -86,11 +86,11 @@ do { if ((l)->l_info[DT_MIPS (RLD_MAP)]) \ (ElfW(Addr)) (r); \ } while (0) -/* Return nonzero iff E_MACHINE is compatible with the running host. */ +/* Return nonzero iff ELF header is compatible with the running host. */ static inline int __attribute__ ((unused)) -elf_machine_matches_host (ElfW(Half) e_machine) +elf_machine_matches_host (const ElfW(Ehdr) *ehdr) { - switch (e_machine) + switch (ehdr->e_machine) { case EM_MIPS: case EM_MIPS_RS3_LE: diff --git a/sysdeps/mips/mips64/dl-machine.h b/sysdeps/mips/mips64/dl-machine.h index 195a1d3634..59bd581eae 100644 --- a/sysdeps/mips/mips64/dl-machine.h +++ b/sysdeps/mips/mips64/dl-machine.h @@ -77,11 +77,11 @@ do { if ((l)->l_info[DT_MIPS (RLD_MAP)]) \ (ElfW(Addr)) (r); \ } while (0) -/* Return nonzero iff E_MACHINE is compatible with the running host. */ +/* Return nonzero iff ELF header is compatible with the running host. */ static inline int __attribute__ ((unused)) -elf_machine_matches_host (ElfW(Half) e_machine) +elf_machine_matches_host (const ElfW(Ehdr) *ehdr) { - switch (e_machine) + switch (ehdr->e_machine) { case EM_MIPS: case EM_MIPS_RS3_LE: diff --git a/sysdeps/powerpc/dl-machine.h b/sysdeps/powerpc/dl-machine.h index 0307a2924a..c8d6c113cf 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, 1999, 2000 + Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -25,11 +25,11 @@ #include -/* Return nonzero iff E_MACHINE is compatible with the running host. */ +/* Return nonzero iff ELF header is compatible with the running host. */ static inline int -elf_machine_matches_host (Elf32_Half e_machine) +elf_machine_matches_host (const Elf32_Ehdr *ehdr) { - return e_machine == EM_PPC; + return ehdr->e_machine == EM_PPC; } diff --git a/sysdeps/s390/dl-machine.h b/sysdeps/s390/dl-machine.h index 3cab824ce2..3432426127 100644 --- a/sysdeps/s390/dl-machine.h +++ b/sysdeps/s390/dl-machine.h @@ -29,17 +29,11 @@ #include -/* Return nonzero iff E_MACHINE is compatible with the running host. */ +/* Return nonzero iff ELF header is compatible with the running host. */ static inline int -elf_machine_matches_host (Elf32_Half e_machine) +elf_machine_matches_host (const Elf32_Ehdr *ehdr) { - switch (e_machine) - { - case EM_S390: - return 1; - default: - return 0; - } + return ehdr->e_machine == EM_S390; } diff --git a/sysdeps/sh/dl-machine.h b/sysdeps/sh/dl-machine.h index 1530f946f8..dd21dfbb9c 100644 --- a/sysdeps/sh/dl-machine.h +++ b/sysdeps/sh/dl-machine.h @@ -28,17 +28,11 @@ #include -/* Return nonzero iff E_MACHINE is compatible with the running host. */ +/* Return nonzero iff ELF header is compatible with the running host. */ static inline int __attribute__ ((unused)) -elf_machine_matches_host (Elf32_Half e_machine) +elf_machine_matches_host (const Elf32_Ehdr *ehdr) { - switch (e_machine) - { - case EM_SH: - return 1; - default: - return 0; - } + return ehdr->e_machine == EM_SH; } diff --git a/sysdeps/sparc/sparc32/dl-machine.h b/sysdeps/sparc/sparc32/dl-machine.h index cd91addda5..c1d423aa36 100644 --- a/sysdeps/sparc/sparc32/dl-machine.h +++ b/sysdeps/sparc/sparc32/dl-machine.h @@ -43,13 +43,13 @@ : "/etc/ld.so.preload") -/* Return nonzero iff E_MACHINE is compatible with the running host. */ +/* Return nonzero iff ELF header is compatible with the running host. */ static inline int -elf_machine_matches_host (Elf32_Half e_machine) +elf_machine_matches_host (const Elf32_Ehdr *ehdr) { - if (e_machine == EM_SPARC) + if (ehdr->e_machine == EM_SPARC) return 1; - else if (e_machine == EM_SPARC32PLUS) + else if (ehdr->e_machine == EM_SPARC32PLUS) { unsigned long *hwcap; weak_extern (_dl_hwcap); diff --git a/sysdeps/sparc/sparc64/dl-machine.h b/sysdeps/sparc/sparc64/dl-machine.h index 6aa9ca6659..079e1d7530 100644 --- a/sysdeps/sparc/sparc64/dl-machine.h +++ b/sysdeps/sparc/sparc64/dl-machine.h @@ -27,11 +27,11 @@ #define ELF64_R_TYPE_ID(info) ((info) & 0xff) #define ELF64_R_TYPE_DATA(info) ((info) >> 8) -/* Return nonzero iff E_MACHINE is compatible with the running host. */ +/* Return nonzero iff ELF header is compatible with the running host. */ static inline int -elf_machine_matches_host (Elf64_Half e_machine) +elf_machine_matches_host (const Elf64_Ehdr *ehdr) { - return e_machine == EM_SPARCV9; + return ehdr->e_machine == EM_SPARCV9; } /* Return the link-time address of _DYNAMIC. Conveniently, this is the