From c27e56d74f3fb58f18e5381e49d30e1134b2005e Mon Sep 17 00:00:00 2001 From: joseph Date: Sat, 17 Nov 2012 17:50:14 +0000 Subject: Merge changes between r21628 and r21775 from /fsf/trunk. git-svn-id: svn://svn.eglibc.org/trunk@21776 7b3dc134-2b1b-0410-93df-9e9f96275f8d --- libc/elf/Makefile | 6 +++++- libc/elf/dl-runtime.c | 28 +++++++++++++++++++++++----- libc/elf/tst-array1.c | 6 ++++-- libc/elf/tst-array2dep.c | 6 ++++-- libc/elf/tst-audit8.c | 1 + 5 files changed, 37 insertions(+), 10 deletions(-) create mode 100644 libc/elf/tst-audit8.c (limited to 'libc/elf') diff --git a/libc/elf/Makefile b/libc/elf/Makefile index 5155d0910..be9456bf7 100644 --- a/libc/elf/Makefile +++ b/libc/elf/Makefile @@ -142,7 +142,7 @@ tests += loadtest restest1 preloadtest loadfail multiload origtest resolvfail \ tst-dlmodcount tst-dlopenrpath tst-deep1 \ tst-dlmopen1 tst-dlmopen2 tst-dlmopen3 \ unload3 unload4 unload5 unload6 unload7 unload8 tst-global1 order2 \ - tst-audit1 tst-audit2 \ + tst-audit1 tst-audit2 tst-audit8 \ tst-stackguard1 tst-addr1 tst-thrlock \ tst-unique1 tst-unique2 tst-unique3 tst-unique4 \ tst-initorder tst-initorder2 tst-relsort1 @@ -1020,6 +1020,10 @@ $(objpfx)tst-audit7: $(objpfx)tst-auditmod7a.so $(objpfx)tst-audit7.out: $(objpfx)tst-auditmod7b.so tst-audit7-ENV = LD_AUDIT=$(objpfx)tst-auditmod7b.so +$(objpfx)tst-audit8: $(common-objpfx)math/libm.so +$(objpfx)tst-audit8.out: $(objpfx)tst-auditmod1.so +tst-audit8-ENV = LD_AUDIT=$(objpfx)tst-auditmod1.so + $(objpfx)tst-global1: $(libdl) $(objpfx)tst-global1.out: $(objpfx)testobj6.so $(objpfx)testobj2.so diff --git a/libc/elf/dl-runtime.c b/libc/elf/dl-runtime.c index 2e02a218e..19543aa44 100644 --- a/libc/elf/dl-runtime.c +++ b/libc/elf/dl-runtime.c @@ -1,5 +1,5 @@ /* On-demand PLT fixup for shared objects. - Copyright (C) 1995-2009, 2010, 2011 Free Software Foundation, Inc. + Copyright (C) 1995-2012 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 @@ -56,7 +56,6 @@ to that address. Future calls will bounce directly from the PLT to the function. */ -#ifndef ELF_MACHINE_NO_PLT DL_FIXUP_VALUE_TYPE __attribute ((noinline)) ARCH_FIXUP_ATTRIBUTE _dl_fixup ( @@ -150,9 +149,8 @@ _dl_fixup ( return elf_machine_fixup_plt (l, result, reloc, rel_addr, value); } -#endif -#if !defined PROF && !defined ELF_MACHINE_NO_PLT && !__BOUNDED_POINTERS__ +#if !defined PROF && !__BOUNDED_POINTERS__ DL_FIXUP_VALUE_TYPE __attribute ((noinline)) ARCH_FIXUP_ATTRIBUTE _dl_profile_fixup ( @@ -164,6 +162,26 @@ _dl_profile_fixup ( { void (*mcount_fct) (ElfW(Addr), ElfW(Addr)) = INTUSE(_dl_mcount); + if (l->l_reloc_result == NULL) + { + /* BZ #14843: ELF_DYNAMIC_RELOCATE is called before l_reloc_result + is allocated. We will get here if ELF_DYNAMIC_RELOCATE calls a + resolver function to resolve an IRELATIVE relocation and that + resolver calls a function that is not yet resolved (lazy). For + example, the resolver in x86-64 libm.so calls __get_cpu_features + defined in libc.so. Skip audit and resolve the external function + in this case. */ + *framesizep = -1; + return _dl_fixup ( +# ifdef ELF_MACHINE_RUNTIME_FIXUP_ARGS +# ifndef ELF_MACHINE_RUNTIME_FIXUP_PARAMS +# error Please define ELF_MACHINE_RUNTIME_FIXUP_PARAMS. +# endif + ELF_MACHINE_RUNTIME_FIXUP_PARAMS, +# endif + l, reloc_arg); + } + /* This is the address in the array where we store the result of previous relocations. */ struct reloc_result *reloc_result = &l->l_reloc_result[reloc_index]; @@ -417,7 +435,7 @@ _dl_profile_fixup ( return value; } -#endif /* PROF && ELF_MACHINE_NO_PLT */ +#endif /* PROF */ #include diff --git a/libc/elf/tst-array1.c b/libc/elf/tst-array1.c index ca9bdf407..e998932b3 100644 --- a/libc/elf/tst-array1.c +++ b/libc/elf/tst-array1.c @@ -1,6 +1,7 @@ #include -static void init (void) __attribute__ ((constructor)); +/* Give init non-default priority so that it runs before init_array. */ +static void init (void) __attribute__ ((constructor (1000))); static void init (void) @@ -8,7 +9,8 @@ init (void) write (STDOUT_FILENO, "init\n", 5); } -static void fini (void) __attribute__ ((destructor)); +/* Give fini the same priority as init. */ +static void fini (void) __attribute__ ((destructor (1000))); static void fini (void) diff --git a/libc/elf/tst-array2dep.c b/libc/elf/tst-array2dep.c index 2812761a0..2f920cdc8 100644 --- a/libc/elf/tst-array2dep.c +++ b/libc/elf/tst-array2dep.c @@ -1,6 +1,7 @@ #include -static void init (void) __attribute__ ((constructor)); +/* Give init non-default priority so that it runs before init_array. */ +static void init (void) __attribute__ ((constructor (1000))); static void init (void) @@ -8,7 +9,8 @@ init (void) write (STDOUT_FILENO, "DSO init\n", 9); } -static void fini (void) __attribute__ ((destructor)); +/* Give fini the same priority as init. */ +static void fini (void) __attribute__ ((destructor (1000))); static void fini (void) diff --git a/libc/elf/tst-audit8.c b/libc/elf/tst-audit8.c new file mode 100644 index 000000000..63656b4ee --- /dev/null +++ b/libc/elf/tst-audit8.c @@ -0,0 +1 @@ +#include "../io/pwd.c" -- cgit v1.2.3