diff options
author | Jakub Jelinek <jakub@redhat.com> | 2009-03-20 20:00:20 +0000 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2009-03-20 20:00:20 +0000 |
commit | ef860a878bf532436a469fc1f89fe3366862a949 (patch) | |
tree | c4a2666ac77cdaa00f41bd8f66a828b39e2642ff /elf | |
parent | d4c583b4466962a9d9d4ca54ab6108dc7b42cdcc (diff) |
Updated to fedora-glibc-20090320T1944cvs/fedora-glibc-2_9_90-11
Diffstat (limited to 'elf')
-rw-r--r-- | elf/dl-load.c | 3 | ||||
-rw-r--r-- | elf/dl-open.c | 11 | ||||
-rw-r--r-- | elf/dl-reloc.c | 8 | ||||
-rw-r--r-- | elf/dl-runtime.c | 33 | ||||
-rw-r--r-- | elf/dl-sysdep.c | 59 | ||||
-rw-r--r-- | elf/do-lookup.h | 12 | ||||
-rw-r--r-- | elf/elf.h | 1 | ||||
-rw-r--r-- | elf/rtld.c | 15 |
8 files changed, 84 insertions, 58 deletions
diff --git a/elf/dl-load.c b/elf/dl-load.c index c77c259156..0deb51e445 100644 --- a/elf/dl-load.c +++ b/elf/dl-load.c @@ -941,7 +941,8 @@ _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp, { #ifdef SHARED /* Auditing checkpoint: we are going to add new objects. */ - if (__builtin_expect (GLRO(dl_naudit) > 0, 0)) + if ((mode & __RTLD_AUDIT) == 0 + && __builtin_expect (GLRO(dl_naudit) > 0, 0)) { struct link_map *head = GL(dl_ns)[nsid]._ns_loaded; /* Do not call the functions for any auditing object. */ diff --git a/elf/dl-open.c b/elf/dl-open.c index f825aa0437..75dc7bc406 100644 --- a/elf/dl-open.c +++ b/elf/dl-open.c @@ -1,5 +1,5 @@ /* Load a shared object at runtime, relocate it, and run its initializer. - Copyright (C) 1996-2004, 2005, 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 1996-2007, 2009 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 @@ -207,7 +207,6 @@ dl_open_worker (void *a) const char *file = args->file; int mode = args->mode; struct link_map *new; - int lazy; unsigned int i; bool any_tls = false; struct link_map *call_map = NULL; @@ -366,7 +365,9 @@ dl_open_worker (void *a) _dl_debug_state (); /* Only do lazy relocation if `LD_BIND_NOW' is not set. */ - lazy = (mode & RTLD_BINDING_MASK) == RTLD_LAZY && GLRO(dl_lazy); + int reloc_mode = mode & __RTLD_AUDIT; + if (GLRO(dl_lazy)) + reloc_mode |= mode & RTLD_LAZY; /* Relocate the objects loaded. We do this in reverse order so that copy relocs of earlier objects overwrite the data written by later objects. */ @@ -388,7 +389,7 @@ dl_open_worker (void *a) start the profiling. */ struct link_map *old_profile_map = GL(dl_profile_map); - _dl_relocate_object (l, l->l_scope, 1, 1); + _dl_relocate_object (l, l->l_scope, reloc_mode | RTLD_LAZY, 1); if (old_profile_map == NULL && GL(dl_profile_map) != NULL) { @@ -401,7 +402,7 @@ dl_open_worker (void *a) } else #endif - _dl_relocate_object (l, l->l_scope, lazy, 0); + _dl_relocate_object (l, l->l_scope, reloc_mode, 0); } if (l == new) diff --git a/elf/dl-reloc.c b/elf/dl-reloc.c index a303cb4ce6..28f08de3e7 100644 --- a/elf/dl-reloc.c +++ b/elf/dl-reloc.c @@ -1,5 +1,5 @@ /* Relocate a shared object and resolve its references to other loaded objects. - Copyright (C) 1995-2004, 2005, 2006, 2008 Free Software Foundation, Inc. + Copyright (C) 1995-2006, 2008, 2009 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 @@ -151,7 +151,7 @@ _dl_nothread_init_static_tls (struct link_map *map) void _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[], - int lazy, int consider_profiling) + int reloc_mode, int consider_profiling) { struct textrels { @@ -162,10 +162,12 @@ _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[], } *textrels = NULL; /* Initialize it to make the compiler happy. */ const char *errstring = NULL; + int lazy = reloc_mode & RTLD_LAZY; #ifdef SHARED /* If we are auditing, install the same handlers we need for profiling. */ - consider_profiling |= GLRO(dl_audit) != NULL; + if ((reloc_mode & __RTLD_AUDIT) == 0) + consider_profiling |= GLRO(dl_audit) != NULL; #elif defined PROF /* Never use dynamic linker profiling for gprof profiling code. */ # define consider_profiling 0 diff --git a/elf/dl-runtime.c b/elf/dl-runtime.c index 968e293409..93c8f29d39 100644 --- a/elf/dl-runtime.c +++ b/elf/dl-runtime.c @@ -1,5 +1,5 @@ /* On-demand PLT fixup for shared objects. - Copyright (C) 1995-2006, 2007 Free Software Foundation, Inc. + Copyright (C) 1995-2006, 2007, 2008, 2009 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 @@ -46,6 +46,12 @@ # define ARCH_FIXUP_ATTRIBUTE #endif +#ifndef reloc_offset +# define reloc_offset reloc_arg +# define reloc_index reloc_arg / sizeof (PLTREL) +#endif + + /* This function is called through a special trampoline from the PLT the first time each PLT entry is called. We must perform the relocation @@ -63,7 +69,7 @@ _dl_fixup ( # endif /* GKM FIXME: Fix trampoline to pass bounds so we can do without the `__unbounded' qualifier. */ - struct link_map *__unbounded l, ElfW(Word) reloc_offset) + struct link_map *__unbounded l, ElfW(Word) reloc_arg) { const ElfW(Sym) *const symtab = (const void *) D_PTR (l, l_info[DT_SYMTAB]); @@ -130,6 +136,9 @@ _dl_fixup ( /* And now perhaps the relocation addend. */ value = elf_machine_plt_value (l, reloc, value); + if (__builtin_expect (ELFW(ST_TYPE) (sym->st_info) == STT_GNU_IFUNC, 0)) + value = ((DL_FIXUP_VALUE_TYPE (*) (void)) value) (); + /* Finally, fix up the plt itself. */ if (__builtin_expect (GLRO(dl_bind_not), 0)) return value; @@ -139,22 +148,20 @@ _dl_fixup ( #endif #if !defined PROF && !defined ELF_MACHINE_NO_PLT && !__BOUNDED_POINTERS__ - DL_FIXUP_VALUE_TYPE __attribute ((noinline)) ARCH_FIXUP_ATTRIBUTE _dl_profile_fixup ( #ifdef ELF_MACHINE_RUNTIME_FIXUP_ARGS ELF_MACHINE_RUNTIME_FIXUP_ARGS, #endif - struct link_map *l, ElfW(Word) reloc_offset, + struct link_map *l, ElfW(Word) reloc_arg, ElfW(Addr) retaddr, void *regs, long int *framesizep) { void (*mcount_fct) (ElfW(Addr), ElfW(Addr)) = INTUSE(_dl_mcount); /* 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_offset / sizeof (PLTREL)]; + struct reloc_result *reloc_result = &l->l_reloc_result[reloc_index]; DL_FIXUP_VALUE_TYPE *resultp = &reloc_result->addr; DL_FIXUP_VALUE_TYPE value = *resultp; @@ -215,12 +222,21 @@ _dl_profile_fixup ( defsym != NULL ? LOOKUP_VALUE_ADDRESS (result) + defsym->st_value : 0); + + if (__builtin_expect (ELFW(ST_TYPE) (defsym->st_info) + == STT_GNU_IFUNC, 0)) + value = ((DL_FIXUP_VALUE_TYPE (*) (void)) value) (); } else { /* We already found the symbol. The module (and therefore its load address) is also known. */ value = DL_FIXUP_MAKE_VALUE (l, l->l_addr + refsym->st_value); + + if (__builtin_expect (ELFW(ST_TYPE) (refsym->st_info) + == STT_GNU_IFUNC, 0)) + value = ((DL_FIXUP_VALUE_TYPE (*) (void)) value) (); + result = l; } /* And now perhaps the relocation addend. */ @@ -403,7 +419,7 @@ _dl_profile_fixup ( #include <stdio.h> void ARCH_FIXUP_ATTRIBUTE -_dl_call_pltexit (struct link_map *l, ElfW(Word) reloc_offset, +_dl_call_pltexit (struct link_map *l, ElfW(Word) reloc_arg, const void *inregs, void *outregs) { #ifdef SHARED @@ -411,8 +427,7 @@ _dl_call_pltexit (struct link_map *l, ElfW(Word) reloc_offset, relocations. */ // XXX Maybe the bound information must be stored on the stack since // XXX with bind_not a new value could have been stored in the meantime. - struct reloc_result *reloc_result - = &l->l_reloc_result[reloc_offset / sizeof (PLTREL)]; + struct reloc_result *reloc_result = &l->l_reloc_result[reloc_index]; ElfW(Sym) *defsym = ((ElfW(Sym) *) D_PTR (reloc_result->bound, l_info[DT_SYMTAB]) + reloc_result->boundndx); diff --git a/elf/dl-sysdep.c b/elf/dl-sysdep.c index a44bee7086..db1001253c 100644 --- a/elf/dl-sysdep.c +++ b/elf/dl-sysdep.c @@ -269,36 +269,37 @@ _dl_show_auxv (void) { static const struct { - const char label[20]; - enum { unknown = 0, dec, hex, str, ignore } form; + const char label[17]; + enum { unknown = 0, dec, hex, str, ignore } form : 8; } auxvars[] = { - [AT_EXECFD - 2] = { "AT_EXECFD: ", dec }, - [AT_EXECFN - 2] = { "AT_EXECFN: ", str }, - [AT_PHDR - 2] = { "AT_PHDR: 0x", hex }, - [AT_PHENT - 2] = { "AT_PHENT: ", dec }, - [AT_PHNUM - 2] = { "AT_PHNUM: ", dec }, - [AT_PAGESZ - 2] = { "AT_PAGESZ: ", dec }, - [AT_BASE - 2] = { "AT_BASE: 0x", hex }, - [AT_FLAGS - 2] = { "AT_FLAGS: 0x", hex }, - [AT_ENTRY - 2] = { "AT_ENTRY: 0x", hex }, - [AT_NOTELF - 2] = { "AT_NOTELF: ", hex }, - [AT_UID - 2] = { "AT_UID: ", dec }, - [AT_EUID - 2] = { "AT_EUID: ", dec }, - [AT_GID - 2] = { "AT_GID: ", dec }, - [AT_EGID - 2] = { "AT_EGID: ", dec }, - [AT_PLATFORM - 2] = { "AT_PLATFORM: ", str }, - [AT_HWCAP - 2] = { "AT_HWCAP: ", hex }, - [AT_CLKTCK - 2] = { "AT_CLKTCK: ", dec }, - [AT_FPUCW - 2] = { "AT_FPUCW: ", hex }, - [AT_DCACHEBSIZE - 2] = { "AT_DCACHEBSIZE: 0x", hex }, - [AT_ICACHEBSIZE - 2] = { "AT_ICACHEBSIZE: 0x", hex }, - [AT_UCACHEBSIZE - 2] = { "AT_UCACHEBSIZE: 0x", hex }, - [AT_IGNOREPPC - 2] = { "AT_IGNOREPPC", ignore }, - [AT_SECURE - 2] = { "AT_SECURE: ", dec }, - [AT_SYSINFO - 2] = { "AT_SYSINFO: 0x", hex }, - [AT_SYSINFO_EHDR - 2] = { "AT_SYSINFO_EHDR: 0x", hex }, - [AT_RANDOM - 2] = { "AT_RANDOM: 0x", hex }, + [AT_EXECFD - 2] = { "EXECFD: ", dec }, + [AT_EXECFN - 2] = { "EXECFN: ", str }, + [AT_PHDR - 2] = { "PHDR: 0x", hex }, + [AT_PHENT - 2] = { "PHENT: ", dec }, + [AT_PHNUM - 2] = { "PHNUM: ", dec }, + [AT_PAGESZ - 2] = { "PAGESZ: ", dec }, + [AT_BASE - 2] = { "BASE: 0x", hex }, + [AT_FLAGS - 2] = { "FLAGS: 0x", hex }, + [AT_ENTRY - 2] = { "ENTRY: 0x", hex }, + [AT_NOTELF - 2] = { "NOTELF: ", hex }, + [AT_UID - 2] = { "UID: ", dec }, + [AT_EUID - 2] = { "EUID: ", dec }, + [AT_GID - 2] = { "GID: ", dec }, + [AT_EGID - 2] = { "EGID: ", dec }, + [AT_PLATFORM - 2] = { "PLATFORM: ", str }, + [AT_HWCAP - 2] = { "HWCAP: ", hex }, + [AT_CLKTCK - 2] = { "CLKTCK: ", dec }, + [AT_FPUCW - 2] = { "FPUCW: ", hex }, + [AT_DCACHEBSIZE - 2] = { "DCACHEBSIZE: 0x", hex }, + [AT_ICACHEBSIZE - 2] = { "ICACHEBSIZE: 0x", hex }, + [AT_UCACHEBSIZE - 2] = { "UCACHEBSIZE: 0x", hex }, + [AT_IGNOREPPC - 2] = { "IGNOREPPC", ignore }, + [AT_SECURE - 2] = { "SECURE: ", dec }, + [AT_BASE_PLATFORM - 2] = { "BASE_PLATFORM:", str }, + [AT_SYSINFO - 2] = { "SYSINFO: 0x", hex }, + [AT_SYSINFO_EHDR - 2] = { "SYSINFO_EHDR: 0x", hex }, + [AT_RANDOM - 2] = { "RANDOM: 0x", hex }, }; unsigned int idx = (unsigned int) (av->a_type - 2); @@ -327,7 +328,7 @@ _dl_show_auxv (void) val = _itoa ((unsigned long int) av->a_un.a_val, buf + sizeof buf - 1, 16, 0); - _dl_printf ("%s%s\n", auxvars[idx].label, val); + _dl_printf ("AT_%s%s\n", auxvars[idx].label, val); continue; } diff --git a/elf/do-lookup.h b/elf/do-lookup.h index ebb9ed5b47..41e5fc137c 100644 --- a/elf/do-lookup.h +++ b/elf/do-lookup.h @@ -1,5 +1,5 @@ /* Look up a symbol in the loaded objects. - Copyright (C) 1995-2004, 2005, 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 1995-2007, 2008 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 @@ -88,10 +88,12 @@ do_lookup_x (const char *undef_name, uint_fast32_t new_hash, if (__builtin_expect (ELFW(ST_TYPE) (sym->st_info) > STT_FUNC && ELFW(ST_TYPE) (sym->st_info) != STT_COMMON - && ELFW(ST_TYPE) (sym->st_info) != STT_TLS, 0)) - /* Ignore all but STT_NOTYPE, STT_OBJECT, STT_FUNC, and STT_COMMON - entries (and STT_TLS if TLS is supported) since these - are no code/data definitions. */ + && ELFW(ST_TYPE) (sym->st_info) != STT_TLS + && ELFW(ST_TYPE) (sym->st_info) != STT_GNU_IFUNC, + 0)) + /* Ignore all but STT_NOTYPE, STT_OBJECT, STT_FUNC, STT_COMMON, + STT_TLS, and STT_GNU_IFUNC since these are no code/data + definitions. */ return NULL; if (sym != ref && strcmp (strtab + sym->st_name, undef_name)) @@ -459,6 +459,7 @@ typedef struct #define STT_TLS 6 /* Symbol is thread-local data object*/ #define STT_NUM 7 /* Number of defined types. */ #define STT_LOOS 10 /* Start of OS-specific */ +#define STT_GNU_IFUNC 10 /* Symbol is indirect code object */ #define STT_HIOS 12 /* End of OS-specific */ #define STT_LOPROC 13 /* Start of processor-specific */ #define STT_HIPROC 15 /* End of processor-specific */ diff --git a/elf/rtld.c b/elf/rtld.c index aa4c030f73..bfe9564463 100644 --- a/elf/rtld.c +++ b/elf/rtld.c @@ -574,7 +574,7 @@ _dl_start (void *arg) struct relocate_args { struct link_map *l; - int lazy; + int reloc_mode; }; struct map_args @@ -613,7 +613,7 @@ relocate_doit (void *a) { struct relocate_args *args = (struct relocate_args *) a; - _dl_relocate_object (args->l, args->l->l_scope, args->lazy, 0); + _dl_relocate_object (args->l, args->l->l_scope, args->reloc_mode, 0); } static void @@ -1011,7 +1011,8 @@ of this helper program; chances are you did not intend to run this program.\n\ --library-path PATH use given PATH instead of content of the environment\n\ variable LD_LIBRARY_PATH\n\ --inhibit-rpath LIST ignore RUNPATH and RPATH information in object names\n\ - in LIST\n"); + in LIST\n\ + --audit LIST use objects named in LIST as auditors\n"); ++_dl_skip_args; --_dl_argc; @@ -1908,7 +1909,9 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", struct link_map *l = main_map; /* Relocate the main executable. */ - struct relocate_args args = { .l = l, .lazy = GLRO(dl_lazy) }; + struct relocate_args args = { .l = l, + .reloc_mode = (GLRO(dl_lazy) + ? RTLD_LAZY : 0) }; _dl_receive_error (print_unresolved, relocate_doit, &args); /* This loop depends on the dependencies of the executable to @@ -1985,7 +1988,7 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", struct relocate_args args; struct link_map *l; - args.lazy = GLRO(dl_lazy); + args.reloc_mode = GLRO(dl_lazy) ? RTLD_LAZY : 0; l = main_map; while (l->l_next != NULL) @@ -2225,7 +2228,7 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", } if (l != &GL(dl_rtld_map)) - _dl_relocate_object (l, l->l_scope, GLRO(dl_lazy), + _dl_relocate_object (l, l->l_scope, GLRO(dl_lazy) ? RTLD_LAZY : 0, consider_profiling); /* Add object to slot information data if necessasy. */ |