2003-05-30  Andreas Jaeger  <aj@suse.de>

	* sysdeps/x86_64/dl-machine.h (ELF_MACHINE_RUNTIME_TRAMPOLINE):
	Add CFI directives.

	* sysdeps/unix/sysv/linux/x86_64/sigaction.c (RESTORE2): Add CFI
	directives.

	* sysdeps/generic/sysdep.h: Add CFI_* macros for C files.

	* sysdeps/unix/sysv/linux/x86_64/sysdep.h (SYSCALL_ERROR_HANDLER):
	Add CFI directives.
This commit is contained in:
Andreas Jaeger 2003-05-30 16:12:18 +00:00
parent b34f9a90b1
commit 2b1c0eeae3
5 changed files with 88 additions and 33 deletions

View File

@ -1,3 +1,16 @@
2003-05-30 Andreas Jaeger <aj@suse.de>
* sysdeps/x86_64/dl-machine.h (ELF_MACHINE_RUNTIME_TRAMPOLINE):
Add CFI directives.
* sysdeps/unix/sysv/linux/x86_64/sigaction.c (RESTORE2): Add CFI
directives.
* sysdeps/generic/sysdep.h: Add CFI_* macros for C files.
* sysdeps/unix/sysv/linux/x86_64/sysdep.h (SYSCALL_ERROR_HANDLER):
Add CFI directives.
2003-05-30 Jakub Jelinek <jakub@redhat.com> 2003-05-30 Jakub Jelinek <jakub@redhat.com>
* sysdeps/powerpc/powerpc32/elf/start.S: Make code compilable with * sysdeps/powerpc/powerpc32/elf/start.S: Make code compilable with

View File

@ -66,5 +66,31 @@
# define cfi_offset(reg, off) # define cfi_offset(reg, off)
# endif # endif
#else /* ! ASSEMBLER */
# ifdef HAVE_ASM_CFI_DIRECTIVES
# define CFI_STRINGIFY(Name) CFI_STRINGIFY2 (Name)
# define CFI_STRINGIFY2(Name) #Name
# define CFI_STARTPROC ".cfi_startproc"
# define CFI_ENDPROC ".cfi_endproc"
# define CFI_DEF_CFA(reg, off) \
".cfi_def_cfa " CFI_STRINGIFY(reg) "," CFI_STRINGIFY(off)
# define CFI_DEF_CFA_REGISTER(reg) \
".cfi_def_cfa_register " CFI_STRINGIFY(reg)
# define CFI_DEF_CFA_OFFSET(off) \
".cfi_def_cfa_offset " CFI_STRINGIFY(off)
# define CFI_ADJUST_CFA_OFFSET(off) \
".cfi_adjust_cfa_offset " CFI_STRINGIFY(off)
# define CFI_OFFSET(reg, off) \
".cfi_offset " CFI_STRINGIFY(reg) "," CFI_STRINGIFY(off)
# else
# define CFI_STARTPROC
# define CFI_ENDPROC
# define CFI_DEF_CFA(reg, off)
# define CFI_DEF_CFA_REGISTER(reg)
# define CFI_DEF_CFA_OFFSET(off)
# define CFI_ADJUST_CFA_OFFSET(off)
# define CFI_OFFSET(reg, off)
# endif
#endif /* __ASSEMBLER__ */ #endif /* __ASSEMBLER__ */

View File

@ -97,14 +97,15 @@ weak_alias (__libc_sigaction, sigaction)
appropriate GDB maintainer. */ appropriate GDB maintainer. */
#define RESTORE(name, syscall) RESTORE2 (name, syscall) #define RESTORE(name, syscall) RESTORE2 (name, syscall)
#define RESTORE2(name, syscall) \ # define RESTORE2(name, syscall) \
asm \ asm \
( \ ( \
".align 16\n" \ ".align 16\n" \
CFI_STARTPROC "\n" \
"__" #name ":\n" \ "__" #name ":\n" \
" movq $" #syscall ", %rax\n" \ " movq $" #syscall ", %rax\n" \
" syscall\n" \ " syscall\n" \
CFI_ENDPROC "\n" \
); );
/* The return code for realtime-signals. */ /* The return code for realtime-signals. */
RESTORE (restore_rt, __NR_rt_sigreturn) RESTORE (restore_rt, __NR_rt_sigreturn)

View File

@ -132,11 +132,13 @@
0: \ 0: \
xorq %rdx, %rdx; \ xorq %rdx, %rdx; \
subq %rax, %rdx; \ subq %rax, %rdx; \
pushq %rdx \ pushq %rdx; \
cfi_adjust_cfa_offset(8); \
PUSH_ERRNO_LOCATION_RETURN; \ PUSH_ERRNO_LOCATION_RETURN; \
call BP_SYM (__errno_location)@PLT; \ call BP_SYM (__errno_location)@PLT; \
POP_ERRNO_LOCATION_RETURN; \ POP_ERRNO_LOCATION_RETURN; \
popq %rdx; \ popq %rdx; \
cfi_adjust_cfa_offset(-8); \
movl %edx, (%rax); \ movl %edx, (%rax); \
orq $-1, %rax; \ orq $-1, %rax; \
jmp L(pseudo_end); jmp L(pseudo_end);

View File

@ -24,6 +24,7 @@
#define ELF_MACHINE_NAME "x86_64" #define ELF_MACHINE_NAME "x86_64"
#include <sys/param.h> #include <sys/param.h>
#include <sysdep.h>
/* Return nonzero iff ELF header is compatible with the running host. */ /* Return nonzero iff ELF header is compatible with the running host. */
static inline int __attribute__ ((unused)) static inline int __attribute__ ((unused))
@ -136,14 +137,17 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
.globl _dl_runtime_resolve\n\ .globl _dl_runtime_resolve\n\
.type _dl_runtime_resolve, @function\n\ .type _dl_runtime_resolve, @function\n\
.align 16\n\ .align 16\n\
" CFI_STARTPROC "\n\
_dl_runtime_resolve:\n\ _dl_runtime_resolve:\n\
pushq %rax # Preserve registers otherwise clobbered.\n\ subq $56,%rsp\n\
pushq %rcx\n\ " CFI_ADJUST_CFA_OFFSET(72)" # Incorporate PLT\n\
pushq %rdx\n\ movq %rax,(%rsp) # Preserve registers otherwise clobbered.\n\
pushq %rsi\n\ movq %rcx,8(%rsp)\n\
pushq %rdi\n\ movq %rdx,16(%rsp)\n\
pushq %r8\n\ movq %rsi,24(%rsp)\n\
pushq %r9\n\ movq %rdi,32(%rsp)\n\
movq %r8,40(%rsp)\n\
movq %r9,48(%rsp)\n\
movq 64(%rsp), %rsi # Copy args pushed by PLT in register.\n\ movq 64(%rsp), %rsi # Copy args pushed by PLT in register.\n\
movq %rsi,%r11 # Multiply by 24\n\ movq %rsi,%r11 # Multiply by 24\n\
addq %r11,%rsi\n\ addq %r11,%rsi\n\
@ -152,28 +156,33 @@ _dl_runtime_resolve:\n\
movq 56(%rsp), %rdi # %rdi: link_map, %rsi: reloc_offset\n\ movq 56(%rsp), %rdi # %rdi: link_map, %rsi: reloc_offset\n\
call fixup # Call resolver.\n\ call fixup # Call resolver.\n\
movq %rax, %r11 # Save return value\n\ movq %rax, %r11 # Save return value\n\
popq %r9 # Get register content back.\n\ movq 48(%rsp),%r9 # Get register content back.\n\
popq %r8\n\ movq 40(%rsp),%r8\n\
popq %rdi\n\ movq 32(%rsp),%rdi\n\
popq %rsi\n\ movq 24(%rsp),%rsi\n\
popq %rdx\n\ movq 16(%rsp),%rdx\n\
popq %rcx\n\ movq 8(%rsp),%rcx\n\
popq %rax\n\ movq (%rsp),%rax\n\
addq $16,%rsp # Adjust stack\n\ addq $72,%rsp # Adjust stack(PLT did 2 pushes)\n\
" CFI_ADJUST_CFA_OFFSET(-72)" \n\
jmp *%r11 # Jump to function address.\n\ jmp *%r11 # Jump to function address.\n\
" CFI_ENDPROC "\n\
.size _dl_runtime_resolve, .-_dl_runtime_resolve\n\ .size _dl_runtime_resolve, .-_dl_runtime_resolve\n\
\n\ \n\
.globl _dl_runtime_profile\n\ .globl _dl_runtime_profile\n\
.type _dl_runtime_profile, @function\n\ .type _dl_runtime_profile, @function\n\
.align 16\n\ .align 16\n\
" CFI_STARTPROC "\n\
_dl_runtime_profile:\n\ _dl_runtime_profile:\n\
pushq %rax # Preserve registers otherwise clobbered.\n\ subq $56,%rsp\n\
pushq %rcx\n\ " CFI_ADJUST_CFA_OFFSET(72)" # Incorporate PLT\n\
pushq %rdx\n\ movq %rax,(%rsp) # Preserve registers otherwise clobbered.\n\
pushq %rsi\n\ movq %rcx,8(%rsp)\n\
pushq %rdi\n\ movq %rdx,16(%rsp)\n\
pushq %r8\n\ movq %rsi,24(%rsp)\n\
pushq %r9\n\ movq %rdi,32(%rsp)\n\
movq %r8,40(%rsp)\n\
movq %r9,48(%rsp)\n\
movq 72(%rsp), %rdx # Load return address if needed\n\ movq 72(%rsp), %rdx # Load return address if needed\n\
movq 64(%rsp), %rsi # Copy args pushed by PLT in register.\n\ movq 64(%rsp), %rsi # Copy args pushed by PLT in register.\n\
movq %rsi,%r11 # Multiply by 24\n\ movq %rsi,%r11 # Multiply by 24\n\
@ -183,15 +192,17 @@ _dl_runtime_profile:\n\
movq 56(%rsp), %rdi # %rdi: link_map, %rsi: reloc_offset\n\ movq 56(%rsp), %rdi # %rdi: link_map, %rsi: reloc_offset\n\
call profile_fixup # Call resolver.\n\ call profile_fixup # Call resolver.\n\
movq %rax, %r11 # Save return value\n\ movq %rax, %r11 # Save return value\n\
popq %r9 # Get register content back.\n\ movq 48(%rsp),%r9 # Get register content back.\n\
popq %r8\n\ movq 40(%rsp),%r8\n\
popq %rdi\n\ movq 32(%rsp),%rdi\n\
popq %rsi\n\ movq 24(%rsp),%rsi\n\
popq %rdx\n\ movq 16(%rsp),%rdx\n\
popq %rcx\n\ movq 8(%rsp),%rcx\n\
popq %rax\n\ movq (%rsp),%rax\n\
addq $16,%rsp # Adjust stack\n\ addq $72,%rsp # Adjust stack\n\
" CFI_ADJUST_CFA_OFFSET(-72)"\n\
jmp *%r11 # Jump to function address.\n\ jmp *%r11 # Jump to function address.\n\
" CFI_ENDPROC "\n\
.size _dl_runtime_profile, .-_dl_runtime_profile\n\ .size _dl_runtime_profile, .-_dl_runtime_profile\n\
.previous\n\ .previous\n\
"); ");
@ -203,6 +214,7 @@ _dl_runtime_profile:\n\
.type _dl_runtime_resolve, @function\n\ .type _dl_runtime_resolve, @function\n\
.type _dl_runtime_profile, @function\n\ .type _dl_runtime_profile, @function\n\
.align 16\n\ .align 16\n\
" CFI_STARTPROC "\n\
_dl_runtime_resolve:\n\ _dl_runtime_resolve:\n\
_dl_runtime_profile:\n\ _dl_runtime_profile:\n\
pushq %rax # Preserve registers otherwise clobbered.\n\ pushq %rax # Preserve registers otherwise clobbered.\n\
@ -229,6 +241,7 @@ _dl_runtime_profile:\n\
popq %rax\n\ popq %rax\n\
addq $16,%rsp # Adjust stack\n\ addq $16,%rsp # Adjust stack\n\
jmp *%r11 # Jump to function address.\n\ jmp *%r11 # Jump to function address.\n\
" CFI_ENDPROC "\n\
.size _dl_runtime_resolve, .-_dl_runtime_resolve\n\ .size _dl_runtime_resolve, .-_dl_runtime_resolve\n\
.size _dl_runtime_profile, .-_dl_runtime_profile\n\ .size _dl_runtime_profile, .-_dl_runtime_profile\n\
.previous\n\ .previous\n\