public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Add CFI to i386 _start functions
@ 2016-08-15 19:24 Keno Fischer
  0 siblings, 0 replies; only message in thread
From: Keno Fischer @ 2016-08-15 19:24 UTC (permalink / raw)
  To: libc-alpha

As a follow up to my patch patch for RTLD_START on x86_64, this adds
cfi instructions to the _start functions in both the dynamic loader
and the application startup files.
---
 sysdeps/i386/dl-machine.h | 14 ++++++++++----
 sysdeps/i386/start.S      | 10 ++++++----
 2 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/sysdeps/i386/dl-machine.h b/sysdeps/i386/dl-machine.h
index 4e3968a..b8fd5f3 100644
--- a/sysdeps/i386/dl-machine.h
+++ b/sysdeps/i386/dl-machine.h
@@ -149,11 +149,16 @@ extern ElfW(Addr) _dl_profile_fixup (struct link_map *l,
  .align 16\n\
 .globl _start\n\
 .globl _dl_start_user\n\
-_start:\n\
+_start:\n"\
+CFI_STARTPROC "\n"\
+CFI_UNDEFINED(%eip) "\n\
  # Note that _dl_start gets the parameter in %eax.\n\
  movl %esp, %eax\n\
- call _dl_start\n\
-_dl_start_user:\n\
+ call _dl_start\n"\
+CFI_ENDPROC "\n\
+_dl_start_user:\n"\
+CFI_STARTPROC "\n"\
+CFI_UNDEFINED(%eip) "\n\
  # Save the user entry point address in %edi.\n\
  movl %eax, %edi\n\
  # Point %ebx at the GOT.\n\
@@ -195,7 +200,8 @@ _dl_start_user:\n\
  # Restore %esp _start expects.\n\
  movl (%esp), %esp\n\
  # Jump to the user's entry point.\n\
- jmp *%edi\n\
+ jmp *%edi\n"\
+CFI_ENDPROC "\n\
  .previous\n\
 ");

diff --git a/sysdeps/i386/start.S b/sysdeps/i386/start.S
index 964e6d9..3ad1749 100644
--- a/sysdeps/i386/start.S
+++ b/sysdeps/i386/start.S
@@ -52,10 +52,11 @@
  NULL
 */

- .text
- .globl _start
- .type _start,@function
-_start:
+#include <sysdep.h>
+
+ENTRY (_start)
+ /* Also use CFI to indicate outermost frame.  */
+ cfi_undefined (eip)
  /* Clear the frame pointer.  The ABI suggests this be done, to mark
    the outermost frame obviously.  */
  xorl %ebp, %ebp
@@ -121,6 +122,7 @@ _start:
 1: movl (%esp), %ebx
  ret
 #endif
+END (_start)

 /* To fulfill the System V/i386 ABI we need this symbol.  Yuck, it's so
    meaningless since we don't support machines < 80386.  */
-- 
2.8.1

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-08-15 19:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-15 19:24 [PATCH] Add CFI to i386 _start functions Keno Fischer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).