This is the mail archive of the binutils@sourceware.cygnus.com mailing list for the binutils project.


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

Re: MIPS gas problem




I rewrite the test program which is not depending your gcc version
or config. Please try this.


#define P1  10
#define P2  12
#define P1STR  "10"
#define P2STR  "12"
#define AL1 (2<<(P1-1))
#define AL2 (2<<(P2-1))

asm( 
"	.globl	globalc;\n"
"	.rdata;\n"
"	.type	 globalc,@object;\n"
"	.size	 globalc,1;\n"
"globalc:\n"
"	.byte	97;\n"
);

asm( 
"	.globl	global1;\n"
"	.align	" P1STR ";\n"
"	.type	 global1,@object;\n"
"	.size	 global1,4;\n"
"global1:\n"
"	.word	0;\n"
);

asm( 
"	.globl	global2;\n"
"	.align	" P2STR ";\n"
"	.type	 global2,@object;\n"
"	.size	 global2,4;\n"
"global2:\n"
"	.word	1;\n"
);


int total_ng=0;

void check(char *addr, unsigned long al)
{
        unsigned long mask = (al -1);
        if ((unsigned long) addr & mask){
                total_ng ++;
                printf("err:%x expected:%x\n", addr, 
				(unsigned long) addr & ~mask);
        }
}


int
main(void)
{
	extern int global1, global2;
	extern char globalc;

        printf("* readonly gloabl\n");
        printf("chcking align:%x\n",AL1);
        check((char *)&global1,AL1); 
        printf("%x\n", &global1);

        printf("chcking align:%x\n",AL2);
        check((char *)&global2,AL2); 
        printf("%x\n", &global2);

        printf("\n");
        if (total_ng) {
                printf("NG:%d\n",total_ng);
        } else {
                printf("OK\n");
        }
        printf("\n");
        return total_ng;

}

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