From bd7fe1d3c4c8877ac53839169851621249289bd7 Mon Sep 17 00:00:00 2001 From: Christopher Ferris Date: Tue, 20 Aug 2013 11:20:48 -0700 Subject: [PATCH] Update all debug directives. The libcorkscrew stack unwinder does not understand cfi directives, so add .save directives so that it can function properly. Also add the directives in to strcmp.S and fix a missing set of directives in cortex-a9/memcpy_base.S. Bug: 10345269 Merge from internal master. (cherry-picked from 5f7ccea3ffab05aeceecb85c821003cf580630d3) Change-Id: If48a216203216a643807f5d61906015984987189 --- .../arch-arm/cortex-a15/bionic/__strcat_chk.S | 5 +++- .../arch-arm/cortex-a15/bionic/__strcpy_chk.S | 1 + libc/arch-arm/cortex-a15/bionic/memcpy.S | 5 ++++ libc/arch-arm/cortex-a15/bionic/memset.S | 2 ++ libc/arch-arm/cortex-a15/bionic/strcmp.S | 14 ++++++++++ libc/arch-arm/cortex-a9/bionic/__strcat_chk.S | 3 +++ libc/arch-arm/cortex-a9/bionic/__strcpy_chk.S | 1 + libc/arch-arm/cortex-a9/bionic/memcpy.S | 1 + libc/arch-arm/cortex-a9/bionic/memcpy_base.S | 9 ++++++- libc/arch-arm/cortex-a9/bionic/memset.S | 3 +++ libc/arch-arm/cortex-a9/bionic/strcmp.S | 26 +++++++++++++++++++ libc/arch-arm/krait/bionic/__strcat_chk.S | 3 +++ libc/arch-arm/krait/bionic/__strcpy_chk.S | 1 + libc/arch-arm/krait/bionic/memcpy.S | 4 +++ libc/arch-arm/krait/bionic/memset.S | 2 ++ libc/arch-arm/krait/bionic/strcmp.S | 26 +++++++++++++++++++ 16 files changed, 104 insertions(+), 2 deletions(-) diff --git a/libc/arch-arm/cortex-a15/bionic/__strcat_chk.S b/libc/arch-arm/cortex-a15/bionic/__strcat_chk.S index 08dc78a9a..4b125c89c 100644 --- a/libc/arch-arm/cortex-a15/bionic/__strcat_chk.S +++ b/libc/arch-arm/cortex-a15/bionic/__strcat_chk.S @@ -40,14 +40,16 @@ ENTRY(__strcat_chk) .cfi_startproc pld [r0, #0] + .save {r0, lr} push {r0, lr} .cfi_def_cfa_offset 8 .cfi_rel_offset r0, 0 .cfi_rel_offset lr, 4 + .save {r4, r5} push {r4, r5} .cfi_adjust_cfa_offset 8 .cfi_rel_offset r4, 0 - .cfi_rel_offset r5, 0 + .cfi_rel_offset r5, 4 mov lr, r2 @@ -185,6 +187,7 @@ ENTRY(__strcat_chk) pld [r1, #64] mov r2, r4 add r0, r0, r3 + .pad #-8 pop {r4, r5} .cfi_adjust_cfa_offset -8 .cfi_restore r4 diff --git a/libc/arch-arm/cortex-a15/bionic/__strcpy_chk.S b/libc/arch-arm/cortex-a15/bionic/__strcpy_chk.S index 9fde59015..a04581681 100644 --- a/libc/arch-arm/cortex-a15/bionic/__strcpy_chk.S +++ b/libc/arch-arm/cortex-a15/bionic/__strcpy_chk.S @@ -39,6 +39,7 @@ ENTRY(__strcpy_chk) .cfi_startproc pld [r0, #0] + .save {r0, lr} push {r0, lr} .cfi_def_cfa_offset 8 .cfi_rel_offset r0, 0 diff --git a/libc/arch-arm/cortex-a15/bionic/memcpy.S b/libc/arch-arm/cortex-a15/bionic/memcpy.S index 8052d62ef..16881d4de 100644 --- a/libc/arch-arm/cortex-a15/bionic/memcpy.S +++ b/libc/arch-arm/cortex-a15/bionic/memcpy.S @@ -74,18 +74,22 @@ END(__memcpy_chk) ENTRY(memcpy) .cfi_startproc pld [r1, #64] + .save {r0, lr} push {r0, lr} .cfi_def_cfa_offset 8 .cfi_rel_offset r0, 0 .cfi_rel_offset lr, 4 #include "memcpy_base.S" + .cfi_endproc END(memcpy) + .fnstart .cfi_startproc __memcpy_chk_fail: // Preserve lr for backtrace. + .save {lr} push {lr} .cfi_def_cfa_offset 4 .cfi_rel_offset lr, 0 @@ -100,6 +104,7 @@ error_code: error_message: .word error_string-(1b+8) .cfi_endproc + .fnend .data error_string: diff --git a/libc/arch-arm/cortex-a15/bionic/memset.S b/libc/arch-arm/cortex-a15/bionic/memset.S index 5593be689..b5fc6babd 100644 --- a/libc/arch-arm/cortex-a15/bionic/memset.S +++ b/libc/arch-arm/cortex-a15/bionic/memset.S @@ -45,6 +45,7 @@ ENTRY(__memset_chk) bls .L_done // Preserve lr for backtrace. + .save {lr} push {lr} .cfi_def_cfa_offset 4 .cfi_rel_offset lr, 0 @@ -73,6 +74,7 @@ END(bzero) ENTRY(memset) .cfi_startproc + .save {r0} stmfd sp!, {r0} .cfi_def_cfa_offset 4 .cfi_rel_offset r0, 0 diff --git a/libc/arch-arm/cortex-a15/bionic/strcmp.S b/libc/arch-arm/cortex-a15/bionic/strcmp.S index 7aff7c4e1..2719bf7fc 100644 --- a/libc/arch-arm/cortex-a15/bionic/strcmp.S +++ b/libc/arch-arm/cortex-a15/bionic/strcmp.S @@ -122,9 +122,15 @@ ENTRY(strcmp) .macro init /* Macro to save temporary registers and prepare magic values. */ + .save {r4-r7} subs sp, sp, #16 + .cfi_def_cfa_offset 16 strd r4, r5, [sp, #8] + .cfi_rel_offset r4, 0 + .cfi_rel_offset r5, 4 strd r6, r7, [sp] + .cfi_rel_offset r6, 8 + .cfi_rel_offset r7, 12 mvn r6, #0 /* all F */ mov r7, #0 /* all 0 */ .endm /* init */ @@ -165,6 +171,7 @@ ENTRY(strcmp) #endif /* not __ARMEB__ */ .endm /* setup_return */ + .cfi_startproc pld [r0, #0] pld [r1, #0] @@ -348,7 +355,13 @@ do_return: /* Restore temporaries early, before computing the return value. */ ldrd r6, r7, [sp] ldrd r4, r5, [sp, #8] + .pad #-16 adds sp, sp, #16 + .cfi_def_cfa_offset 0 + .cfi_restore r4 + .cfi_restore r5 + .cfi_restore r6 + .cfi_restore r7 /* There is a zero or a different byte between r1 and r2. */ /* r0 contains a mask of all-zero bytes in r1. */ @@ -374,4 +387,5 @@ compute_return_value: it ls sbcls r0, r0, r0 bx lr + .cfi_endproc END(strcmp) diff --git a/libc/arch-arm/cortex-a9/bionic/__strcat_chk.S b/libc/arch-arm/cortex-a9/bionic/__strcat_chk.S index 3f866361d..1329c1612 100644 --- a/libc/arch-arm/cortex-a9/bionic/__strcat_chk.S +++ b/libc/arch-arm/cortex-a9/bionic/__strcat_chk.S @@ -40,10 +40,12 @@ ENTRY(__strcat_chk) .cfi_startproc pld [r0, #0] + .save {r0, lr} push {r0, lr} .cfi_def_cfa_offset 8 .cfi_rel_offset r0, 0 .cfi_rel_offset lr, 4 + .save {r4, r5} push {r4, r5} .cfi_adjust_cfa_offset 8 .cfi_rel_offset r4, 0 @@ -188,6 +190,7 @@ ENTRY(__strcat_chk) pld [r1, #64] mov r2, r4 add r0, r0, r3 + .pad #-8 pop {r4, r5} .cfi_adjust_cfa_offset -8 .cfi_restore r4 diff --git a/libc/arch-arm/cortex-a9/bionic/__strcpy_chk.S b/libc/arch-arm/cortex-a9/bionic/__strcpy_chk.S index 787b0578a..b697c1f70 100644 --- a/libc/arch-arm/cortex-a9/bionic/__strcpy_chk.S +++ b/libc/arch-arm/cortex-a9/bionic/__strcpy_chk.S @@ -39,6 +39,7 @@ ENTRY(__strcpy_chk) .cfi_startproc pld [r0, #0] + .save {r0, lr} push {r0, lr} .cfi_def_cfa_offset 8 .cfi_rel_offset r0, 0 diff --git a/libc/arch-arm/cortex-a9/bionic/memcpy.S b/libc/arch-arm/cortex-a9/bionic/memcpy.S index e7beb25b3..ab3b0a006 100644 --- a/libc/arch-arm/cortex-a9/bionic/memcpy.S +++ b/libc/arch-arm/cortex-a9/bionic/memcpy.S @@ -52,6 +52,7 @@ END(__memcpy_chk) ENTRY(memcpy) .cfi_startproc pld [r1, #0] + .save {r0, lr} stmfd sp!, {r0, lr} .cfi_def_cfa_offset 8 .cfi_rel_offset r0, 0 diff --git a/libc/arch-arm/cortex-a9/bionic/memcpy_base.S b/libc/arch-arm/cortex-a9/bionic/memcpy_base.S index 46b5a9361..088d29e35 100644 --- a/libc/arch-arm/cortex-a9/bionic/memcpy_base.S +++ b/libc/arch-arm/cortex-a9/bionic/memcpy_base.S @@ -133,7 +133,14 @@ bx lr 11: /* Simple arm-only copy loop to handle aligned copy operations */ - stmfd sp!, {r4, r5, r6, r7, r8} + .save {r4-r8} + stmfd sp!, {r4-r8} + .cfi_def_cfa_offset 20 + .cfi_rel_offset r4, 0 + .cfi_rel_offset r5, 4 + .cfi_rel_offset r6, 8 + .cfi_rel_offset r7, 12 + .cfi_rel_offset r8, 16 pld [r1, #(32 * 4)] /* Check alignment */ diff --git a/libc/arch-arm/cortex-a9/bionic/memset.S b/libc/arch-arm/cortex-a9/bionic/memset.S index bc25a3e2e..a7876fb91 100644 --- a/libc/arch-arm/cortex-a9/bionic/memset.S +++ b/libc/arch-arm/cortex-a9/bionic/memset.S @@ -43,6 +43,7 @@ ENTRY(__memset_chk) bls .L_done // Preserve lr for backtrace. + .save {lr} push {lr} .cfi_def_cfa_offset 4 .cfi_rel_offset lr, 0 @@ -77,6 +78,7 @@ ENTRY(memset) cmp r2, #132 bhi 11f + .save {r0} stmfd sp!, {r0} .cfi_def_cfa_offset 4 .cfi_rel_offset r0, 0 @@ -117,6 +119,7 @@ ENTRY(memset) * offset = (4-(src&3))&3 = -src & 3 */ + .save {r0, r4-r7, lr} stmfd sp!, {r0, r4-r7, lr} .cfi_def_cfa_offset 24 .cfi_rel_offset r0, 0 diff --git a/libc/arch-arm/cortex-a9/bionic/strcmp.S b/libc/arch-arm/cortex-a9/bionic/strcmp.S index 9597d0d53..a84c047d5 100644 --- a/libc/arch-arm/cortex-a9/bionic/strcmp.S +++ b/libc/arch-arm/cortex-a9/bionic/strcmp.S @@ -122,9 +122,15 @@ ENTRY(strcmp) .macro init /* Macro to save temporary registers and prepare magic values. */ + .save {r4-r7} subs sp, sp, #16 + .cfi_def_cfa_offset 16 strd r4, r5, [sp, #8] + .cfi_rel_offset r4, 0 + .cfi_rel_offset r5, 4 strd r6, r7, [sp] + .cfi_rel_offset r6, 8 + .cfi_rel_offset r7, 12 mvn r6, #0 /* all F */ mov r7, #0 /* all 0 */ .endm /* init */ @@ -165,6 +171,7 @@ ENTRY(strcmp) #endif /* not __ARMEB__ */ .endm /* setup_return */ + .cfi_startproc pld [r0, #0] pld [r1, #0] @@ -334,7 +341,13 @@ do_return: /* Restore temporaries early, before computing the return value. */ ldrd r6, r7, [sp] ldrd r4, r5, [sp, #8] + .pad #-16 adds sp, sp, #16 + .cfi_def_cfa_offset 0 + .cfi_restore r4 + .cfi_restore r5 + .cfi_restore r6 + .cfi_restore r7 /* There is a zero or a different byte between r1 and r2. */ /* r0 contains a mask of all-zero bytes in r1. */ @@ -519,7 +532,13 @@ strcmp_unaligned: /* Restore registers and stack. */ ldrd r6, r7, [sp] ldrd r4, r5, [sp, #8] + .pad #-16 adds sp, sp, #16 + .cfi_def_cfa_offset 0 + .cfi_restore r4 + .cfi_restore r5 + .cfi_restore r6 + .cfi_restore r7 bx lr @@ -538,7 +557,14 @@ strcmp_unaligned: /* Restore registers and stack. */ ldrd r6, r7, [sp] ldrd r4, r5, [sp, #8] + .pad #-16 adds sp, sp, #16 + .cfi_def_cfa_offset 0 + .cfi_restore r4 + .cfi_restore r5 + .cfi_restore r6 + .cfi_restore r7 bx lr + .cfi_endproc END(strcmp) diff --git a/libc/arch-arm/krait/bionic/__strcat_chk.S b/libc/arch-arm/krait/bionic/__strcat_chk.S index 4516d3005..4b125c89c 100644 --- a/libc/arch-arm/krait/bionic/__strcat_chk.S +++ b/libc/arch-arm/krait/bionic/__strcat_chk.S @@ -40,10 +40,12 @@ ENTRY(__strcat_chk) .cfi_startproc pld [r0, #0] + .save {r0, lr} push {r0, lr} .cfi_def_cfa_offset 8 .cfi_rel_offset r0, 0 .cfi_rel_offset lr, 4 + .save {r4, r5} push {r4, r5} .cfi_adjust_cfa_offset 8 .cfi_rel_offset r4, 0 @@ -185,6 +187,7 @@ ENTRY(__strcat_chk) pld [r1, #64] mov r2, r4 add r0, r0, r3 + .pad #-8 pop {r4, r5} .cfi_adjust_cfa_offset -8 .cfi_restore r4 diff --git a/libc/arch-arm/krait/bionic/__strcpy_chk.S b/libc/arch-arm/krait/bionic/__strcpy_chk.S index c57268c46..d5e1db610 100644 --- a/libc/arch-arm/krait/bionic/__strcpy_chk.S +++ b/libc/arch-arm/krait/bionic/__strcpy_chk.S @@ -39,6 +39,7 @@ ENTRY(__strcpy_chk) .cfi_startproc pld [r0, #0] + .save {r0, lr} push {r0, lr} .cfi_def_cfa_offset 8 .cfi_rel_offset r0, 0 diff --git a/libc/arch-arm/krait/bionic/memcpy.S b/libc/arch-arm/krait/bionic/memcpy.S index 75b239587..3b4fca476 100644 --- a/libc/arch-arm/krait/bionic/memcpy.S +++ b/libc/arch-arm/krait/bionic/memcpy.S @@ -55,6 +55,7 @@ END(__memcpy_chk) ENTRY(memcpy) .cfi_startproc pld [r1, #64] + .save {r0, lr} stmfd sp!, {r0, lr} .cfi_def_cfa_offset 8 .cfi_rel_offset r0, 0 @@ -64,9 +65,11 @@ ENTRY(memcpy) .cfi_endproc END(memcpy) + .fnstart .cfi_startproc __memcpy_chk_fail: // Preserve lr for backtrace. + .save {lr} push {lr} .cfi_def_cfa_offset 4 .cfi_rel_offset lr, 0 @@ -81,6 +84,7 @@ error_code: error_message: .word error_string-(1b+4) .cfi_endproc + .fnend .data error_string: diff --git a/libc/arch-arm/krait/bionic/memset.S b/libc/arch-arm/krait/bionic/memset.S index 15661320b..005dfd8cf 100644 --- a/libc/arch-arm/krait/bionic/memset.S +++ b/libc/arch-arm/krait/bionic/memset.S @@ -44,6 +44,7 @@ ENTRY(__memset_chk) bls .L_done // Preserve lr for backtrace. + .save {lr} push {lr} .cfi_def_cfa_offset 4 .cfi_rel_offset lr, 0 @@ -74,6 +75,7 @@ END(bzero) /* memset() returns its first argument. */ ENTRY(memset) .cfi_startproc + .save {r0} stmfd sp!, {r0} .cfi_def_cfa_offset 4 .cfi_rel_offset r0, 0 diff --git a/libc/arch-arm/krait/bionic/strcmp.S b/libc/arch-arm/krait/bionic/strcmp.S index d614b9db0..f26aaf14c 100644 --- a/libc/arch-arm/krait/bionic/strcmp.S +++ b/libc/arch-arm/krait/bionic/strcmp.S @@ -122,9 +122,15 @@ ENTRY(strcmp) .macro init /* Macro to save temporary registers and prepare magic values. */ + .save {r4-r7} subs sp, sp, #16 + .cfi_def_cfa_offset 16 strd r4, r5, [sp, #8] + .cfi_rel_offset r4, 0 + .cfi_rel_offset r5, 4 strd r6, r7, [sp] + .cfi_rel_offset r6, 8 + .cfi_rel_offset r7, 12 mvn r6, #0 /* all F */ mov r7, #0 /* all 0 */ .endm /* init */ @@ -165,6 +171,7 @@ ENTRY(strcmp) #endif /* not __ARMEB__ */ .endm /* setup_return */ + .cfi_startproc pld [r0, #0] pld [r1, #0] @@ -347,7 +354,13 @@ do_return: /* Restore temporaries early, before computing the return value. */ ldrd r6, r7, [sp] ldrd r4, r5, [sp, #8] + .pad #-16 adds sp, sp, #16 + .cfi_def_cfa_offset 0 + .cfi_restore r4 + .cfi_restore r5 + .cfi_restore r6 + .cfi_restore r7 /* There is a zero or a different byte between r1 and r2. */ /* r0 contains a mask of all-zero bytes in r1. */ @@ -452,7 +465,13 @@ miscmp_word_16: /* Restore registers and stack. */ ldrd r6, r7, [sp] ldrd r4, r5, [sp, #8] + .pad #-16 adds sp, sp, #16 + .cfi_def_cfa_offset 0 + .cfi_restore r4 + .cfi_restore r5 + .cfi_restore r6 + .cfi_restore r7 bx lr @@ -471,7 +490,14 @@ miscmp_word_16: /* Restore registers and stack. */ ldrd r6, r7, [sp] ldrd r4, r5, [sp, #8] + .pad #-16 adds sp, sp, #16 + .cfi_def_cfa_offset 0 + .cfi_restore r4 + .cfi_restore r5 + .cfi_restore r6 + .cfi_restore r7 bx lr + .cfi_endproc END(strcmp)