* elf/dl-load.c (lose): Use noinline attribute instead of silly
	alloca to prevent inlining.
	* elf/dl-runtime.c (fixup): Likewise.
	(profile_fixup): Likewise.
This commit is contained in:
Ulrich Drepper 2004-02-09 07:10:19 +00:00
parent 14a60f0440
commit a481b13cc2
3 changed files with 13 additions and 30 deletions

View File

@ -1,5 +1,10 @@
2004-02-08 Ulrich Drepper <drepper@redhat.com> 2004-02-08 Ulrich Drepper <drepper@redhat.com>
* elf/dl-load.c (lose): Use noinline attribute instead of silly
alloca to prevent inlining.
* elf/dl-runtime.c (fixup): Likewise.
(profile_fixup): Likewise.
* stdio-common/printf_size.c: Undo parts of patch from 2000-2-11. * stdio-common/printf_size.c: Undo parts of patch from 2000-2-11.
Initialize width correctly. Initialize width correctly.

View File

@ -764,26 +764,14 @@ _dl_init_paths (const char *llp)
} }
/* Think twice before changing anything in this function. It is placed
here and prepared using the `alloca' magic to prevent it from being
inlined. The function is only called in case of an error. But then
performance does not count. The function used to be "inlinable" and
the compiled did so all the time. This increased the code size for
absolutely no good reason. */
static void static void
__attribute__ ((noreturn)) __attribute__ ((noreturn, noinline))
lose (int code, int fd, const char *name, char *realname, struct link_map *l, lose (int code, int fd, const char *name, char *realname, struct link_map *l,
const char *msg) const char *msg)
{ {
/* The use of `alloca' here looks ridiculous but it helps. The goal
is to avoid the function from being inlined. There is no official
way to do this so we use this trick. gcc never inlines functions
which use `alloca'. */
int *a = (int *) alloca (sizeof (int));
a[0] = fd;
/* The file might already be closed. */ /* The file might already be closed. */
if (a[0] != -1) if (fd != -1)
(void) __close (a[0]); (void) __close (fd);
if (l != NULL) if (l != NULL)
{ {
/* Remove the stillborn object from the list and free it. */ /* Remove the stillborn object from the list and free it. */

View File

@ -1,5 +1,5 @@
/* On-demand PLT fixup for shared objects. /* On-demand PLT fixup for shared objects.
Copyright (C) 1995-2002, 2003 Free Software Foundation, Inc. Copyright (C) 1995-2002, 2003, 2004 Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or The GNU C Library is free software; you can redistribute it and/or
@ -45,7 +45,8 @@
function. */ function. */
#ifndef ELF_MACHINE_NO_PLT #ifndef ELF_MACHINE_NO_PLT
static ElfW(Addr) __attribute_used__ static ElfW(Addr)
__attribute ((used, noinline))
fixup ( fixup (
# ifdef ELF_MACHINE_RUNTIME_FIXUP_ARGS # ifdef ELF_MACHINE_RUNTIME_FIXUP_ARGS
ELF_MACHINE_RUNTIME_FIXUP_ARGS, ELF_MACHINE_RUNTIME_FIXUP_ARGS,
@ -65,12 +66,6 @@ fixup (
lookup_t result; lookup_t result;
ElfW(Addr) value; ElfW(Addr) value;
/* The use of `alloca' here looks ridiculous but it helps. The goal is
to prevent the function from being inlined and thus optimized out.
There is no official way to do this so we use this trick. gcc never
inlines functions which use `alloca'. */
alloca (sizeof (int));
/* Sanity check that we're really looking at a PLT relocation. */ /* Sanity check that we're really looking at a PLT relocation. */
assert (ELFW(R_TYPE)(reloc->r_info) == ELF_MACHINE_JMP_SLOT); assert (ELFW(R_TYPE)(reloc->r_info) == ELF_MACHINE_JMP_SLOT);
@ -132,7 +127,8 @@ fixup (
#if !defined PROF && !defined ELF_MACHINE_NO_PLT && !__BOUNDED_POINTERS__ #if !defined PROF && !defined ELF_MACHINE_NO_PLT && !__BOUNDED_POINTERS__
static ElfW(Addr) __attribute_used__ static ElfW(Addr)
__attribute ((used, noinline))
profile_fixup ( profile_fixup (
#ifdef ELF_MACHINE_RUNTIME_FIXUP_ARGS #ifdef ELF_MACHINE_RUNTIME_FIXUP_ARGS
ELF_MACHINE_RUNTIME_FIXUP_ARGS, ELF_MACHINE_RUNTIME_FIXUP_ARGS,
@ -144,12 +140,6 @@ profile_fixup (
lookup_t result; lookup_t result;
ElfW(Addr) value; ElfW(Addr) value;
/* The use of `alloca' here looks ridiculous but it helps. The goal is
to prevent the function from being inlined, and thus optimized out.
There is no official way to do this so we use this trick. gcc never
inlines functions which use `alloca'. */
alloca (sizeof (int));
/* This is the address in the array where we store the result of previous /* This is the address in the array where we store the result of previous
relocations. */ relocations. */
resultp = &l->l_reloc_result[reloc_offset / sizeof (PLTREL)]; resultp = &l->l_reloc_result[reloc_offset / sizeof (PLTREL)];