[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Is libc6 OK on powerpc?



On Wed, Mar 21, 2001 at 02:21:09PM -0500, Daniel Jacobowitz wrote:
>
> On Thu, Mar 22, 2001 at 12:51:02AM +1100, Drew Parsons wrote:
> > gcc  main.o init.o events.o tools.o screens.o game.o editor.o files.o
> > cartoons.o libgame/libgame.a -lSDL_image -lSDL_mixer -L/usr/lib -lSDL
> > -lpthread  -lm -o ../mirrormagic
> > libgame/libgame.a(gadgets.o): In function HandleGadgetTags':
> > gadgets.o(.text+0x9f8): undefined reference to __va_arg_type_violation'
> > gadgets.o(.text+0x9f8): relocation truncated to fit: R_PPC_REL24
> > __va_arg_type_violation
> > collect2: ld returned 1 exit status
> > make[2]: *** [../mirrormagic] Error 1
> 
> 
> > The code in question is declared as:
> > 
> > static void HandleGadgetTags(struct GadgetInfo *gi, int first_tag, va_list ap)
> > 
> > and the va_arg argument is used in several places inside, e.g.
> >     gi->custom_id = va_arg(ap, int); 
> >     strncpy(gi->info_text, va_arg(ap, char *), max_textsize); 
> >     gi->type = va_arg(ap, unsigned long); 
> >     gi->deco.width = va_arg(ap, int); 
> >     gi->deco.height = va_arg(ap, int);         
> >     gi->design[GD_BUTTON_PRESSED].bitmap = va_arg(ap, Bitmap *); 
> >     gi->event_mask = va_arg(ap, unsigned long); 
> >     gi->callback_info = va_arg(ap, gadget_function); 
> 
> Somewhere, you left out one of the va_arg calls.  It'll be using a char
> or short argument.  This is illegal C; only promoted types (int,
> pointers, etc) may be given to va_arg.

This was indeed the problem.  The bug was with a call of va_arg(ap,boolean)
which should have been an int.

With the patch below it compiles and runs just fine.

> > So this "undefined reference to __va_arg_type_violation", is it a known
> > problem on the powerpc?  Have others met it?  Or does it mean the code has
> > been written poorly?  There's nothing obviously bad in the code that I can
> > see, but I've never had to deal with powerpc or endian issues before (though
> > I can't see any issues here). It works fine on x86.
> 
> It works on x86 because x86 is a mostly unaligned architecture, that's
> all :)

"__va_arg_type_violation" is a function which doesn't exist, which gcc
intentionally makes a call to if you make a bad va_arg call.  See
<va-ppc.h> (which is where I read about it).

I'm not sure why it does this rather than giving a compile time error,
which would be much more user-friendly, since it would give the line of
code that is causing the problem.  Also, it doesn't do it when you turn the
optimization off, which I also don't understand.

But at least I now understand what this error is all about.
-- 
David Roundy
http://civet.berkeley.edu/droundy/


--- mirrormagic-2.0.0/src/libgame/gadgets.c     Mon Dec  4 14:44:04 2000
+++ mirrormagic-2.0.0.new/src/libgame/gadgets.c Thu Mar 22 08:44:23 2001
@@ -309,7 +309,7 @@
        break;

       case GDI_CHECKED:
-       gi->checked = va_arg(ap, boolean);
+       gi->checked = (boolean) va_arg(ap, int);
        break;

       case GDI_RADIO_NR:



Reply to: