This is the mail archive of the crossgcc@sourceware.org mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


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

mips-elf-gcc 3.4.4 and 4.0.2 produce the same assembly code with -fPIC and -fno-PIC


I build my gcc(3.4.4 and 4.0.2)  mips-elf cross compile toolchain on my
cygwin and fedora core4 with the following configuration:
--prefix=/opt/mips-elf-tools --target=mips-elf --enable-languages=c,c++
--with-gnu-as --with-gnu-ld --with-newlib
--with-gxx-include-dir=/opt/mips-elf-tools/mips-elf/include
when tested the toolchain with following code: 

static int x;
static int w;
static const int y[]={0,1,2,3,4,5,6,7,8,9};
static int zz=10;
static  void z(void)
{
	w=x;
}
int xxx(void)
{
	x=y[6];
	z();
        zz=y[1];
} 
 
I tried both -fPIC and -fno-PIC options as follows:
mips-elf-gcc -S -fPIC test.c -o test.1.s
mips-elf-gcc -S -fno-PIC test.c -o test.2.s
but I found -fno-PIC option seem not to be working, mips-elf-gcc just
produce PIC code while given the -fno-PIC option
anybody can help me with this? many thanks
content of test.1.s and test.2.s are as follows:
	.file	1 "test1.c"
	.section .mdebug.abi32
	.previous
	.rdata
	.align	2
	.type	y, @object
	.size	y, 40
y:
	.word	0
	.word	1
	.word	2
	.word	3
	.word	4
	.word	5
	.word	6
	.word	7
	.word	8
	.word	9
	.section	.sdata,"aw",@progbits
	.align	2
	.type	zz, @object
	.size	zz, 4
zz:
	.word	10
	.text
	.align	2
	.ent	z
z:
	.frame	$fp,8,$31		# vars= 0, regs= 1/0, args= 0, gp= 0
	.mask	0x40000000,-8
	.fmask	0x00000000,0
	.set	noreorder
	.set	nomacro
	
	addiu	$sp,$sp,-8
	sw	$fp,0($sp)
	move	$fp,$sp
	lw	$2,%gp_rel(x)($28)
	nop
	sw	$2,%gp_rel(w)($28)
	move	$sp,$fp
	lw	$fp,0($sp)
	addiu	$sp,$sp,8
	j	$31
	nop

	.set	macro
	.set	reorder
	.end	z
	.align	2
	.globl	xxx
	.ent	xxx
xxx:
	.frame	$fp,24,$31		# vars= 0, regs= 2/0, args= 16, gp=
0
	.mask	0xc0000000,-4
	.fmask	0x00000000,0
	.set	noreorder
	.set	nomacro
	
	addiu	$sp,$sp,-24
	sw	$31,20($sp)
	sw	$fp,16($sp)
	move	$fp,$sp
	lui	$2,%hi(y)
	addiu	$2,$2,%lo(y)
	lw	$2,24($2)
	nop
	sw	$2,%gp_rel(x)($28)
	jal	z
	nop

	lui	$2,%hi(y)
	addiu	$2,$2,%lo(y)
	lw	$2,4($2)
	nop
	sw	$2,%gp_rel(zz)($28)
	move	$sp,$fp
	lw	$31,20($sp)
	lw	$fp,16($sp)
	addiu	$sp,$sp,24
	j	$31
	nop

	.set	macro
	.set	reorder
	.end	xxx

	.lcomm	x,4

	.lcomm	w,4





------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sources.redhat.com


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