powerpc-eabi subroutine calls

David Korn dkorn@pixelpower.com
Tue Oct 30 17:43:00 GMT 2001


>-----Original Message-----
>From: Gunter Magin [mailto:magin@skil.camelot.de]
>Sent: 12 December 2001 09:06

>to make gcc generate a "far" subroutine call, an attribute must be added
>to the function declaration:
>
>     void foo (int bar1, char bar2) __attribute__ ((longcall));
>
>This has to be done for any function which might be called from a location
>more than 8MB away.
>
>The generated assembler code looks like this:
>
>    lis 9,foo@ha
>    la 0,foo@l(9)
>    mtlr 0
>    li 4,0                 # 2nd argument
>    li 3,100               # 1st argument
>    blrl


  Here's a patch I wrote which adds a new commmand line option -mlongcall
to the 2.95.x compiler.  It is based on a patch contributed by Mike Stump
of Wind River Systems which I found in one of the gcc.gnu.org mailing list
archives.  I've sent it as an attachment to avoid line-wrapping trouble.
The line numbering may be slightly out of kilter, but the patch command
should still apply it cleanly.  After applying the patch to the gcc source
code, build it just as usual.  Then you can compile using -mlongcall to
force all subroutine calls to be made using longcalls (except when the
compiler knows it is a call to a function in the same C module, either 
because the function has been declared static, or because it has already
been defined and output, in which two cases it can optimize to use a short
branch on the assumption that the module itself is less than 8MB).  This
saves going and adding attributes to all your declarations!

  Despite the comment that says "Note that this patch is only valid for the
Vxworks target", it should in fact work just as well for ppc-eabi.  The
provisos about pic code and virtual functions remain, and it may possibly
still have bugs, but I use it regularly and it works for me. 

  There is one change worth making that isn't included in the patch: you
might want to edit the file gcc/config/rs6000/t-ppcgas to add "mlongcall"
in the list of options next to "MULTILIB_EXTRA_OPTS", which will cause the
system libraries such as libgcc.a to be compiled using longcalls during the
process of building and installing the compiler.



    hth,
     DaveK
-- 
Burn your ID card!  http://www.optional-identity.org.uk/
Help support the campaign, copy this into your .sig!



**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vxworks-longcall.patch
Type: application/octet-stream
Size: 15852 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/crossgcc/attachments/20011030/bc506fb0/attachment.obj>
-------------- next part --------------
------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sources.redhat.com


More information about the crossgcc mailing list