* ARM crt0.o: Add NULL to end of argv[]
@ 2002-11-18 7:20 Nick Clifton
2002-11-18 7:50 ` Richard Earnshaw
0 siblings, 1 reply; 4+ messages in thread
From: Nick Clifton @ 2002-11-18 7:20 UTC (permalink / raw)
To: newlib; +Cc: gdb-patches
Hi Guys,
I am applying the patch below to fix a small bug in the ARM crt0.o
file for newlib. The code was creating an argv[] array from the
command line, but it was not terminating the array with a NULL
pointer. This is required by the ISO C specification, and this
patch fixes the problem.
Cheers
Nick
2002-11-18 Nick Clifton <nickc@redhat.com>
* libc/sys/arm/crt0.S: Add NULL to end of argv array.
Index: newlib/libc/sys/arm/crt0.S
===================================================================
RCS file: /cvs/src/src/newlib/libc/sys/arm/crt0.S,v
retrieving revision 1.6
diff -c -3 -p -w -r1.6 crt0.S
*** newlib/libc/sys/arm/crt0.S 30 Apr 2002 18:23:38 -0000 1.6
--- newlib/libc/sys/arm/crt0.S 18 Nov 2002 15:19:11 -0000
*************** __change_mode:
*** 181,186 ****
--- 181,193 ----
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
#ifdef __USES_INITFINI__
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: ARM crt0.o: Add NULL to end of argv[]
2002-11-18 7:20 ARM crt0.o: Add NULL to end of argv[] Nick Clifton
@ 2002-11-18 7:50 ` Richard Earnshaw
2002-11-18 7:53 ` Richard Earnshaw
0 siblings, 1 reply; 4+ messages in thread
From: Richard Earnshaw @ 2002-11-18 7:50 UTC (permalink / raw)
To: Nick Clifton; +Cc: newlib, gdb-patches, Richard.Earnshaw
> + /* 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!!!!
R.
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: ARM crt0.o: Add NULL to end of argv[]
2002-11-18 7:50 ` Richard Earnshaw
@ 2002-11-18 7:53 ` Richard Earnshaw
2002-11-18 8:30 ` Nick Clifton
0 siblings, 1 reply; 4+ messages in thread
From: Richard Earnshaw @ 2002-11-18 7:53 UTC (permalink / raw)
To: Nick Clifton; +Cc: newlib, gdb-patches, Richard.Earnshaw
>
> > + /* 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!!!!
>
> R.
>
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.
R.
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: ARM crt0.o: Add NULL to end of argv[]
2002-11-18 7:53 ` Richard Earnshaw
@ 2002-11-18 8:30 ` Nick Clifton
0 siblings, 0 replies; 4+ messages in thread
From: Nick Clifton @ 2002-11-18 8:30 UTC (permalink / raw)
To: Richard.Earnshaw; +Cc: newlib, gdb-patches
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 ----
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2002-11-18 16:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-18 7:20 ARM crt0.o: Add NULL to end of argv[] Nick Clifton
2002-11-18 7:50 ` Richard Earnshaw
2002-11-18 7:53 ` Richard Earnshaw
2002-11-18 8:30 ` Nick Clifton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox