From patchwork Fri Apr 17 15:59:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Reutner-Fischer X-Patchwork-Id: 462144 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from fraxinus.osuosl.org (fraxinus.osuosl.org [140.211.166.137]) by ozlabs.org (Postfix) with ESMTP id 403441402B5 for ; Sat, 18 Apr 2015 01:59:22 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="verification failed; unprotected key" header.d=gmail.com header.i=@gmail.com header.b=iNHQ5QoV; dkim-adsp=none (unprotected policy); dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 7E6E9A19B5; Fri, 17 Apr 2015 15:59:21 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Tua3U_6BNktc; Fri, 17 Apr 2015 15:59:18 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id C26D3A17D9; Fri, 17 Apr 2015 15:59:18 +0000 (UTC) X-Original-To: uclibc@lists.busybox.net Delivered-To: uclibc@osuosl.org Received: from hemlock.osuosl.org (hemlock.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id B2DED1C21BC for ; Fri, 17 Apr 2015 15:59:17 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id AFA9A95644 for ; Fri, 17 Apr 2015 15:59:17 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id fLuGJuzs1I4F for ; Fri, 17 Apr 2015 15:59:16 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-lb0-f174.google.com (mail-lb0-f174.google.com [209.85.217.174]) by hemlock.osuosl.org (Postfix) with ESMTPS id E7476957D3 for ; Fri, 17 Apr 2015 15:59:15 +0000 (UTC) Received: by lbbqq2 with SMTP id qq2so86467931lbb.3 for ; Fri, 17 Apr 2015 08:59:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=+blMHYERthRTJUN53Z/81m5LN3zoqy0hULJ7jUnqtdE=; b=iNHQ5QoV+UMhuYunsJ7ugwiqIEX91qrw3x2dzWxgOsO/ICeRhloOc02TH0yQsDnZH4 RQkqzAVu5riG4KTxTdtCGGvJK0VaY33OGaSA+T8KoZQkg1Hq0yoPcm2VR90aK0w81AFZ 02o/IkZ2MB69y6L0nwNgyEZov3shYYY/Hh0W1P8snpuQIDhdIR5LrG5QG6lXFtiAK8EJ eAGv5gbGOacGCaoLz7wSK5IYwZEMtVFxB8Lll88iMxCAtO99jDfOQKszbcdu+bViWCUu ZeGrLZaetxw0eaRcBGMPgGt6yD+eheRIF+1xRZcXG9TEgwAn0icvJo1SFLk12WAwsU57 nXdg== MIME-Version: 1.0 X-Received: by 10.112.17.8 with SMTP id k8mr4872367lbd.28.1429286353795; Fri, 17 Apr 2015 08:59:13 -0700 (PDT) Received: by 10.152.45.3 with HTTP; Fri, 17 Apr 2015 08:59:13 -0700 (PDT) In-Reply-To: References: <55218D56.40306@meta.ua> <9D9C402F-4266-4E0D-AA9A-94D5B0897224@gmail.com> <5526BEB1.4070106@meta.ua> <552ECB57.5080001@meta.ua> <553007CF.6070906@meta.ua> <90692285-5C3D-43D8-89A2-4ABA43CA8123@gmail.com> Date: Fri, 17 Apr 2015 17:59:13 +0200 Message-ID: Subject: Re: is ARMv4T deprecated? From: Bernhard Reutner-Fischer To: Sergiy Kibrik Cc: uClibc , Will Newton X-BeenThere: uclibc@uclibc.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "Discussion and development of uClibc \(the embedded C library\)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: uclibc-bounces@uclibc.org Sender: "uClibc" On 17 April 2015 at 14:32, Bernhard Reutner-Fischer wrote: > So i read some documents yesterday night and this lead me to think > that the condition is just inverted? > Shouldn't it read more like: May i ask you to try the attached on your arm920t, please? This should of course be tested in pure ARM mode too.. TIA && cheers, diff --git a/include/libc-symbols.h b/include/libc-symbols.h index a87cde6..97463ac 100644 --- a/include/libc-symbols.h +++ b/include/libc-symbols.h @@ -111,7 +111,7 @@ /* Indirect stringification. Doing two levels allows * the parameter to be a macro itself. */ -#define __stringify_1(x) #x +#define __stringify_1(x...) #x #define __stringify(x) __stringify_1(x) #ifdef __UCLIBC_HAVE_ASM_SET_DIRECTIVE__ diff --git a/ldso/ldso/arm/dl-startup.h b/ldso/ldso/arm/dl-startup.h index df2c824..eb2a9a2 100644 --- a/ldso/ldso/arm/dl-startup.h +++ b/ldso/ldso/arm/dl-startup.h @@ -47,11 +47,7 @@ __asm__( " ldr r0, .L_FINI_PROC\n" " ldr r0, [sl, r0]\n" " @ jump to the user_s entry point\n" -#if defined(__USE_BX__) - " bx r6\n" -#else - " mov pc, r6\n" -#endif + " " __stringify(BX(r6)) "\n" ".L_GET_GOT:\n" " .word _GLOBAL_OFFSET_TABLE_ - .L_GOT_GOT - 4\n" ".L_SKIP_ARGS:\n" @@ -113,11 +109,7 @@ __asm__( " ldr r0, .L_FINI_PROC\n" " ldr r0, [r7, r0]\n" " @ jump to the user_s entry point\n" -#if defined(__USE_BX__) - " bx r6\n" -#else - " mov pc, r6\n" -#endif + " " __stringify(BX(r6)) "\n" "\n\n" ".L_GET_GOT:\n" " .word _GLOBAL_OFFSET_TABLE_ - .L_GOT_GOT - 4\n" diff --git a/ldso/ldso/arm/resolve.S b/ldso/ldso/arm/resolve.S index c1caf9a..7e0058e 100644 --- a/ldso/ldso/arm/resolve.S +++ b/ldso/ldso/arm/resolve.S @@ -90,12 +90,10 @@ * dl-startup.c). */ -#include +#include #include #include -#include - #define sl r10 #define fp r11 #define ip r12 @@ -114,8 +112,8 @@ _dl_linux_resolve: @ function must branch to the real function, and that expects @ r0-r3 and lr to be as they were before the whole PLT stuff - @ ip can be trashed. - @ This routine is called after pushing lr, so we must push an odd - @ number of words to keep the stack correctly aligned. + @ This routine is called after pushing lr, so we must push an odd + @ number of words to keep the stack correctly aligned. stmdb sp!, {r0, r1, r2, r3, r4} ldr r0, [lr, #-4] @ r0 : = [lr-4] (GOT_TABLE[1]) @@ -124,16 +122,12 @@ _dl_linux_resolve: @ ~x = -x-1, therefore ~(r1>>2) = (-((lr-ip)>>2)-1) @ = - ((lr-ip)/4) - 1 = (ip - lr - 4)/4, as required - bl _dl_linux_resolver + bl _dl_linux_resolver - mov ip, r0 + mov ip, r0 ldmia sp!, {r0, r1, r2, r3, r4, lr} -#if defined(__USE_BX__) - bx ip -#else - mov pc,ip -#endif + BX(ip) #else @ In the thumb case _dl_linux_resolver is thumb. If a bl is used @ from arm code the linker will insert a stub call which, with diff --git a/libc/string/arm/_memcpy.S b/libc/string/arm/_memcpy.S index c59f5b8..2999e8e 100644 --- a/libc/string/arm/_memcpy.S +++ b/libc/string/arm/_memcpy.S @@ -111,11 +111,7 @@ _memcpy: bcc .Lmemcpy_backwards IT(t, eq) /* Quick abort for src=dst */ -#if defined(__USE_BX__) - bxeq lr -#else - moveq pc, lr -#endif + BXC(eq, lr) stmdb sp!, {r0, lr} /* memcpy() returns dest addr */ subs r2, r2, #4 blt .Lmemcpy_fl4 /* less than 4 bytes */ @@ -455,11 +451,7 @@ _memcpy: /* less than 4 bytes to go */ adds r2, r2, #4 IT(t, eq) -#if defined(__USE_BX__) - bxeq lr -#else - moveq pc, lr /* done */ -#endif + BXC(eq, lr) /* done */ /* copy the crud byte at a time */ cmp r2, #2 ldrb r3, [r1, #-1]! @@ -477,11 +469,7 @@ _memcpy: ldrgtb r3, [r1, #-1]! strgtb r3, [r0, #-1]! #endif -#if defined(__USE_BX__) - bx lr -#else - mov pc, lr -#endif + BX(lr) /* erg - unaligned destination */ .Lmemcpy_bdestul: cmp r12, #2 diff --git a/libc/string/arm/memcmp.S b/libc/string/arm/memcmp.S index 9f78415..5b9473c 100644 --- a/libc/string/arm/memcmp.S +++ b/libc/string/arm/memcmp.S @@ -67,11 +67,7 @@ memcmp: subs r2, r2, #1 IT(tt, mi) movmi r0, #0 -#if defined(__USE_BX__) - bxmi lr -#else - movmi pc, lr -#endif + BXC(mi, lr) /* ip == last src address to compare */ add ip, r0, r2 1: @@ -82,11 +78,7 @@ memcmp: cmpcs r2, r3 beq 1b sub r0, r2, r3 -#if defined(__USE_BX__) - bx lr -#else - mov pc, lr -#endif + BX(lr) #endif .size memcmp,.-memcmp diff --git a/libc/string/arm/memset.S b/libc/string/arm/memset.S index 8ddc47e..2be4850 100644 --- a/libc/string/arm/memset.S +++ b/libc/string/arm/memset.S @@ -17,7 +17,6 @@ . */ #include -#include #include #include @@ -109,11 +108,7 @@ memset: 2: movs a3, a3 @ anything left? IT(t, eq) -#if defined(__USE_BX__) - bxeq lr -#else - moveq pc, lr @ nope -#endif + BXC(eq, lr) @ nope #if defined (__thumb2__) 1: strb a2, [a4], #1 @@ -131,11 +126,7 @@ memset: strb a2, [a4], $1 strb a2, [a4], $1 strb a2, [a4], $1 -#if defined(__USE_BX__) - bx lr -#else - mov pc, lr -#endif + BX(lr) #endif #endif diff --git a/libc/string/arm/strcmp.S b/libc/string/arm/strcmp.S index 8b77ab0..81416a9 100644 --- a/libc/string/arm/strcmp.S +++ b/libc/string/arm/strcmp.S @@ -63,11 +63,7 @@ strcmp: cmpcs r2, r3 beq 1b sub r0, r2, r3 -#if defined(__USE_BX__) - bx lr -#else - mov pc, lr -#endif + BX(lr) #endif .size strcmp,.-strcmp diff --git a/libc/string/arm/strlen.S b/libc/string/arm/strlen.S index 0e7737e..9995d76 100644 --- a/libc/string/arm/strlen.S +++ b/libc/string/arm/strlen.S @@ -18,7 +18,6 @@ #include #include -#include #include #include @@ -99,11 +98,7 @@ Llastword: @ drop through to here once we find a IT(t, ne) addne r0, r0, $1 @ must be zero) #endif -#if defined(__USE_BX__) - bx lr -#else - mov pc,lr -#endif + BX(lr) #endif .size strlen,.-strlen diff --git a/libc/sysdeps/linux/arm/__longjmp.S b/libc/sysdeps/linux/arm/__longjmp.S index 853b906..58ae8ab 100644 --- a/libc/sysdeps/linux/arm/__longjmp.S +++ b/libc/sysdeps/linux/arm/__longjmp.S @@ -98,12 +98,7 @@ __longjmp: ldcl p1, cr14, [r12], #8 ldcl p1, cr15, [r12], #8 #endif - -#if defined(__USE_BX__) - bx lr -#else - mov pc, lr -#endif + BX(lr) #endif .size __longjmp,.-__longjmp diff --git a/libc/sysdeps/linux/arm/bits/arm_asm.h b/libc/sysdeps/linux/arm/bits/arm_asm.h index 04664b3..898a78b 100644 --- a/libc/sysdeps/linux/arm/bits/arm_asm.h +++ b/libc/sysdeps/linux/arm/bits/arm_asm.h @@ -13,12 +13,12 @@ unified assembly syntax. */ #define IT(t, cond) /* Code to return from a thumb function stub. */ -#ifdef __ARM_ARCH_4T__ -#define POP_RET pop {r2, pc} -#else -#define POP_RET pop {r2, r3}; bx r3 -#endif -#endif +# if defined __ARM_ARCH_4T__ && defined __THUMB_INTERWORK__ +# define POP_RET pop {r2, r3}; bx r3 +# else +# define POP_RET pop {r2, pc} +# endif +#endif /* __thumb2__ */ #if defined(__ARM_ARCH_6M__) /* Force arm mode to flush out errors on M profile cores. */ diff --git a/libc/sysdeps/linux/arm/bits/arm_bx.h b/libc/sysdeps/linux/arm/bits/arm_bx.h index 321490e..2c29089 100644 --- a/libc/sysdeps/linux/arm/bits/arm_bx.h +++ b/libc/sysdeps/linux/arm/bits/arm_bx.h @@ -24,11 +24,17 @@ #endif /* features.h not yet included */ #if defined(__USE_BX__) -# if ( defined (__ARM_ARCH_2__) || defined (__ARM_ARCH_3__) \ - || defined (__ARM_ARCH_3M__) || defined (__ARM_ARCH_4__) \ - ) +# if (__ARM_ARCH <= 4 && !defined __ARM_ARCH_4T__) # error Use of BX was requested, but is not available on the target processor. # endif /* ARCH level */ #endif /* __USE_BX__ */ +#if defined(__USE_BX__) && (__ARM_ARCH > 4 || (__ARM_ARCH == 4 && defined __ARM_ARCH_4T__)) +# define BX(reg) bx reg +# define BXC(cond, reg) bx##cond reg +#else +# define BX(reg) mov pc, reg +# define BXC(cond, reg) mov##cond pc, reg +#endif + #endif /* _ARM_BX_H */ diff --git a/libc/sysdeps/linux/arm/bits/uClibc_arch_features.h b/libc/sysdeps/linux/arm/bits/uClibc_arch_features.h index b01d79c..e85aa52 100644 --- a/libc/sysdeps/linux/arm/bits/uClibc_arch_features.h +++ b/libc/sysdeps/linux/arm/bits/uClibc_arch_features.h @@ -48,6 +48,32 @@ /* only weird assemblers generally need this */ #undef __UCLIBC_ASM_LINE_SEP__ + +/* The __ARM_ARCH define is provided by gcc 4.8. Construct it otherwise. */ +#ifndef __ARM_ARCH +# ifdef __ARM_ARCH_2__ +# define __ARM_ARCH 2 +# elif defined (__ARM_ARCH_3__) || defined (__ARM_ARCH_3M__) +# define __ARM_ARCH 3 +# elif defined (__ARM_ARCH_4__) || defined (__ARM_ARCH_4T__) +# define __ARM_ARCH 4 +# elif defined (__ARM_ARCH_5__) || defined (__ARM_ARCH_5E__) \ + || defined(__ARM_ARCH_5T__) || defined(__ARM_ARCH_5TE__) \ + || defined(__ARM_ARCH_5TEJ__) +# define __ARM_ARCH 5 +# elif defined (__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) \ + || defined (__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) \ + || defined (__ARM_ARCH_6K__) || defined(__ARM_ARCH_6T2__) +# define __ARM_ARCH 6 +# elif defined (__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) \ + || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) \ + || defined(__ARM_ARCH_7EM__) +# define __ARM_ARCH 7 +# else +# error unknown arm architecture +# endif +#endif + #ifdef __GNUC__ # define __need_uClibc_config_h # include diff --git a/libc/sysdeps/linux/arm/clone.S b/libc/sysdeps/linux/arm/clone.S index 03cd10e..63eca31 100644 --- a/libc/sysdeps/linux/arm/clone.S +++ b/libc/sysdeps/linux/arm/clone.S @@ -115,11 +115,7 @@ __clone: ldmnefd sp!, {r4} blt __error IT(t, ne) -#if defined(__USE_BX__) - bxne lr -#else - movne pc, lr -#endif + BXC(ne, lr) @ pick the function arg and call address off the stack and execute ldr r0, [sp, #4] diff --git a/libc/sysdeps/linux/arm/mmap64.S b/libc/sysdeps/linux/arm/mmap64.S index f4c491a..c9f2bd2 100644 --- a/libc/sysdeps/linux/arm/mmap64.S +++ b/libc/sysdeps/linux/arm/mmap64.S @@ -92,11 +92,7 @@ mmap64: cmn r0, $4096 ldmfd sp!, {r4, r5} IT(t, cc) -#if defined(__USE_BX__) - bxcc lr -#else - movcc pc, lr -#endif + BXC(cc, lr) b __syscall_error .Linval: mov r0, $-EINVAL diff --git a/libc/sysdeps/linux/arm/syscall-eabi.S b/libc/sysdeps/linux/arm/syscall-eabi.S index 005cfe3..534c6e9 100644 --- a/libc/sysdeps/linux/arm/syscall-eabi.S +++ b/libc/sysdeps/linux/arm/syscall-eabi.S @@ -15,7 +15,7 @@ License along with the GNU C Library; if not, see . */ -#include +#include #include #include @@ -62,11 +62,7 @@ syscall: ldmfd sp!, {r4, r5, r6, r7} cmn r0, #4096 IT(t, cc) -#if defined(__USE_BX__) - bxcc lr -#else - movcc pc, lr -#endif + BXC(cc, lr) b __syscall_error #endif diff --git a/libc/sysdeps/linux/arm/sysdep.h b/libc/sysdeps/linux/arm/sysdep.h index 64f4040..019dc37 100644 --- a/libc/sysdeps/linux/arm/sysdep.h +++ b/libc/sysdeps/linux/arm/sysdep.h @@ -21,7 +21,6 @@ #include #include - #include /* For Linux we can use the system call table in the header file /usr/include/asm/unistd.h @@ -50,17 +49,10 @@ #ifdef __APCS_32__ #define LOADREGS(cond, base, reglist...)\ ldm##cond base,reglist -#ifdef __USE_BX__ -#define RETINSTR(cond, reg) \ - bx##cond reg -#define DO_RET(_reg) \ - bx _reg -#else -#define RETINSTR(cond, reg) \ - mov##cond pc, reg +#define RETINSTR(cond, reg) \ + BXC(cond, reg) #define DO_RET(_reg) \ - mov pc, _reg -#endif + BX(_reg) #else /* APCS-26 */ #define LOADREGS(cond, base, reglist...) \ ldm##cond base,reglist^ diff --git a/libc/sysdeps/linux/arm/vfork.S b/libc/sysdeps/linux/arm/vfork.S index 99fb6cb..221a90c 100644 --- a/libc/sysdeps/linux/arm/vfork.S +++ b/libc/sysdeps/linux/arm/vfork.S @@ -74,11 +74,7 @@ __vfork: RESTORE_PID cmn r0, #4096 IT(t, cc) -#if defined(__USE_BX__) - bxcc lr -#else - movcc pc, lr -#endif + BXC(cc, lr) /* Check if vfork even exists. */ ldr r1, =-ENOSYS @@ -92,11 +88,7 @@ __vfork: /* Syscall worked. Return to child/parent */ IT(t, cc) -#if defined(__USE_BX__) - bxcc lr -#else - movcc pc, lr -#endif + BXC(cc, lr) __error: b __syscall_error