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


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

Re: position independent code


Gnu CC does support position independant code with the -fpic and -fPIC
options.  It is only supported when the compiler & assembler use the ELF
object file format, it does not work when using COFF (as you have
already discovered, judging from the listing you enclosed).  ELF for the
m68k will be supported in a forthcoming release of EGCS.

There is an additional complication: the gnu implementation is designed
with shared libraries in mind; it creates an address translation table
which must be 'fixed up' at run time to point to the absolute address of
functions and variables.  This is not really useful for an embedded
(diskless, OS-less) system.  This is a more complicated issue, and it
would take some work to implement for a low-end system (essentially you
would need a run-time loader of some sort).

FALE@skidata.com wrote:
> 
> Hi,
> 
> is it possible to generate position independent code
> and data references with the gnu gcc for m68k/coldfire ?
> 
> eg:
>     bsr function    instead of    jsr function
> and
>     mov.l var(%a5),%d0  instead of    move.l var,%d0
> 
> at the moment we use the sds crosscode c compiler
> which has this option (register relative data and bss),
> but can't generate code for the coldfire cpu.
> 
> I tried the -fpic and -fPIC options and got the following
> assembler output
> 
>         move.l %a5,-(%sp)
>         lea (%pc, _GLOBAL_OFFSET_TABLE_@GOTPC), %a5
>         bsr __main@PLTPC
>         "
>         "
>         move.l var@GOT.w(%a5),%d1
>         "
>         etc...
> 
> and following assembler errors
> temp.s: Assembler messages:
> temp.s:55: Error: parse error -- statement `lea
> (%pc,_GLOBAL_OFFSET_TABLE_@GOTPC),%a5' ignored
> temp.s:56: Error: parse error -- statement `bsr __main@PLTPC' ignored
> 
> seems the assembler does'nt understand the generated code ?
> 
> any ideas ?
> 
> Leopold Faschalek                     mailto:fale@skidata.com
> Research and Development
> SkiData AG                                 http://www.skidata.com
> Untersbergstrasse 40
> A-5083 Gartenau                         voice:+43-6246-888
> 
> _______________________________________________
> New CrossGCC FAQ: http://www.objsw.com/CrossGCC
> _______________________________________________
> To remove yourself from the crossgcc list, send
> mail to crossgcc-request@cygnus.com with the
> text 'unsubscribe' (without the quotes) in the
> body of the message.
_______________________________________________
New CrossGCC FAQ: http://www.objsw.com/CrossGCC
_______________________________________________
To remove yourself from the crossgcc list, send
mail to crossgcc-request@cygnus.com with the
text 'unsubscribe' (without the quotes) in the
body of the message.