diff options
| author | Xavier Leroy <xavier.leroy@inria.fr> | 2012-02-21 17:41:02 +0000 |
|---|---|---|
| committer | Xavier Leroy <xavier.leroy@inria.fr> | 2012-02-21 17:41:02 +0000 |
| commit | 2eecf2d4c0933f64bcfa3e620f031497166db338 (patch) | |
| tree | 38eeb1c84b8be72a918fbbc8ef5498c02840755b /asmrun | |
| parent | fd515e3a166e8fcb30188f4aa4a2d07e25c2de98 (diff) | |
| download | ocaml-2eecf2d4c0933f64bcfa3e620f031497166db338.tar.gz | |
PR#5487: addition of CFI directives and a few filename/linenumber info to generated amd64 and i386 assembly files.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@12179 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'asmrun')
| -rw-r--r-- | asmrun/amd64.S | 22 | ||||
| -rw-r--r-- | asmrun/i386.S | 21 |
2 files changed, 43 insertions, 0 deletions
diff --git a/asmrun/amd64.S b/asmrun/amd64.S index 40716e0196..715e796bcb 100644 --- a/asmrun/amd64.S +++ b/asmrun/amd64.S @@ -18,6 +18,8 @@ /* PIC mode support based on contribution by Paul Stravers (see PR#4795) */ +#include "../config/m.h" + #if defined(SYS_macosx) #define LBL(x) L##x @@ -63,6 +65,16 @@ #endif +#ifdef ASM_CFI_SUPPORTED +#define CFI_STARTPROC .cfi_startproc +#define CFI_ENDPROC .cfi_endproc +#define CFI_ADJUST(n) .cfi_adjust_cfa_offset n +#else +#define CFI_STARTPROC +#define CFI_ENDPROC +#define CFI_ADJUST(n) +#endif + #if defined(__PIC__) && !defined(SYS_mingw64) /* Position-independent operations on global variables. */ @@ -226,6 +238,7 @@ G(caml_system__code_begin): /* Allocation */ FUNCTION(G(caml_call_gc)) + CFI_STARTPROC RECORD_STACK_FRAME(0) LBL(caml_call_gc): #ifndef SYS_mingw64 @@ -255,6 +268,7 @@ LBL(caml_call_gc): STORE_VAR(%r14, caml_exception_pointer) /* Save floating-point registers */ subq $(16*8), %rsp + CFI_ADJUST(232) movsd %xmm0, 0*8(%rsp) movsd %xmm1, 1*8(%rsp) movsd %xmm2, 2*8(%rsp) @@ -309,8 +323,10 @@ LBL(caml_call_gc): popq %rbp popq %r12 popq %r13 + CFI_ADJUST(-232) /* Return to caller */ ret + CFI_ENDPROC FUNCTION(G(caml_alloc1)) LBL(caml_alloc1): @@ -396,8 +412,10 @@ LBL(caml_c_call): /* Start the OCaml program */ FUNCTION(G(caml_start_program)) + CFI_STARTPROC /* Save callee-save registers */ PUSH_CALLEE_SAVE_REGS + CFI_ADJUST(56) /* Initial entry point is G(caml_program) */ leaq GCALL(caml_program)(%rip), %r12 /* Common code for caml_start_program and caml_callback* */ @@ -407,6 +425,7 @@ LBL(caml_start_program): PUSH_VAR(caml_gc_regs) PUSH_VAR(caml_last_return_address) PUSH_VAR(caml_bottom_of_stack) + CFI_ADJUST(32) /* Setup alloc ptr and exception ptr */ LOAD_VAR(caml_young_ptr, %r15) LOAD_VAR(caml_exception_pointer, %r14) @@ -414,6 +433,7 @@ LBL(caml_start_program): lea LBL(108)(%rip), %r13 pushq %r13 pushq %r14 + CFI_ADJUST(16) movq %rsp, %r14 /* Call the OCaml code */ call *%r12 @@ -421,6 +441,7 @@ LBL(107): /* Pop the exception handler */ popq %r14 popq %r12 /* dummy register */ + CFI_ADJUST(-16) LBL(109): /* Update alloc ptr and exception ptr */ STORE_VAR(%r15,caml_young_ptr) @@ -439,6 +460,7 @@ LBL(108): /* Mark the bucket as an exception result and return it */ orq $2, %rax jmp LBL(109) + CFI_ENDPROC /* Registers holding arguments of C functions. */ diff --git a/asmrun/i386.S b/asmrun/i386.S index 6c86de05a4..e9b8a93bb7 100644 --- a/asmrun/i386.S +++ b/asmrun/i386.S @@ -16,6 +16,8 @@ /* Asm part of the runtime system, Intel 386 processor */ /* Must be preprocessed by cpp */ +#include "../config/m.h" + /* Linux/BSD with ELF binaries and Solaris do not prefix identifiers with _. Linux/BSD with a.out binaries and NextStep do. */ @@ -42,6 +44,16 @@ #define FUNCTION_ALIGN 2 #endif +#ifdef ASM_CFI_SUPPORTED +#define CFI_STARTPROC .cfi_startproc +#define CFI_ENDPROC .cfi_endproc +#define CFI_ADJUST(n) .cfi_adjust_cfa_offset n +#else +#define CFI_STARTPROC +#define CFI_ENDPROC +#define CFI_ADJUST(n) +#endif + #if defined(PROFILING) #if defined(SYS_linux_elf) || defined(SYS_gnu) #define PROFILE_CAML \ @@ -92,6 +104,7 @@ G(caml_system__code_begin): .align FUNCTION_ALIGN G(caml_call_gc): + CFI_STARTPROC PROFILE_CAML /* Record lowest stack address and return address */ movl 0(%esp), %eax @@ -114,6 +127,7 @@ LBL(105): pushl %ecx pushl %ebx pushl %eax + CFI_ADJUST(28) movl %esp, G(caml_gc_regs) /* MacOSX note: 16-alignment of stack preserved at this point */ /* Call the garbage collector */ @@ -126,8 +140,10 @@ LBL(105): popl %esi popl %edi popl %ebp + CFI_ADJUST(-28) /* Return to caller */ ret + CFI_ENDPROC .align FUNCTION_ALIGN G(caml_alloc1): @@ -236,12 +252,14 @@ G(caml_c_call): .globl G(caml_start_program) .align FUNCTION_ALIGN G(caml_start_program): + CFI_STARTPROC PROFILE_C /* Save callee-save registers */ pushl %ebx pushl %esi pushl %edi pushl %ebp + CFI_ADJUST(16) /* Initial entry point is caml_program */ movl $ G(caml_program), %esi /* Common code for caml_start_program and caml_callback* */ @@ -255,6 +273,7 @@ LBL(106): pushl $ LBL(108) ALIGN_STACK(8) pushl G(caml_exception_pointer) + CFI_ADJUST(20) movl %esp, G(caml_exception_pointer) /* Call the OCaml code */ call *%esi @@ -266,6 +285,7 @@ LBL(107): #else addl $4, %esp #endif + CFI_ADJUST(-8) LBL(109): /* Pop the callback link, restoring the global variables */ popl G(caml_bottom_of_stack) @@ -283,6 +303,7 @@ LBL(108): /* Mark the bucket as an exception result and return it */ orl $2, %eax jmp LBL(109) + CFI_ENDPROC /* Raise an exception from OCaml */ |
