This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: ARM crt0.o: Add NULL to end of argv[]


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 ----


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]