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]

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


Hi,

sorry for the late reply.

On Wed, 21 Dec 2005, Weiqiang wrote:

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

Abicalls and PIC code generation are tied to one another on MIPS. This is because the System V ABI specifies the the global pointer register "gp" to
be call-clobberable, and PIC code means the GP will be used. Thus for
non-PIC code, you should also specify -mno-abicalls. If you don't, the
compiler might implicitly fall back to PIC code generation (detectable by
the GP register being used in the assembly).


I compile my statically linked MIPS code with -mno-abicalls -fno-pic.

Ah, and make sure you don't reference anything from libgcc.a or any other
compiler library; they are PIC compiled and mips-ld will refuse to link your
code against them.

Regards,
Marius

--
Marius Groeger <mgroeger@sysgo.com>
SYSGO AG                      Embedded and Real-Time Software
Voice: +49 6136 9948 0                  FAX: +49 6136 9948 10
www.sysgo.com | www.elinos.com | www.osek.de | www.pikeos.com



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