summaryrefslogtreecommitdiff
path: root/elf
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2005-07-08 09:10:42 +0000
committerJakub Jelinek <jakub@redhat.com>2005-07-08 09:10:42 +0000
commit48f006fc656c70757103dc9efa92d5775717576b (patch)
tree49d57e1205b93471c3245fceab5dd5ac31ba743d /elf
parent03d65262fdcc287ef8b691c7dff2f1a63cdd13c2 (diff)
Updated to fedora-glibc-20050708T0811
Diffstat (limited to 'elf')
-rw-r--r--elf/Makefile21
-rw-r--r--elf/dl-error.c5
-rw-r--r--elf/dl-reloc.c5
-rw-r--r--elf/stackguard-macros.h7
-rw-r--r--elf/tst-array5-static.c1
-rw-r--r--elf/tst-array5-static.exp2
-rw-r--r--elf/tst-array5.c50
-rw-r--r--elf/tst-array5.exp3
-rw-r--r--elf/tst-array5dep.c23
9 files changed, 109 insertions, 8 deletions
diff --git a/elf/Makefile b/elf/Makefile
index c43eb02f5b..a563f0190f 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -88,7 +88,9 @@ distribute := rtld-Rules \
unload4mod1.c unload4mod2.c unload4mod3.c unload4mod4.c \
unload6mod1.c unload6mod2.c unload6mod3.c tst-auditmod1.c \
order2mod1.c order2mod2.c order2mod3.c order2mod4.c \
- tst-stackguard1.c tst-stackguard1-static.c
+ tst-stackguard1.c tst-stackguard1-static.c \
+ tst-array5.c tst-array5-static.c tst-array5dep.c \
+ tst-array5.exp
CFLAGS-dl-runtime.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-dl-lookup.c = -fexceptions -fasynchronous-unwind-tables
@@ -138,7 +140,7 @@ endif
tests = tst-tls1 tst-tls2 tst-tls9
ifeq (yes,$(have-initfini-array))
-tests += tst-array1 tst-array2 tst-array3 tst-array4
+tests += tst-array1 tst-array2 tst-array3 tst-array4 tst-array5
endif
ifeq (yes,$(build-static))
tests-static = tst-tls1-static tst-tls2-static tst-stackguard1-static
@@ -148,7 +150,7 @@ tst-tls9-static-ENV = \
LD_LIBRARY_PATH=$(objpfx):$(common-objpfx):$(common-objpfx)dlfcn
endif
ifeq (yes,$(have-initfini-array))
-tests-static += tst-array1-static
+tests-static += tst-array1-static tst-array5-static
endif
tests += $(tests-static)
endif
@@ -206,7 +208,7 @@ modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \
unload6mod1 unload6mod2 unload6mod3 \
order2mod1 order2mod2 order2mod3 order2mod4
ifeq (yes,$(have-initfini-array))
-modules-names += tst-array2dep
+modules-names += tst-array2dep tst-array5dep
endif
ifeq (yesyes,$(have-fpie)$(build-shared))
modules-names += tst-piemod1
@@ -767,6 +769,17 @@ $(objpfx)tst-array4.out: $(objpfx)tst-array4 $(objpfx)tst-array2dep.so
$< > $@
cmp $@ tst-array4.exp > /dev/null
+$(objpfx)tst-array5: $(objpfx)tst-array5dep.so
+$(objpfx)tst-array5.out: $(objpfx)tst-array5
+ $(elf-objpfx)$(rtld-installed-name) \
+ --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \
+ $(objpfx)tst-array5 > $@
+ cmp $@ tst-array5.exp > /dev/null
+
+$(objpfx)tst-array5-static.out: $(objpfx)tst-array5-static
+ $(objpfx)tst-array5-static > $@
+ cmp $@ tst-array5-static.exp > /dev/null
+
ifeq (yesyes,$(have-fpie)$(build-shared))
CFLAGS-tst-pie1.c += -fpie
diff --git a/elf/dl-error.c b/elf/dl-error.c
index a63d801411..3a0d9bb8a7 100644
--- a/elf/dl-error.c
+++ b/elf/dl-error.c
@@ -98,8 +98,9 @@ _dl_signal_error (int errcode, const char *objname, const char *occation,
/* If the main executable is relocated it means the libc's malloc
is used. */
#ifdef SHARED
- lcatch->malloced = (GL(dl_ns)[LM_ID_BASE]._ns_loaded->l_relocated
- != 0);
+ lcatch->malloced = (GL(dl_ns)[LM_ID_BASE]._ns_loaded != NULL
+ && (GL(dl_ns)[LM_ID_BASE]._ns_loaded->l_relocated
+ != 0));
#else
lcatch->malloced = true;
#endif
diff --git a/elf/dl-reloc.c b/elf/dl-reloc.c
index 2d309fb210..117410e924 100644
--- a/elf/dl-reloc.c
+++ b/elf/dl-reloc.c
@@ -153,6 +153,9 @@ _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[],
#ifdef SHARED
/* If we are auditing, install the same handlers we need for profiling. */
consider_profiling |= GLRO(dl_audit) != NULL;
+#elif defined PROF
+ /* Never use dynamic linker profiling for gprof profiling code. */
+# define consider_profiling 0
#endif
if (l->l_relocated)
@@ -264,6 +267,7 @@ _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[],
ELF_DYNAMIC_RELOCATE (l, lazy, consider_profiling);
+#ifndef PROF
if (__builtin_expect (consider_profiling, 0))
{
/* Allocate the array which will contain the already found
@@ -288,6 +292,7 @@ _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[],
goto fatal;
}
}
+#endif
}
/* Mark the object so we know this work has been done. */
diff --git a/elf/stackguard-macros.h b/elf/stackguard-macros.h
index 0fbf4d2c0b..97db8bc22a 100644
--- a/elf/stackguard-macros.h
+++ b/elf/stackguard-macros.h
@@ -20,10 +20,13 @@
({ uintptr_t x; asm ("ld [%%g7+0x14], %0" : "=r" (x)); x; })
#elif defined __s390x__
# define STACK_CHK_GUARD \
- ({ uintptr_t x; asm ("ear %0,%a0; sllg %0,%0,32; ear %0,%a1; lg %0,0x28(%0)" : "=r" (x)); x; })
+ ({ uintptr_t x; asm ("ear %0,%%a0; sllg %0,%0,32; ear %0,%%a1; lg %0,0x28(%0)" : "=a" (x)); x; })
#elif defined __s390__
# define STACK_CHK_GUARD \
- ({ uintptr_t x; asm ("ear %0,%%a0; l %0,0x14(%0)" : "=r" (x)); x; })
+ ({ uintptr_t x; asm ("ear %0,%%a0; l %0,0x14(%0)" : "=a" (x)); x; })
+#elif defined __ia64__
+# define STACK_CHK_GUARD \
+ ({ uintptr_t x; asm ("adds %0 = -8, r13;; ld8 %0 = [%0]" : "=r" (x)); x; })
#else
extern uintptr_t __stack_chk_guard;
# define STACK_CHK_GUARD __stack_chk_guard
diff --git a/elf/tst-array5-static.c b/elf/tst-array5-static.c
new file mode 100644
index 0000000000..4ef2aba3f3
--- /dev/null
+++ b/elf/tst-array5-static.c
@@ -0,0 +1 @@
+#include "tst-array5.c"
diff --git a/elf/tst-array5-static.exp b/elf/tst-array5-static.exp
new file mode 100644
index 0000000000..b1dc9e467b
--- /dev/null
+++ b/elf/tst-array5-static.exp
@@ -0,0 +1,2 @@
+preinit array in executable: tst-array5-static
+init array in executable: tst-array5-static
diff --git a/elf/tst-array5.c b/elf/tst-array5.c
new file mode 100644
index 0000000000..03a5668326
--- /dev/null
+++ b/elf/tst-array5.c
@@ -0,0 +1,50 @@
+#include <string.h>
+#include <unistd.h>
+
+static void
+preinit_0 (int argc __attribute__ ((unused)), char **argv)
+{
+ char *p = strrchr (argv [0], '/');
+
+ if (p == NULL)
+ return;
+
+ p++;
+ size_t len = strlen (p);
+ write (STDOUT_FILENO, "preinit array in executable: ", 29);
+ write (STDOUT_FILENO, p, len);
+ write (STDOUT_FILENO, "\n", 1);
+}
+
+void (*const preinit_array []) (int, char **)
+ __attribute__ ((section (".preinit_array"), aligned (sizeof (void *)))) =
+{
+ &preinit_0,
+};
+
+static void
+init_0 (int argc __attribute__ ((unused)), char **argv)
+{
+ char *p = strrchr (argv [0], '/');
+
+ if (p == NULL)
+ return;
+
+ p++;
+ size_t len = strlen (p);
+ write (STDOUT_FILENO, "init array in executable: ", 26);
+ write (STDOUT_FILENO, p, len);
+ write (STDOUT_FILENO, "\n", 1);
+}
+
+void (*const init_array []) (int, char **)
+ __attribute__ ((section (".init_array"), aligned (sizeof (void *)))) =
+{
+ &init_0,
+};
+
+int
+main (void)
+{
+ return 0;
+}
diff --git a/elf/tst-array5.exp b/elf/tst-array5.exp
new file mode 100644
index 0000000000..28b4909833
--- /dev/null
+++ b/elf/tst-array5.exp
@@ -0,0 +1,3 @@
+preinit array in executable: tst-array5
+init array in DSO: tst-array5
+init array in executable: tst-array5
diff --git a/elf/tst-array5dep.c b/elf/tst-array5dep.c
new file mode 100644
index 0000000000..570d282af4
--- /dev/null
+++ b/elf/tst-array5dep.c
@@ -0,0 +1,23 @@
+#include <string.h>
+#include <unistd.h>
+
+static void
+init_0 (int argc __attribute__ ((unused)), char **argv)
+{
+ char *p = strrchr (argv [0], '/');
+
+ if (p == NULL)
+ return;
+
+ p++;
+ size_t len = strlen (p);
+ write (STDOUT_FILENO, "init array in DSO: ", 19);
+ write (STDOUT_FILENO, p, len);
+ write (STDOUT_FILENO, "\n", 1);
+}
+
+void (*const init_array []) (int, char **)
+ __attribute__ ((section (".init_array"), aligned (sizeof (void *)))) =
+{
+ &init_0,
+};