From patchwork Fri Apr 12 20:42:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Fedotov X-Patchwork-Id: 162144 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp22088jan; Fri, 12 Apr 2019 13:43:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqzVj0HZgjVVyodECtHXnT4GaUgMKC3nafsCNwwPQP9RbXnhcZ4jsaHpPMoZ+BT8yJO1pYCV X-Received: by 2002:a17:902:9a4a:: with SMTP id x10mr60127492plv.113.1555101786355; Fri, 12 Apr 2019 13:43:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555101786; cv=none; d=google.com; s=arc-20160816; b=pvygJoHb38FG50BcyID20b0qGibJztzj1frmDFEdNoUi+c0p9yQGfjzKRr9vM9GJ3r ZCLcDJUgIcYpTyMqjjmh+7wglfT8ghsSJMX9s1Uy0fLq5cR8KSQWVzK9Vckjq43SnVZa n9Vd02+EvYNyW27B5qZOLILsOYCL+YPVVuSDcUILazEAf51nEXVrgQEfouQ9PU9g2JDW byKseKdKSzOYR8vvhVbwihIBAd8X+fa2U81zg9uJyT6wrbgThVxKq2wDNWVK/T/8jJdB K8Xaw52MEqRb/QTOjCoPJYP11NR6pwsBT1R3kmoryZRqGo7f4YzFv16dT9vmOV5W4PtX +hOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:subject:message-id:date:from:mime-version: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=8Ly4q8+zZwGVnmhE9lEuLziuhpw6hn+LbubBeX8p/BU=; b=Ok3ZXAwZyg+oPbE4tbjtE/P/JedY2+sj0UORC7Vmp/HvftU+soTTn9k7vvCImp1I5j UlLdKNV7H0CR5O9696xGjFgYOqk4ulMSVUgN00Cgap1yYWdgH/L8bhFI4ChwLEa4obqU D3cXXoz+CM5L99o7TSSDZjk7fk55BngJyXSpUAIBJYiFWjzDPgLBnCRqktZLOy9keyWz TmcmziPPPHfLLaVW0h7y+Ka3W7vM1qbW6GwDn1leihWlNMYo5uVlyUppTsfoA7dFAgmv SKgCohZmbwQIHoJEGk0CGgNMU1biDeQqDezOyPYHrAtS5Kvpxv2k3FA06LlNvhm5k5Qe qnLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=lbCsokeW; dkim=pass header.i=@gmail.com header.s=20161025 header.b=X2Dd0mMd; spf=pass (google.com: domain of newlib-return-16880-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="newlib-return-16880-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 v5si37017668pfm.134.2019.04.12.13.43.06 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Apr 2019 13:43:06 -0700 (PDT) Received-SPF: pass (google.com: domain of newlib-return-16880-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=lbCsokeW; dkim=pass header.i=@gmail.com header.s=20161025 header.b=X2Dd0mMd; spf=pass (google.com: domain of newlib-return-16880-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="newlib-return-16880-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:mime-version:from:date:message-id:subject:to :content-type; q=dns; s=default; b=CSA1mEDjcFdrK8Rb6s/DD0kmHesv6 McYlgVaAXi5s0rt2osGOIgOkw4k9cF60n/n1aS2+QMcAqRPw0M74JI2lYannXcem i1jhjXG9YITNeRwOyX7VmKzbhHqBRh5Ie6AoRp+1GD05Myzf+0KfY+nyKh2r05tU /rkaR+/Whkwvwo= 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:mime-version:from:date:message-id:subject:to :content-type; s=default; bh=o1NE/Y/Kne7Nsv//NFsDJ9aW10M=; b=lbC sokeWcMM6Dl2Gj2kl5iLzCNPaZRX4/dBjrL7CSmFqzZJW6tGzKD0eUSSzqSUfr5h eAd3lTnqhqv0ibpcrbLfoGzuwp5JeAxpGBqM8lAnVtMAW40jfjziU0hJapg/DUuv p5aOaZGsDC4kh9Ay2M8i4tOxNDvhmHRV9MIZ2wFI= Received: (qmail 89902 invoked by alias); 12 Apr 2019 20:42:58 -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 89892 invoked by uid 89); 12 Apr 2019 20:42:57 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-13.1 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=lite, HX-Languages-Length:3112, pulling X-HELO: mail-io1-f46.google.com Received: from mail-io1-f46.google.com (HELO mail-io1-f46.google.com) (209.85.166.46) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 12 Apr 2019 20:42:56 +0000 Received: by mail-io1-f46.google.com with SMTP id p16so9694688iod.2 for ; Fri, 12 Apr 2019 13:42:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=8Ly4q8+zZwGVnmhE9lEuLziuhpw6hn+LbubBeX8p/BU=; b=X2Dd0mMdjVBM0DsXdU+cdvCmKY7JGdfy+hrk3Jjzh/+KcCc3mPMau39UB4qtWD0tZK Me/RpoIkkFzu8DGGe5DQswCClIEifE8lM0kuPHmYPIcGUVSNUJJsl4C33/Uj2JGdOjBq E1S6OReTe7y8skK9aVGsIGVS+K/WTCVw7mVoj9k+0c2onFuGWx400472/Oprlxo23ZO3 kUxVm2gS8uynwtU/HpxfO0lmCfafAxauv9E+iTNa+pF+0IuZIH+72yPgIFf/OiYbij7D 0lx9hqKVTa1A0CuJfUYeHFERTqktRnZdd2Va2TVRnqvJDkWm5sZ+sN2SZD8vVUFSLSQU 0OfA== MIME-Version: 1.0 From: Alexander Fedotov Date: Fri, 12 Apr 2019 23:42:43 +0300 Message-ID: Subject: [Arm] Remaining difference in crt0 code To: "Richard Earnshaw (lists)" , Newlib Hello Richard There is still some difference in crt0.S code in libgloss and libc respectively. Could you help me figure out what version is correct so we can get rid of this. Differences are following: #ifdef ARM_RDP_MONITOR /* Issue Demon SWI to read stack info. */ @@ -105,13 +118,20 @@ bkpt AngelSWI #elif defined(__thumb2__) /* We are in thumb mode for startup on armv7 architectures. */ - AngelSWIAsm AngelSWI + AngelSWIAsm (AngelSWI) #else /* We are always in ARM mode for startup on pre armv7 archs. */ - AngelSWIAsm AngelSWI_ARM + AngelSWIAsm (AngelSWI_ARM) #endif ldr r0, .LC0 /* Point at values read. */ + /* Set __heap_limit. */ + ldr r1, [r0, #4] + cmp r1, #0 + beq .LC33 + ldr r2, =__heap_limit + str r1, [r2] +.LC33: ldr r1, [r0, #0] cmp r1, #0 bne .LC32 @@ -279,13 +299,10 @@ movs r1, r0 #else movs r0, #AngelSWI_Reason_GetCmdLine - adr r1, .LC30 /* Space for command line. */ -#ifdef THUMB_VXM - bkpt AngelSWI -#else - AngelSWIAsm AngelSWI -#endif + 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. */ @@ -309,7 +326,7 @@ beq .LC10 /* See whether we are scanning a string. */ - cmp r3, #'\"' + cmp r3, #'"' #ifdef __thumb__ beq .LC20 cmp r3, #'\'' @@ -396,8 +413,17 @@ for _fini to be called at program exit. */ movs r4, r0 movs r5, r1 +#ifdef _LITE_EXIT + /* Make reference to atexit weak to avoid unconditionally pulling in + support code. Refer to comments in __atexit.c for more details. */ + .weak FUNCTION(atexit) + ldr r0, .Latexit + cmp r0, #0 + beq .Lweak_atexit +#endif ldr r0, .Lfini bl FUNCTION (atexit) +.Lweak_atexit: bl FUNCTION (_init) movs r0, r4 movs r1, r5 @@ -469,13 +495,19 @@ .LC2: .word __bss_end__ #ifdef __USES_INITFINI__ +#ifdef _LITE_EXIT +.Latexit: + .word FUNCTION(atexit) + + /* Weak reference _fini in case of lite exit. */ + .weak FUNCTION(_fini) +#endif .Lfini: .word FUNCTION(_fini) #endif #ifdef ARM_RDI_MONITOR .LC30: - .word CommandLine - .word 255 + .word AngelSWIArgs .LC31: .word __end__ @@ -488,6 +520,9 @@ __stack_base__: .word 0 StackLimit: .word 0 CommandLine: .space 256,0 /* Maximum length of 255 chars handled. */ +AngelSWIArgs: + .word CommandLine + .word 255 #endif #ifdef __pe__ Best regards, Alex --- newlib/libc/sys/arm/crt0.S 2019-04-12 23:28:32.237488800 +0300 +++ libgloss/arm/crt0.S 2019-04-12 23:28:32.237488800 +0300 @@ -79,6 +79,19 @@ .fnstart #endif + /* __ARM_ARCH_PROFILE is defined from GCC 4.8 onwards, however __ARM_ARCH_7A + has been defined since 4.2 onwards, which is when v7-a support was added + and hence 'A' profile support was added in the compiler. Allow for this + file to be built with older compilers. We only call this for A profile + cores. */ +#if defined (__ARM_ARCH_7A__) || (__ARM_ARCH_PROFILE == 'A') +/* The init hook does not use the stack and is called before the stack has been set up. */ +#ifdef ARM_RDI_MONITOR + bl _rdimon_hw_init_hook + .weak FUNCTION (_rdimon_hw_init_hook) +#endif +#endif + /* Start by setting up a stack. */