From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27159 invoked by alias); 18 Nov 2002 16:30:36 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 27138 invoked from network); 18 Nov 2002 16:30:28 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sources.redhat.com with SMTP; 18 Nov 2002 16:30:28 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.11.6/8.11.6) with ESMTP id gAIG6jw04268; Mon, 18 Nov 2002 11:06:45 -0500 Received: from pobox.corp.redhat.com (pobox.corp.redhat.com [172.16.52.156]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id gAIGUOD20865; Mon, 18 Nov 2002 11:30:24 -0500 Received: from north-pole.nickc.cambridge.redhat.com.redhat.com (vpn50-24.rdu.redhat.com [172.16.50.24]) by pobox.corp.redhat.com (8.11.6/8.11.6) with ESMTP id gAIGULq05228; Mon, 18 Nov 2002 11:30:23 -0500 To: Richard.Earnshaw@arm.com Cc: newlib@sources.redhat.com, gdb-patches@sources.redhat.com Subject: Re: ARM crt0.o: Add NULL to end of argv[] References: <200211181552.gAIFqmt05403@pc960.cambridge.arm.com> From: Nick Clifton Date: Mon, 18 Nov 2002 08:30:00 -0000 In-Reply-To: <200211181552.gAIFqmt05403@pc960.cambridge.arm.com> Message-ID: User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/21.1 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2002-11/txt/msg00459.txt.bz2 Hi Richard, > > > + /* Push a NULL argument onto the end of the list. */ > > + mov r2, #0 > > + #ifdef __thumb__ > > + push {r2} > > + #else > > + stmfd sp!, {r1} > > + #endif > > #endif > > That can't be right. The arm and thumb code push different registers!!!! Doh! > And even if you change that I'm not convinced. Surely you need to > push this extra value *before* you reverse the list. Otherwise the > first argument will be null, not the last. Argh. I should not have gotten out of bed this morning. You are right of course, I was putting the NULL at the wrong end of the list, and it was only by chance that the test I as using to check the patch was detecting a NULL at argv[argc]. *sigh* Fixed by applying the patch below. Cheers Nick Index: newlib/libc/sys/arm/crt0.S =================================================================== RCS file: /cvs/src/src/newlib/libc/sys/arm/crt0.S,v retrieving revision 1.7 diff -c -3 -p -w -r1.7 crt0.S *** newlib/libc/sys/arm/crt0.S 18 Nov 2002 15:21:24 -0000 1.7 --- newlib/libc/sys/arm/crt0.S 18 Nov 2002 16:29:18 -0000 *************** __change_mode: *** 95,100 **** --- 95,106 ---- #endif /* Parse string at r1 */ mov r0, #0 /* count of arguments so far */ + /* Push a NULL argument onto the end of the list. */ + #ifdef __thumb__ + push {r0} + #else + stmfd sp!, {r0} + #endif .LC10: /* Skip leading blanks */ #ifdef __thumb__ *************** __change_mode: *** 179,192 **** strhi r5, [r2, #-4]! strhi r4, [r3], #4 bhi .LC13 - #endif - - /* Push a NULL argument onto the end of the list. */ - mov r2, #0 - #ifdef __thumb__ - push {r2} - #else - stmfd sp!, {r1} #endif #endif --- 185,190 ----