Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

gcc cross-compiler for ARM with -fPIC (-mapcs-reentrant) support

262 views
Skip to first unread message

Ramesh Chandrasekhar

unread,
Feb 1, 2001, 1:27:01 PM2/1/01
to
I am trying to build a Position Indep module using the gcc cross-compiler
on Linux.
(Binutils-2.9.5.0.22, gcc-2.95.2, glibc-2.1.2 with all the patches)

I realized that if you use -fPIC, the compiler only attempts to
do -mapcs-reentrant, but does not warn if the option is not present. I do
want this option in what I am trying
to do, and so if I explicitly use the compiler with -mapcs-reentrant option,
I get an error
"cc1: warning: APCS reentrant code not supported. Ignored"

Can anybody please tell me if this option is supported at all on ARM, and if
yes, how to make gcc support this option.

Thanks,

Ramesh


Kai Ruottu

unread,
Feb 2, 2001, 4:16:53 AM2/2/01
to

It seems that the '-mapcs-reentrant or '-fPIC' isn't yet supported,
while the '-fpic' variation is...

-fpic
Generate position-independent code (PIC) suitable for use in a
shared library, if supported for the target machine. Such code
accesses all constant addresses through a global offset table (GOT).
<snip>

-fPIC
If supported for the target machine, emit position-independent code,
suitable for dynamic linking and avoiding any limit on the size of
the global offset table. This option makes a difference on the
m68k, m88k, and the Sparc.

For newer-than-gcc-2.95.2 GCCs there are the PIC-related ARM-specific
options:

-msingle-pic-base
Treat the register used for PIC addressing as read-only, rather than
loading it in the prologue for each function. The run-time system
is responsible for initialising this register with an appropriate
value before execution begins.

-mpic-register=<reg>
Specify the register to be used for PIC addressing. The default is
R10 unless stack-checking is enabled, when R9 is used.

These new options are available in the GCC-snapshots, and in the
RedHat EDK and Intel-XScale (ARM v5) releases:

ftp://sources.redhat.com/pub/gcc/snapshots
ftp://ftp.redhat.com/pub/redhat/edk
ftp://ftp.redhat.com/pub/gnupro

It is usual that the RedHat-sites have too many users, but the

http://www.redhat.com/download/mirror.html

gives the mirrors for it...

The XScale toolkit manual (xscale.pdf) documents the
'-mapcs-reentrant' and doesn't say that it isn't supported, so
it can be possible that Cygnus/RedHat has it impemented in their
GNUPro sources... Please check the XScale-distribution if possible
(tens of megabytes per package).

Anyway here are the diffs between codes produced with '-fno-pic'
(nothing used) and with '-fpic' for a simple function:

***************
*** 140,149 ****
@ args = 0, pretend = 0, frame = 0
@ frame_needed = 1, current_function_anonymous_args = 0
mov ip, sp
! stmfd sp!, {fp, ip, lr, pc}
sub fp, ip, #4
mov r1, r0
! ldr ip, .L41
ldr r2, [ip, #0]
rsb r3, r2, r2, asl #3
add r3, r2, r3, asl #2
--- 147,160 ----
@ args = 0, pretend = 0, frame = 0
@ frame_needed = 1, current_function_anonymous_args = 0
mov ip, sp
! stmfd sp!, {sl, fp, ip, lr, pc}
sub fp, ip, #4
mov r1, r0
! ldr sl, .L43
! ldr r3, .L43+4
! .L42:
! add sl, pc, sl
! ldr ip, [sl, r3]
ldr r2, [ip, #0]
rsb r3, r2, r2, asl #3
add r3, r2, r3, asl #2
***************
*** 152,164 ****
add r0, r2, r3, asl #2
add r3, r0, #13824
add r3, r3, #25
- mov r0, r3
- mov r0, r3
str r3, [ip, #0]
! bl __modsi3
! ldmea fp, {fp, sp, pc}
! .L42:
.align 2
! .L41:
! .word seed
.Lfe3:
.size random,.Lfe3-random
--- 163,176 ----
add r0, r2, r3, asl #2
add r3, r0, #13824
add r3, r3, #25
str r3, [ip, #0]
! mov r0, r3
! bl __modsi3(PLT)
! ldmea fp, {sl, fp, sp, pc}
! .L44:
.align 2
! .L43:
! .word _GLOBAL_OFFSET_TABLE_ - (.L42+8)
! .word seed(GOT)
.Lfe3:
.size random,.Lfe3-random

Perhaps the '-fpic' option could be used by you too...

Cheers, Kai

0 new messages