From patchwork Fri Jul 19 13:22:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Fedotov X-Patchwork-Id: 169248 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp3857849ilk; Fri, 19 Jul 2019 06:22:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqzfAVr/JqF4bq+aBRYSCVYInZJpIAJVMokeCoAKhHBHjtpYFb3zuRnXkF19pGREHUi3ksc2 X-Received: by 2002:a17:90a:d58c:: with SMTP id v12mr56801172pju.7.1563542558262; Fri, 19 Jul 2019 06:22:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563542558; cv=none; d=google.com; s=arc-20160816; b=CmXpuVWPHGtODMBRkLDPwmv9baWgLsKox4BTTnYKQ37XzXp9jVQHClugXt66/PkHGK OkPlhlRjwVB5HEMPnpU6aEvq7OQ2K2OoK+t1RwDJie9Q5twtfAkwJFez2L7TeonJSu38 s1663gL378YbkBYMHtDmWR5qsX19GMlE1jn2JbYWzxO/lqtu4SNcB1IOP/1Tpzbfc9nq jOy48inaCnmJKrN3KJdD26VxPdhf8UMB2ze81jXEfVXrX/xlcp5qtKqdHC0lYtr3mh35 WG3NgQKLD/OPBCJg5BqFB7u3xNALq6ufwSI3JPowlNxQ6NJceB5wfso6VQ+AE5+Plobt BB2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature:delivered-to :sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature; bh=63yF6My/2p9CaUEybO20yNkzvC2zRaLIZMrARr27O0I=; b=LP+Lv6+Z1V2TSjyYdKEGf3XMP00hCDVaj/7bcr/2luwZZTZ3qOSaN6EFBR0cy9zq77 vmOhMSHTWXN6GVoZ41JOD5OmdU1FtNHO/F7j4I2+KyBMIdDVcR7Qu9vk3kCk7Hsyu/P0 q5+aYGCrJO63xklxMNiYGqPPPl/PPkK4kuqZUqB34XvnT0etE/TqYvi1I2hj02OHWbIV c+WmWhrxLhZ4Dp62GdjH1rdcE+SsBv1RHhy0sLXy4fPbfhdrTR6jHl/JvBKQ6f8Q9qoQ vAvXkDNCWPq1+STFQkVEVy2ug8cLsx9NA7j1kmTou0Fj2uVdt01PjmZdQQty7DqB6P+H qZ6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=G89LNKib; dkim=pass header.i=@gmail.com header.s=20161025 header.b=OUFm8vli; spf=pass (google.com: domain of newlib-return-17019-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="newlib-return-17019-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id n18si2204879plp.215.2019.07.19.06.22.37 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Jul 2019 06:22:38 -0700 (PDT) Received-SPF: pass (google.com: domain of newlib-return-17019-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=G89LNKib; dkim=pass header.i=@gmail.com header.s=20161025 header.b=OUFm8vli; spf=pass (google.com: domain of newlib-return-17019-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="newlib-return-17019-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id; q=dns; s= default; b=lxDkb8a5bwOx1Y8gVKlp+ntEH/q88ZE+tVwn3yckdrrwfnjyIbHjt 4gT8YuLo6rdX6mMOnvB9e+KD7hXXpR0ECXkDIZEcPzbt7JHa55qlxtZtbciUZC3z kaWvI1dJ2mTy0chew/575XnkJXuLePP1KEJtDeN9sV3cWQECCZ7RDA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id; s=default; bh=prqvdVr5Em31XRUIDfNKOn65CEc=; b=G89LNKibb8rz59hpDOmr+noOjdWG b5CkagGW8FCVr5TZmgrBq+d9LoiUURyje67ch8gZG7pm+VJC+St9hm+rFPT78a76 ReObKUNFm9u8zKAb7V4v0EpXHDQ9K+HnQTaTI5GYdIgD6leQUgNQ16GWItALg/8e hfINUiax1qRum94= Received: (qmail 64135 invoked by alias); 19 Jul 2019 13:22:29 -0000 Mailing-List: contact newlib-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: newlib-owner@sourceware.org Delivered-To: mailing list newlib@sourceware.org Received: (qmail 64127 invoked by uid 89); 19 Jul 2019 13:22:28 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=angel, cmpne, Angel X-HELO: mail-lf1-f42.google.com Received: from mail-lf1-f42.google.com (HELO mail-lf1-f42.google.com) (209.85.167.42) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 19 Jul 2019 13:22:25 +0000 Received: by mail-lf1-f42.google.com with SMTP id c19so21736811lfm.10 for ; Fri, 19 Jul 2019 06:22:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=63yF6My/2p9CaUEybO20yNkzvC2zRaLIZMrARr27O0I=; b=OUFm8vlirH8fmmBvpB33cJb46jkI+vcu2QmYAyWlSjDElOBqeAXx+els5Ja82WbA7o Mo7ZTlw8sCHcIGXeMYUKZ4hKF2tHJzs6AK574bncvXr9/ql1WJftyKCia0+N9OTbMwN9 4CYGVz+/WFR6JIic59gAcMRwXavBw8mOol8Jp6sD3GKkNGpnH/BsiMkRrbHy3J0JiW5d 9AeKnrc5dsDOiyrJ9PmRqVsUUsa/VnIb+6h051E5KONqILbechtVRVaRI3cb6ZdocLp9 pxi4XNnx67UNxmmvwD+Jtr4zvRG3UXP53zyGfU7fHbE9hjBjxJJAa6RhhMU4frQ3Ufvh SXSQ== Return-Path: Received: from af-ubuntu18-hyperv.cmtknet.ru (relay.cmtk.ru. [195.5.145.226]) by smtp.gmail.com with ESMTPSA id u17sm4552307lfq.69.2019.07.19.06.22.22 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 19 Jul 2019 06:22:22 -0700 (PDT) From: alfedotov@gmail.com To: Richard.Earnshaw@arm.com, newlib@sourceware.org Cc: Alexander Fedotov Subject: [PATCH v2 1/2] Align comments and spaces in libgloss/arm/crt0.S and newlib/libc/sys/arm/crt0.S to ease further code alignment. Date: Fri, 19 Jul 2019 08:22:17 -0500 Message-Id: <20190719132218.3108-1-alfedotov@gmail.com> From: Alexander Fedotov --- libgloss/arm/crt0.S | 137 +++++++++++++++++++------------------ newlib/libc/sys/arm/crt0.S | 20 +++--- 2 files changed, 80 insertions(+), 77 deletions(-) -- 2.17.1 diff --git a/libgloss/arm/crt0.S b/libgloss/arm/crt0.S index c708f63d8..f21add8bc 100644 --- a/libgloss/arm/crt0.S +++ b/libgloss/arm/crt0.S @@ -68,8 +68,10 @@ #endif .endm +/******************************************************************************* +* Main library startup code. +*******************************************************************************/ .align 0 - FUNC_START _mainCRTStartup FUNC_START _start #if defined(__ELF__) && !defined(__USING_SJLJ_EXCEPTIONS__) @@ -90,14 +92,14 @@ #endif #endif -/* Start by setting up a stack */ +/* Start by setting up a stack. */ #ifdef ARM_RDP_MONITOR - /* Issue Demon SWI to read stack info */ - swi SWI_GetEnv /* Returns command line in r0 */ - mov sp,r1 /* and the highest memory address in r1 */ + /* Issue Demon SWI to read stack info. */ + swi SWI_GetEnv /* Returns command line in r0. */ + mov sp,r1 /* and the highest memory address in r1. */ - /* stack limit is at end of data */ - /* allow slop for stack overflow handling and small frames */ + /* Stack limit is at end of data. */ + /* Allow slop for stack overflow handling and small frames. */ #ifdef THUMB1_ONLY ldr r0, .LC2 adds r0, #128 @@ -109,19 +111,19 @@ #endif #else #ifdef ARM_RDI_MONITOR - /* Issue Angel SWI to read stack info */ + /* Issue Angel SWI to read stack info. */ movs r0, #AngelSWI_Reason_HeapInfo - adr r1, .LC0 /* point at ptr to 4 words to receive data */ + adr r1, .LC0 /* Point at ptr to 4 words to receive data. */ #ifdef THUMB_VXM bkpt AngelSWI #elif defined(__thumb2__) - /* We are in thumb mode for startup on armv7 architectures. */ + /* We are in thumb mode for startup on armv7 architectures. */ AngelSWIAsm (AngelSWI) #else - /* We are always in ARM mode for startup on pre armv7 archs. */ + /* We are always in ARM mode for startup on pre armv7 archs. */ AngelSWIAsm (AngelSWI_ARM) #endif - ldr r0, .LC0 /* point at values read */ + ldr r0, .LC0 /* Point at values read. */ /* Set __heap_limit. */ ldr r1, [r0, #4] @@ -148,14 +150,15 @@ to skip setting sp/sl to 0 here. - Considering M-profile processors, We might want to initialize sp by the first entry of vector table and return 0 to SYS_HEAPINFO - semihosting call, which will be skipped here. */ + semihosting call, which will be skipped here. */ cmp r1, #0 beq .LC26 mov sp, r1 .LC26: cmp r2, #0 beq .LC27 - /* allow slop for stack overflow handling and small frames */ + + /* Allow slop for stack overflow handling and small frames. */ #ifdef THUMB1_ONLY adds r2, #128 adds r2, #128 @@ -163,9 +166,10 @@ #else add sl, r2, #256 #endif + .LC27: #else - /* Set up the stack pointer to a fixed value */ + /* Set up the stack pointer to a fixed value. */ /* Changes by toralf: - Allow linker script to provide stack via __stack symbol - see defintion of .Lstack @@ -175,7 +179,7 @@ Loosely based on init.s from ARM/Motorola example code. Note: Mode switch via CPSR is not allowed once in non-privileged mode, so we take care not to enter "User" to set up its sp, - and also skip most operations if already in that mode. */ + and also skip most operations if already in that mode. */ ldr r3, .Lstack cmp r3, #0 @@ -192,42 +196,42 @@ /* Note: This 'mov' is essential when starting in User, and ensures we always get *some* sp value for the initial mode, even if we have somehow missed it below (in which case it gets the same - value as FIQ - not ideal, but better than nothing.) */ + value as FIQ - not ideal, but better than nothing). */ mov sp, r3 #ifdef PREFER_THUMB /* XXX Fill in stack assignments for interrupt modes. */ #else mrs r2, CPSR - tst r2, #0x0F /* Test mode bits - in User of all are 0 */ - beq .LC23 /* "eq" means r2 AND #0x0F is 0 */ - msr CPSR_c, #0xD1 /* FIRQ mode, interrupts disabled */ + tst r2, #0x0F /* Test mode bits - in User of all are 0. */ + beq .LC23 /* "eq" means r2 AND #0x0F is 0. */ + msr CPSR_c, #0xD1 /* FIRQ mode, interrupts disabled. */ mov sp, r3 - sub sl, sp, #0x1000 /* This mode also has its own sl (see below) */ + sub sl, sp, #0x1000 /* This mode also has its own sl (see below). */ mov r3, sl - msr CPSR_c, #0xD7 /* Abort mode, interrupts disabled */ + msr CPSR_c, #0xD7 /* Abort mode, interrupts disabled. */ mov sp, r3 sub r3, r3, #0x1000 - msr CPSR_c, #0xDB /* Undefined mode, interrupts disabled */ + msr CPSR_c, #0xDB /* Undefined mode, interrupts disabled. */ mov sp, r3 sub r3, r3, #0x1000 - msr CPSR_c, #0xD2 /* IRQ mode, interrupts disabled */ + msr CPSR_c, #0xD2 /* IRQ mode, interrupts disabled. */ mov sp, r3 sub r3, r3, #0x2000 - msr CPSR_c, #0xD3 /* Supervisory mode, interrupts disabled */ + msr CPSR_c, #0xD3 /* Supervisory mode, interrupts disabled. */ mov sp, r3 - sub r3, r3, #0x8000 /* Min size 32k */ - bic r3, r3, #0x00FF /* Align with current 64k block */ + sub r3, r3, #0x8000 /* Min size 32k. */ + bic r3, r3, #0x00FF /* Align with current 64k block. */ bic r3, r3, #0xFF00 str r3, [r3, #-4] /* Move value into user mode sp without */ - ldmdb r3, {sp}^ /* changing modes, via '^' form of ldm */ + ldmdb r3, {sp}^ /* changing modes, via '^' form of ldm. */ orr r2, r2, #0xC0 /* Back to original mode, presumably SVC, */ - msr CPSR_c, r2 /* with FIQ/IRQ disable bits forced to 1 */ + msr CPSR_c, r2 /* with FIQ/IRQ disable bits forced to 1. */ #endif .LC23: /* Setup a default stack-limit in-case the code has been @@ -243,24 +247,24 @@ subs r2, r3, r2 mov sl, r2 #else - sub sl, r3, #64 << 10 /* Still assumes 256bytes below sl */ + sub sl, r3, #64 << 10 /* Still assumes 256bytes below sl. */ #endif #endif #endif /* Zero the memory in the .bss section. */ - movs a2, #0 /* Second arg: fill value */ - mov fp, a2 /* Null frame pointer */ - mov r7, a2 /* Null frame pointer for Thumb */ + movs a2, #0 /* Second arg: fill value. */ + mov fp, a2 /* Null frame pointer. */ + mov r7, a2 /* Null frame pointer for Thumb. */ - ldr a1, .LC1 /* First arg: start of memory block */ + ldr a1, .LC1 /* First arg: start of memory block. */ ldr a3, .LC2 - subs a3, a3, a1 /* Third arg: length of block */ + subs a3, a3, a1 /* Third arg: length of block. */ #if __thumb__ && !defined(PREFER_THUMB) - /* Enter Thumb mode.... */ - add a4, pc, #1 /* Get the address of the Thumb block */ - bx a4 /* Go there and start Thumb decoding */ + /* Enter Thumb mode... */ + add a4, pc, #1 /* Get the address of the Thumb block. */ + bx a4 /* Go there and start Thumb decoding. */ .code 16 .global __change_mode @@ -271,9 +275,8 @@ __change_mode: bl FUNCTION (memset) #if !defined (ARM_RDP_MONITOR) && !defined (ARM_RDI_MONITOR) /* Changes by toralf: Taken from libgloss/m68k/crt0.S - * initialize target specific stuff. Only execute these - * functions it they exist. - */ + initialize target specific stuff. Only execute these + functions it they exist. */ ldr r3, .Lhwinit cmp r3, #0 beq .LC24 @@ -285,24 +288,24 @@ __change_mode: indirect_call r3 .LC25: - movs r0, #0 /* no arguments */ - movs r1, #0 /* no argv either */ + movs r0, #0 /* No arguments. */ + movs r1, #0 /* No argv either. */ #else - /* Need to set up standard file handles */ + /* Need to set up standard file handles. */ bl FUNCTION (initialise_monitor_handles) #ifdef ARM_RDP_MONITOR - swi SWI_GetEnv /* sets r0 to point to the command line */ + swi SWI_GetEnv /* Sets r0 to point to the command line. */ movs r1, r0 #else movs r0, #AngelSWI_Reason_GetCmdLine - ldr r1, .LC30 /* Space for command line */ + ldr r1, .LC30 /* Space for command line. */ AngelSWIAsm (AngelSWI) ldr r1, .LC30 ldr r1, [r1] #endif - /* Parse string at r1 */ - movs r0, #0 /* count of arguments so far */ + /* Parse string at r1. */ + movs r0, #0 /* Count of arguments so far. */ /* Push a NULL argument onto the end of the list. */ #ifdef __thumb__ push {r0} @@ -310,7 +313,7 @@ __change_mode: stmfd sp!, {r0} #endif .LC10: -/* Skip leading blanks */ +/* Skip leading blanks. */ #ifdef __thumb__ ldrb r3, [r1] adds r1, #1 @@ -322,7 +325,7 @@ __change_mode: cmp r3, #' ' beq .LC10 -/* See whether we are scanning a string */ +/* See whether we are scanning a string. */ cmp r3, #'"' #ifdef __thumb__ beq .LC20 @@ -333,17 +336,17 @@ __change_mode: b .LC22 .LC21: - movs r2, #' ' /* terminator type */ - subs r1, r1, #1 /* adjust back to point at start char */ + movs r2, #' ' /* Terminator type. */ + subs r1, r1, #1 /* Adjust back to point at start char. */ .LC22: #else cmpne r3, #'\'' moveq r2, r3 - movne r2, #' ' /* terminator type */ - subne r1, r1, #1 /* adjust back to point at start char */ + movne r2, #' ' /* Terminator type. */ + subne r1, r1, #1 /* Adjust back to point at start char. */ #endif -/* Stack a pointer to the current argument */ +/* Stack a pointer to the current argument. */ #ifdef __thumb__ push {r1} #else @@ -359,16 +362,16 @@ __change_mode: #endif cmp r3, #0 beq .LC12 - cmp r2, r3 /* reached terminator? */ + cmp r2, r3 /* Reached terminator ? */ bne .LC11 movs r2, #0 subs r3, r1, #1 - strb r2, [r3] /* terminate the arg string */ + strb r2, [r3] /* Terminate the arg string. */ b .LC10 .LC12: - mov r1, sp /* point at stacked arg pointers */ - /* We've now got the stacked args in order reverse the */ + mov r1, sp /* Point at stacked arg pointers. */ + /* We've now got the stacked args in order, reverse them. */ #ifdef __thumb__ movs r2, r0 lsls r2, #2 @@ -390,10 +393,10 @@ __change_mode: bics r4, r5 mov sp, r4 #else - add r2, sp, r0, LSL #2 /* End of args */ - mov r3, sp /* Start of args */ + add r2, sp, r0, LSL #2 /* End of args. */ + mov r3, sp /* Start of args. */ .LC13: cmp r2, r3 - ldrhi r4,[r2, #-4] /* Reverse ends of list */ + ldrhi r4,[r2, #-4] /* Reverse ends of list. */ ldrhi r5, [r3] strhi r5, [r2, #-4]! strhi r4, [r3], #4 @@ -431,7 +434,6 @@ __change_mode: #if __thumb__ && !defined(PREFER_THUMB) /* Come out of Thumb mode. This code should be redundant. */ - mov a4, pc bx a4 @@ -441,13 +443,12 @@ change_back: /* Halt the execution. This code should never be executed. */ /* With no debug monitor, this probably aborts (eventually). With a Demon debug monitor, this halts cleanly. - With an Angel debug monitor, this will report 'Unknown SWI'. */ + With an Angel debug monitor, this will report 'Unknown SWI'. */ swi SWI_Exit #endif /* For Thumb, constants must be after the code since only positive offsets are supported for PC relative addresses. */ - .align 0 .LC0: #ifdef ARM_RDI_MONITOR @@ -457,13 +458,13 @@ change_back: /* Changes by toralf: Provide alternative "stack" variable whose value may be defined externally; .Lstack will be used instead of .LC0 if it points to a non-0 value. Also set up references to "hooks" that - may be used by the application to provide additional init code. */ - + may be used by the application to provide additional init code. */ #ifdef __pe__ .word 0x800000 #else .word 0x80000 /* Top of RAM on the PIE board. */ #endif + .Lstack: .word __stack .Lhwinit: @@ -476,7 +477,7 @@ change_back: runtime (meaning "ignore setting") for the variables, when the user does not provide the symbols. (The linker uses a weak symbol if, and only if, a normal version of the same symbol isn't provided - e.g. by a linker script or another object file.) */ + e.g. by a linker script or another object file.) */ .weak __stack .weak FUNCTION (hardware_init_hook) diff --git a/newlib/libc/sys/arm/crt0.S b/newlib/libc/sys/arm/crt0.S index 8c9f7be38..3358d7014 100644 --- a/newlib/libc/sys/arm/crt0.S +++ b/newlib/libc/sys/arm/crt0.S @@ -50,13 +50,13 @@ .global \name .thumb_func \name: -.endm +.endm #else .code 32 .macro FUNC_START name - .global \name + .global \name \name: -.endm +.endm #endif .macro indirect_call reg @@ -68,8 +68,10 @@ #endif .endm +/******************************************************************************* +* Main library startup code. +*******************************************************************************/ .align 0 - FUNC_START _mainCRTStartup FUNC_START _start #if defined(__ELF__) && !defined(__USING_SJLJ_EXCEPTIONS__) @@ -399,7 +401,7 @@ __change_mode: bl FUNCTION (_init) movs r0, r4 movs r1, r5 -#endif +#endif bl FUNCTION (main) bl FUNCTION (exit) /* Should not return. */ @@ -415,12 +417,12 @@ change_back: /* Halt the execution. This code should never be executed. */ /* With no debug monitor, this probably aborts (eventually). With a Demon debug monitor, this halts cleanly. - With an Angel debug monitor, this will report 'Unknown SWI'. */ + With an Angel debug monitor, this will report 'Unknown SWI'. */ swi SWI_Exit #endif /* For Thumb, constants must be after the code since only - positive offsets are supported for PC relative addresses. */ + positive offsets are supported for PC relative addresses. */ .align 0 .LC0: #ifdef ARM_RDI_MONITOR @@ -430,7 +432,7 @@ change_back: /* Changes by toralf: Provide alternative "stack" variable whose value may be defined externally; .Lstack will be used instead of .LC0 if it points to a non-0 value. Also set up references to "hooks" that - may be used by the application to provide additional init code. */ + may be used by the application to provide additional init code. */ #ifdef __pe__ .word 0x800000 #else @@ -449,7 +451,7 @@ change_back: runtime (meaning "ignore setting") for the variables, when the user does not provide the symbols. (The linker uses a weak symbol if, and only if, a normal version of the same symbol isn't provided - e.g. by a linker script or another object file). */ + e.g. by a linker script or another object file.) */ .weak __stack .weak FUNCTION (hardware_init_hook)