about summary refs log tree commit diff
path: root/elf
diff options
context:
space:
mode:
Diffstat (limited to 'elf')
-rw-r--r--elf/dl-runtime.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/elf/dl-runtime.c b/elf/dl-runtime.c
index a0f54bd3fc..9f3004ecf5 100644
--- a/elf/dl-runtime.c
+++ b/elf/dl-runtime.c
@@ -57,6 +57,12 @@ fixup (
   void *const rel_addr = (void *)(l->l_addr + reloc->r_offset);
   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.  */
   assert (ELFW(R_TYPE)(reloc->r_info) == ELF_MACHINE_JMP_SLOT);
 
@@ -110,6 +116,12 @@ profile_fixup (
   ElfW(Addr) *resultp;
   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
      relocations.  */
   resultp = &l->l_reloc_result[reloc_offset / sizeof (PLTREL)];