From 6f8933ee7b806ed757664856433e47e315c4019a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20Ter=C3=A4s?= Date: Fri, 11 Nov 2011 14:06:29 +0200 Subject: main/libc0.9.32: improve the stack unwinding fix should now work with all syscalls --- ...x-stack-unwinding-and-backtrace-informati.patch | 120 +++++++++++++++------ main/libc0.9.32/APKBUILD | 4 +- 2 files changed, 92 insertions(+), 32 deletions(-) (limited to 'main/libc0.9.32') diff --git a/main/libc0.9.32/0001-libc-x86-fix-stack-unwinding-and-backtrace-informati.patch b/main/libc0.9.32/0001-libc-x86-fix-stack-unwinding-and-backtrace-informati.patch index 87a1758523..62c1456949 100644 --- a/main/libc0.9.32/0001-libc-x86-fix-stack-unwinding-and-backtrace-informati.patch +++ b/main/libc0.9.32/0001-libc-x86-fix-stack-unwinding-and-backtrace-informati.patch @@ -1,7 +1,7 @@ -From 80db5b343bd44806881d400a8627cb526ffccee7 Mon Sep 17 00:00:00 2001 +From 5f72f80e7ea0e3429c28ff5de7ca88cdd95e8904 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20Ter=C3=A4s?= Date: Thu, 10 Nov 2011 09:36:44 +0200 -Subject: [PATCH] libc/x86: fix stack unwinding and backtrace information +Subject: [PATCHv2] libc/x86: fix stack unwinding and backtrace information MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @@ -11,6 +11,7 @@ for proper stack unwinding. This patch adds the CFI information to: * syscalls (so we get proper backtrace even for release builds) + the ebx hack was removed as it would complicate the CFI generation * new thread stub function (so the backtrace is clean for user created threads) @@ -25,13 +26,13 @@ signal return frame. Signed-off-by: Timo Teräs --- - libc/sysdeps/linux/i386/bits/syscalls.h | 13 +++++++++---- - libc/sysdeps/linux/i386/clone.S | 17 +++++++++++++++++ - libc/sysdeps/linux/i386/sigaction.c | 4 ++++ - 3 files changed, 30 insertions(+), 4 deletions(-) + libc/sysdeps/linux/i386/bits/syscalls.h | 82 +++---------------------------- + libc/sysdeps/linux/i386/clone.S | 17 ++++++ + libc/sysdeps/linux/i386/sigaction.c | 4 ++ + 3 files changed, 28 insertions(+), 75 deletions(-) diff --git a/libc/sysdeps/linux/i386/bits/syscalls.h b/libc/sysdeps/linux/i386/bits/syscalls.h -index eeafb3a..47d0b4c 100644 +index eeafb3a..1f60a44 100644 --- a/libc/sysdeps/linux/i386/bits/syscalls.h +++ b/libc/sysdeps/linux/i386/bits/syscalls.h @@ -13,6 +13,7 @@ @@ -42,25 +43,83 @@ index eeafb3a..47d0b4c 100644 #define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \ ({ \ -@@ -71,6 +72,8 @@ __asm__ ( - ".if 1 - \\name\n\t" /* if reg!=ebx... */ - ".if 2 - \\name\n\t" /* if reg can't be clobbered... */ - "pushl %ebx\n\t" /* save ebx on stack */ -+ CFI_ADJUST_CFA_OFFSET(4) "\n\t" -+ CFI_REL_OFFSET(ebx, 0) "\n\t" - ".else\n\t" - "xchgl \\reg, %ebx\n\t" /* else save ebx in reg, and load reg to ebx */ - ".endif\n\t" -@@ -89,6 +92,8 @@ __asm__ ( - ".if 1 - \\name\n\t" - ".if 2 - \\name\n\t" /* if reg can't be clobbered... */ - "popl %ebx\n\t" /* restore ebx from stack */ -+ CFI_ADJUST_CFA_OFFSET(-4) "\n\t" -+ CFI_RESTORE(ebx) "\n\t" - ".else\n\t" - "xchgl \\reg, %ebx\n\t" /* else restore ebx from reg */ - ".endif\n\t" -@@ -106,7 +111,7 @@ __asm__ ( +@@ -31,90 +32,21 @@ + + #if 1 /* defined __PIC__ || defined __pic__ */ + +-/* This code avoids pushing/popping ebx as much as possible. +- * I think the main reason was that older GCCs had problems +- * with proper saving/restoring of ebx if "b" constraint was used, +- * which was breaking -fPIC code really badly. +- * At least gcc 4.2.x seems to not need these tricks anymore, +- * but this code is still useful because it often avoids +- * using stack for saving ebx. +- * Keeping it unconditionally enabled for now. +- */ +- +-/* We need some help from the assembler to generate optimal code. +- * We define some macros here which later will be used. */ +-/* gcc>=4.6 with LTO need the same guards as IMA (a.k.a --combine) did. +- * See gcc.gnu.org/PR47577 */ +-/* FIXME: drop these b* macros! */ +- +-__asm__ ( +-#if defined __DOMULTI__ || __GNUC_PREREQ (4, 6) +- /* Protect against asm macro redefinition (happens in __DOMULTI__ mode). +- * Unfortunately, it ends up visible in .o files. */ +- ".ifndef _BITS_SYSCALLS_ASM\n\t" +- ".set _BITS_SYSCALLS_ASM,1\n\t" +-#endif +- ".L__X'%ebx = 1\n\t" +- ".L__X'%ecx = 2\n\t" +- ".L__X'%edx = 2\n\t" +- ".L__X'%eax = 3\n\t" +- ".L__X'%esi = 3\n\t" +- ".L__X'%edi = 3\n\t" +- ".L__X'%ebp = 3\n\t" +- ".L__X'%esp = 3\n\t" +- +- /* Loading param #1 (ebx) is done by loading it into +- * another register, and then performing bpushl+bmovl, +- * since we must preserve ebx */ +- +- ".macro bpushl name reg\n\t" +- ".if 1 - \\name\n\t" /* if reg!=ebx... */ +- ".if 2 - \\name\n\t" /* if reg can't be clobbered... */ +- "pushl %ebx\n\t" /* save ebx on stack */ +- ".else\n\t" +- "xchgl \\reg, %ebx\n\t" /* else save ebx in reg, and load reg to ebx */ +- ".endif\n\t" +- ".endif\n\t" +- ".endm\n\t" +- +- ".macro bmovl name reg\n\t" +- ".if 1 - \\name\n\t" +- ".if 2 - \\name\n\t" /* if reg can't be clobbered... */ +- "movl \\reg, %ebx\n\t" /* load reg to ebx */ +- ".endif\n\t" +- ".endif\n\t" +- ".endm\n\t" +- +- ".macro bpopl name reg\n\t" +- ".if 1 - \\name\n\t" +- ".if 2 - \\name\n\t" /* if reg can't be clobbered... */ +- "popl %ebx\n\t" /* restore ebx from stack */ +- ".else\n\t" +- "xchgl \\reg, %ebx\n\t" /* else restore ebx from reg */ +- ".endif\n\t" +- ".endif\n\t" +- ".endm\n\t" +- +-#if defined __DOMULTI__ || __GNUC_PREREQ (4, 6) +- ".endif\n\t" /* _BITS_SYSCALLS_ASM */ +-#endif +-); +- + #define LOADARGS_0 +-#define LOADARGS_1 "bpushl .L__X'%k2, %k2\n\t" "bmovl .L__X'%k2, %k2\n\t" ++#define LOADARGS_1 "push %%ebx\n\t" CFI_ADJUST_CFA_OFFSET(4) "\n\t" CFI_REL_OFFSET(ebx, 0) "\n\t" "movl %k2, %%ebx\n\t" + #define LOADARGS_2 LOADARGS_1 #define LOADARGS_3 LOADARGS_1 #define LOADARGS_4 LOADARGS_1 #define LOADARGS_5 LOADARGS_1 @@ -68,8 +127,9 @@ index eeafb3a..47d0b4c 100644 +#define LOADARGS_6 LOADARGS_1 "push %%ebp\n\t" CFI_ADJUST_CFA_OFFSET(4) "\n\t" CFI_REL_OFFSET(ebp, 0) "\n\t" "movl %7, %%ebp\n\t" #define RESTOREARGS_0 - #define RESTOREARGS_1 "bpopl .L__X'%k2, %k2\n\t" -@@ -114,7 +119,7 @@ __asm__ ( +-#define RESTOREARGS_1 "bpopl .L__X'%k2, %k2\n\t" ++#define RESTOREARGS_1 "pop %%ebx\n\t" CFI_ADJUST_CFA_OFFSET(-4) "\n\t" CFI_RESTORE(ebx) "\n\t" RESTOREARGS_0 + #define RESTOREARGS_2 RESTOREARGS_1 #define RESTOREARGS_3 RESTOREARGS_1 #define RESTOREARGS_4 RESTOREARGS_1 #define RESTOREARGS_5 RESTOREARGS_1 @@ -78,7 +138,7 @@ index eeafb3a..47d0b4c 100644 #define ASMFMT_0() /* "acdSD" constraint would work too, but "SD" would use esi/edi and cause -@@ -162,7 +167,7 @@ __asm__ ( +@@ -162,7 +94,7 @@ __asm__ ( #define LOADARGS_3 #define LOADARGS_4 #define LOADARGS_5 @@ -87,7 +147,7 @@ index eeafb3a..47d0b4c 100644 #define RESTOREARGS_0 #define RESTOREARGS_1 -@@ -170,7 +175,7 @@ __asm__ ( +@@ -170,7 +102,7 @@ __asm__ ( #define RESTOREARGS_3 #define RESTOREARGS_4 #define RESTOREARGS_5 diff --git a/main/libc0.9.32/APKBUILD b/main/libc0.9.32/APKBUILD index 54d69866cc..8fc93dadaa 100644 --- a/main/libc0.9.32/APKBUILD +++ b/main/libc0.9.32/APKBUILD @@ -4,7 +4,7 @@ pkgname=libc$_abiver _gitver= pkgver=0.9.32 _ver=${pkgver/_/-} -pkgrel=7 +pkgrel=8 pkgdesc="C library for developing embedded Linux systems" url=http://uclibc.org license="LGPL-2" @@ -145,7 +145,7 @@ b4fb68ad3d0e8331b1b40c30eb21dfdc 0002-stdlib-fix-arc4random-return-type-to-u_in 30f27fe51fdc4d121166ad2af18dfb8d 0001-malloc-standard-synchronize-on-fork.patch 2548d9f470c9a5b2c117ec3d6f35c105 0001-time-fix-parsing-of-tzdata-files-where-off_t-is-64-b.patch 9e1ffc8dae55f4489c770f284734804f 0001-getaddrinfo-allow-numeric-service-without-any-hints.patch -1aed313e59ca9bc15f87273d4b3d4fde 0001-libc-x86-fix-stack-unwinding-and-backtrace-informati.patch +e814d39ab0adab58d69396ac0b9acdea 0001-libc-x86-fix-stack-unwinding-and-backtrace-informati.patch 40e9c7f017cc81ee5b19ead000b9b6b7 libm-cabsf.patch 42416385763f7cd50775ed9bfaf2d59e libm-cexp.patch 7c47e9cb284b0da8df6ed2096b2c9c66 uclibc-ubacktrace-asneeded-fix.patch -- cgit v1.2.3