Home

GNUPro® Toolkit User's Guide for IBM® AIX

image

Contents

1. u For C shells use the following example s input set PROOT installdir aix yymmdd set path PROOT H host bin path setenv INFOPATH PROOT info This documentation uses some general conventions see Table 2 Table 2 Documentation conventions Text appearance Meaning Bold Font Represents menus window names and tool buttons Bold Italic Font Denotes book titles both hardcopy and electronic Plain Typewriter Font Denotes code fragments command lines file contents and command names also indicates directory file and project names where they appear in text Italic Typewriter Font Represents a variable to substitute Bold Typewriter Font Indicates command lines options and text output generated by the program GNUPro Toolkit User s Guide for AIX on PowerPC m 3 Introduction 4 E User s Guide for AIX on PowerPC GNUPro Toolkit Tutorial This tutorial gives examples of how to use the tools For more information about the tools see http www redhat com support manuals gnupro html IMPORTANT Remember that GNUPro Toolkit is case sensitive Enter all commands and options exactly as indicated in this document The following examples were created using GDB GNUPro debugger in command line mode They may also be reproduced using the command prompt in the Console Window of Insight the GUI interface to the GNUPro Debugger Create Source Code Cre
2. mpowerpc permits GCC to use any instruction from either architecture and to allow use of the MQ register specify this for the Motorola MPC601 10 m User s Guide for AIX on PowerPC GNUPro Toolkit Compiler Features mnew mnemonics Specifying mnew mnemonics requests output that uses the assembler mnemonics defined for the PowerPC architecture mold mnemonics Specifying mold mnemonics requests the assembler mnemonics defined for the POWER architecture IMPORTANT Instructions defined in only one architecture have only one mnemonic GCC uses that mnemonic regardless of which of these options is specified GCC defaults to the mnemonics appropriate for the architecture in use Specifying mcpu CPU TYPE sometimes overrides the value of these option Unless you are building a cross compiler you should normally not specify either mnew mnemonics Or mold mnemonics but should instead accept the default mcpu cpu type Sets architecture type register usage choice of mnemonics and instruction scheduling parameters for machine type cpu_type Supported values for cpu type are common power power2 powerpc rs6000 riosl rios2 rsc 403 505 601 602 603 603e 604 604e 620 740 750 801 821 823 and 860 mcpu power mcpu power2 and mcpu powerpc specify generic POWER POWER2 and pure PowerPC not MPC601 architecture machine types with an appropriate generic processor model assumed for scheduling purposes
3. 2 lwz 9 LC 1 2 lwz 4 0 9 add 6 5 4 stw 6 0 11 line 3 lwz 3 LC 3 2 bl printf nop line 4 ef 9 Red Hat User s Guide for AIX on PowerPC m 7 Tutorial 8 E User s Guide for AIX on PowerPC Red Hat Reference The following documentation describes the ABI and PowerPC specific features of the GNUPro tools Compiler Features below 32 Bit ABI Summary on page 15 64 Bit ABI Summary on page 20 Assembler Features on page 25 Linker Features on page 26 Debugger Features on page 29 Compiler Features The following documentation describes PowerPC specific features of the GNUPro compiler The following options are supported for IBM RS 6000 and PowerPC For generic compiler options see GNU CC Command Options in Using GNU CC in GNUPro Compiler Tools GNUPro Toolkit User s Guide for AIX on PowerPC m 9 Reference mpower mno power mpower2 mno power2 mpowerpc mno powerpc mpowerpc gpopt mno powerpc gpopt mpowerpc gfxopt mno powerpc gfxopt GCC supports two related instruction set architectures for RS 6000 and PowerPC The POWER instruction set are those instructions supported by the RIOS chip set used in the original RS 6000 systems and the PowerPC instruction set is the architecture of the Motorola MPC5xx MPC6xx MPC8xx microprocessors and the IBM 4xx microprocessors Neither architecture is a subset of the other Howev
4. F filenames within makefiles 2 floating point arguments 22 floating point registers 16 17 21 22 frame pointer 19 24 GNUPro Toolkit User s Guide for AIX on PowerPC m 31 function addresses 23 function pointer 17 18 23 function returns 16 18 21 22 23 functions 17 G general purpose registers 16 17 21 22 global data 18 23 GNU General Public License ii instruction set 25 instructions 2 integer registers 25 K Korn shell 3 L license ii linker 16 21 linker options 27 linker script 28 29 linker script commands 2 makefiles 2 N naming conventions for tools 2 nonprototyped functions 17 22 O object file format 1 P parameter passing 16 21 parameter registers 17 parameter widening 22 pointer register 18 prototype functions 22 prototyping 17 22 R Red Hat contacting ii registers 2 15 16 17 20 21 25 return values 16 S scalar arguments 17 22 section names 2 shell 3 simulator 6 Source Navigator 1 special purpose registers 16 stack 17 19 24 stack pointer 19 24 structures 17 structures and unions 15 20 22 symbols 25 T TOC table of contents 18 23 tools 2 trademarks ii U unions 15 20 V variables environment setting 2 6 W warranty ii Windows binaries 2 32 m User s Guide for AIX on PowerPC GNUPro Toolkit
5. PowerPC m 15 Reference Table 4 Register usage for 32 bit ABI Register Usage r0 Volatile register used in function prologs el Stack frame pointer r2 TOC pointer r3 and r4 Volatile parameter and return value register r5 through r10 Volatile registers used for function parameters r11 through r13 Volatile registers used during function calls r14 through r31 Nonvolatile registers used for local variables 0 Volatile scratch register 1 through 4 Volatile floating point parameter and return value registers 5 through 13 Volatile floating point parameter registers 14 through 31 Nonvolatile registers LR Link register volatile CTR Loop counter register volatile XER Fixed point exception register volatile FPSCR Floating point status and control register volatile CRO CR1 Volatile condition code register fields CR2 CR4 Nonvolatile condition code register fields CR5 CR7 Volatile condition code register fields Registers r1 r14 through r31 and 14 through 31 are nonvolatile which means that they preserve their values across function calls Functions which use those registers must save the value before changing it restoring it before the function returns Register r2 is technically nonvolatile but it is handled specially during function calls Registers r0 r3 through r12 0 through 13 and the special purp
6. and performance of the software is with you Should the software prove defective you assume the cost of all necessary servicing repair or correction In no event unless required by applicable law or agreed to in writing will any copyright holder or any other party who may modify and or redistribute the program as permitted above be liable to you for damages including any general special incidental or consequential damages arising out of the use or inability to use the program including but not lim ited to loss of data or data being rendered inaccurate or losses sustained by you or third parties or a failure of the program to operate with any other programs even if such holder or other party has been advised of the possibility of such dam ages How to Contact Red Hat Red Hat Corporate Headquarters 2600 Meridian Parkway Durham NC 27713 USA Telephone toll free 1 888 REDHAT 1 Telephone main line 1 919 547 0012 Telephone FAX line 1 919 547 0024 Website http www redhat com ii m User s Guide for AIX on PowerPC GNUPro Toolkit GNUPro Toolkit User s Guide for AIX on PowerPC Gi iii iv EE User s Guide for AIX on PowerPC GNUPro Toolkit Contents Introduction eiii la it a ea a RA odda he Paces 1 H 74 WEE 5 Create Source ET 5 Compile and Assemble from Source Code 6 Run Executable under the Debugger AAA 6 Assembler Listing from Source Code 6 Reference sote tat PONO Ge OO A heh cae bene
7. to prototyped functions beyond the register save area RSA on the stack in addition to argument FPRs The AIX calling convention was extended but not initially documented to handle an obscure K amp R C case of calling a function that takes the address of its arguments with fewer arguments than declared AIX XL compilers access floating point arguments which do not fit in the RSA from the stack when a subroutine is compiled without optimization Because always storing floating point arguments on the stack is inefficient and rarely needed 12 m User s Guide for AIX on PowerPC GNUPro Toolkit Compiler Features mno x1 cal1 is not enabled by default and only is necessary when calling subroutines compiled by AIX XL compilers without optimization mthreads Supports AIX Threads Links an application written to use pthreads with special libraries and startup code to enable the application to run mpe Supports the IBM RS 6000 SP Parallel Environment PE Link an application written to use message passing with special startup code to enable the application to run The system must have PE installed in the standard location usr lpp ppe poe or the specs file must be overridden with the specs option to specify the appropriate directory location The Parallel Environment does not support threads so the mpe option and the mthreads option are incompatible msoft float Generates code that does not use the floating point register set mhar
8. value before changing it restoring it before the function returns Register r2 is technically nonvolatile but it is handled specially during function calls Registers r0 r3 through r12 0 through 13 and the special purpose registers LR CTR XER and FPSCR are volatile which means that they are not preserved across function calls Furthermore registers r0 r2 r11 and r12 may be modified by cross module calls so a function can not assume that the values of one of these registers is that placed there by the calling function The condition code register fields CRO CR1 CR5 CR6 and CR7 are volatile The condition code register fields CR2 CR3 and CR4 are nonvolatile so a function which modifies them must save and restore them Parameter Passing The linkage convention specifies the methods for parameter passing and whether return values are placed in floating point registers general purpose registers or both GNUPro Toolkit User s Guide for AIX on PowerPC m 21 Reference The general purpose registers available for argument passing are r3 through r10 The floating point registers available for argument passing are p3 through fp13 Prototyping affects how parameters are passed and whether parameter widening occurs In nonprototyped functions floating point arguments are widened to type double and integral types are widened to type int In prototyped functions no widening conversions occur except in arguments passe
9. GNUPro Toolkit User s Guide for IBM AIX Development April 2001 Copyright O 2001 Red Haff Inc All rights reserved Red Hat the Red Hat Shadow Man logo Insight GNUPro and the GNUPro logo are all trademarks of Red Hat Inc IBM is a registered trademark of IBM Corporation UNIX is a registered trademark of The Open Group All other brand and product names trademarks and copyrights are the property of their respective owners No part of this document may be reproduced in any form or by any means without the prior express written consent of Red Hat Inc No part of this document may be changed an or modified without the prior express written consent of Red Hat Inc GNUPro Warranty The GNUPro Toolkit is free software covered by the GNU General Public License and you are welcome to change it and or distribute copies of it under certain conditions This version of GNUPro Toolkit is supported for customers of Red Hat For non customers GNUPro Toolkit software has NO WARRANTY Because this software is licensed free of charge there are no warranties for it to the extent permitted by applicable law Except when otherwise stated in writing the copyright holders and or other parties provide the software as is without warranty of any kind either expressed or implied including but not limited to the implied warranties of merchantability and fitness for a particular purpose The entire risk as to the quality
10. Setting mcpu equal to rios1 rios2 rsc power Or power2 enables mpower and mpowerpc Setting mcpu 601 enables both mpower and mpowerpc Setting mcpu equal to 602 603 603e 604 or 620 enables mpowerpc and disables mpower Setting mcpu equal to 403 505 821 860 Or powerpc enables mpowerpc and disables mpower Setting mcpu common disables both mpower and mpowerpc AIX version 4 or greater selects mcpu common by default so that code will operate on all members of the RS 6000 and PowerPC families In that case GCC will use only the instructions in the common subset of both architectures plus some special AIX common mode calls and will not use the MQ register GCC assumes a generic processor model for scheduling purposes Setting mcpu equal to rios1 rios2 rsc power Or power2 also disables new mnemonics Setting mcpu equal to 601 602 603 603e 604 620 403 Or powerpc also enables new mnemonics GNUPro Toolkit User s Guide for AIX on PowerPC m 11 Reference Setting mcpu equal to 403 821 or 860 also enables msoft float mtune cpu type Sets the instruction scheduling parameters for machine type cpu type but does not set the architecture type register usage and choice of mnemonics like mcpu The same values for cpu type are used for mtune as for mcpu mtun overrides mcpu in terms of instruction scheduling parameters mfull toc mno fp in toc mno sum in toc mminima
11. ack grows downwards from high addresses to low addresses u leaf function does not need to allocate a stack frame if one is not needed A frame pointer FP need not be allocated The stack pointer SP shall always be aligned to 32 byte boundaries Figure 2 AIX stack frames for 64 bit ABI Low memory SP Back chain to caller caller gt Saved CR Saved LR Reserved for compilers Reserved for binders Saved TOC pointer Parameter save area P Alloca space A Local variable space L Save area for GP registers G Save area for FP registers F Back chain to caller s caller Old SP_ High memory 64 bit offset 0 8 16 24 32 40 48 48 P 48 P A 48 P A L 48 P A L G 24 E User s Guide for AIX on PowerPC GNUPro Toolkit Assembler Features Assembler Features This section describes PowerPC specific features of the GNUPro assembler For a list of available generic assembler options see Command Line Options in Using as in GNUPro Utilities For more information about the PowerPC instruction set and PowerPC assembly conventions see The PowerPC Architecture A SPECIFICATION FOR A NEW FAMILIY OF RISC PROCESSORS Morgan Kaufmann Publishers Inc or PowerPC Microprocessor Family The Programming Environments IBM MPRPPCFPE 01 also Motorola MPCFPE AD Integer registers depend upon whether you have a 32 bit or a 64 bit
12. ain GNUPro tools For documentation see http www redhat com support manuals gnupro html and see http sources redhat com sourcenav for Source Navigator documentation For the most current release notes find the README at the top level directory of the distribution The supported processor version is the PowerPC The supported host is the AIX 4 3 2 PowerPC operating system The supported target is PowerPC RS6000 The IBM AIX tools support the XCOFF object file format The AIX PowerPC package includes the tools shown in Table 1 GNUPro Toolkit User s Guide for AIX on PowerPC m 1 Introduction Table 1 Tools and their naming conventions Tool description Tool name GCC compiler gcc C compiler g Assembler as Binary utilities ar nm objcopy ob jdump ranlib readelf size strings strip Debugger gdb IMPORTANT Binaries for the Windows hosted toolchain use an exe suffix However the exe Suffix does not need to be specified when running the executable Case sensitivity for Windows is dependent on system configuration By default file names under Windows are not case sensitive File names are case sensitive under UNIX File names are case sensitive when passed to the GNU C compiler GCC regardless of the operating system The following strings are case sensitive command line options assembler labels linker script commands section names and
13. ames The stack grows downwards from high addresses to low addresses A leaf function does not need to allocate a stack frame if one is not needed A frame pointer FP need not be allocated The stack pointer SP shall always be aligned to 16 byte boundaries See Figure 1 for AIX stack frames Figure 1 AIX stack frames for 32 bit ABI Low memory SP Back chain to caller caller 32 bit offset Saved CR 0 Saved LR 4 Reserved for compilers 8 Reserved for binders 12 Saved TOC pointer 16 Parameter save area P 20 Alloca space A 24 Local variable space L 24 P Save area for GP registers G 24 P A Save area for FP registers F 24 P A L Back chain to caller s caller 24 P A L G Old SP High memory GNUPro Toolkit User s Guide for AIX on PowerPC m 19 Reference 64 Bit ABI Summary This section describes the 64 bit AIX ABI Table 6 shows the size and alignment for all data types for 64 bit ABI Alignment within aggregates structures and unions is as shown with padding added if needed Aggregates have alignment equal to that of their most aligned member Aggregates have sizes which are a multiple of their alignment Table 6 Data type sizes and alignments for 64 bit ABI Type Size bytes Alignment bytes char 1 byte 1 byte short 2 bytes 2 bytes int 4 bytes 4 bytes unsigned 4 bytes 4 bytes long 8 bytes 8 bytes long long 8
14. ate the following sample source code and save it as hello c Use this program to verify correct installation include lt stdio h gt yt A OF void foo int b c a b printf sd Sd d n a b c int main Red Hat User s Guide for AIX on PowerPC E 5 Tutorial int b a 3 b 4 printf Hello world n foo b return 0 Compile and Assemble from Source Code To compile assemble and link this example to run on the simulator type gcc g o hello hello c The g option generates debugging information and the o option specifies the name of the executable to be produced Other useful options include o for standard optimization and 02 for extensive optimization When no optimization option is specified GCC will not optimize See GNU CC Command Options in Using GNU CC in GNUPro Compiler Tools for a complete list of available options Run Executable under the Debugger To start GDB type gdb nw hello The nw option was used to select the command line interface to GDB which is useful for making transcripts such as the one above The nw option is also useful when you wish to report a bug in GDB because a sequence of commands is simpler to reproduce If you are running an X11 based server and your DISPLAY environment variable is set GDB starts the Insight interface by default After the initial copyright and configuration information GDB returns its own prompt gdb T
15. ath ade ate SEANA 9 Compiler Features c cesctieesa A sch e AGA AO feet eet 9 Preprocessor Symbols eats td 14 32 BIt ABI Summary EE 15 Parameter Passing cia dee detec betes hoe AE BRNO 16 Call by Value Param eters ccessucsecgenececcueaucis eivectes hands EES Ee 17 TOCA Table of Contents eessen Aesth a etn and van niin 18 Pornters to FUNCIONS LS varier yndet es gale Z dA dO OC senda cidenseceee 18 Function Return Valles sie wii EEN WA W a dise ERE 18 Stack Frames ssa EEN 19 64 Bit ABI SUMMAPY westwerk owy o Oasis i E aaa erR EE E Enis 20 Parameter Passing ici ide a dA 21 Call by value Parameters sinem ksen ORC Bot ELE ate teg 22 TOC Table of Contents tacna altillo ged 23 Pointers to FUNCIONS iriser zzo tia etowe b doc EE EGEE E EEES AEE 23 Function Return Valves sez a OE A ai ER 23 Stack Frames serteni z Z dy O ES eee cuece runes WEZ 24 GNUPro Toolkit User s Guide for AIX on PowerPC E v Assembler Features EE e OWOC EEN EE ee ves 25 Linker Estuco lar dae 26 Debusger Fett A da 29 INQEX iii A asias 31 vi E User s Guide for AIX on PowerPC GNUPro Toolkit Introduction The GNUPro Toolkit from Red Hat is a complete solution for C and C development for AIX on PowerPC The tools include the compiler interactive debugger and utilities libraries This User s Guide consists of an introduction to the features of the GNUPro Toolkit as well as a tutorial and reference for IBM AIX specific features of the m
16. braries to the binary code and produces an executable binary image 1d attempts to emulated the native AIX linker although there are differences The default output format is xcof 32 which can also be explicitly set by using the b32 command line option or by setting the environmental variable DEMULATION aixppc An optional output format is xcof 64 explicitly set by using the b64 command line option or by setting the environmental variable DEMULATION aixppc64 The compiler utility collect2 handles the mapping of maix32 and maix64 to the correct output format To support AIX 4 2 and C constructors and destructors a special linker option to the compiler binitfini has special handling in the linker backend The native linker uses the arguments to generate a table of init and fini functions for the executable The function table is accessed by the runtime linker loader by checking if the first symbol in the loader symbol table is__rtinit The native linker generates this table and the loader symbol 1d looks for the __rt init symbol and makes it the first loader symbol So it is your responsibility to define the __rtinit symbol The format for __rtinit is given by the AIX system file usr include rtinit h Example 1 shows a 32 bit assembly file that defines ___ rt init collect2 handles emitting the __rtinit symbol when the binit fin option is given to GCC 26 M User s Guide for AIX on PowerPC GNUPro Toolkit L
17. bytes 8 bytes float 4 bytes 4 bytes double 8 bytes 4 bytes pointer 8 bytes 8 bytes Table 7 shows how the registers are used for 64 bit ABI 20 m User s Guide for AIX on PowerPC GNUPro Toolkit 64 Bit ABI Summary Table 7 Register usage for 64 bit ABI Register Usage r0 Volatile register used in function prologs eL Stack frame pointer r2 TOC pointer ES Volatile parameter and return value register r4 through r10 Volatile registers used for function parameters r11 through r12 Volatile registers used during function calls r13 Reserved for thread private data r14 through r31 Nonvolatile registers used for local variables 0 Volatile scratch register 1 through 4 Volatile floating point parameter and return value registers 5 through 13 Volatile floating point parameter registers 14 through 31 Nonvolatile registers LR Link register volatile CTR Loop counter register volatile XER Fixed point exception register volatile FPSCR Floating point status and control register volatile CRO CR1 Volatile condition code register fields CR2 CR4 Nonvolatile condition code register fields CR5 CR7 Volatile condition code register fields Registers r1 r14 through r31 and 14 through 31 are nonvolatile which means that they preserve their values across function calls Functions which use those registers must save the
18. chip For 32 bit chips there are 32 32 bit general integer registers named ro through r31 For 64 bit chips there are 32 64 bit general integer registers named ro through r31 There are 32 64 bit floating point registers named 0 through 31 The compiler will generate assembly code which uses the numbers zero through 31 to represent general purpose registers See Table 9 for symbols to use as aliases for individual registers Table 9 Aliases for registers Symbol Register sp rl toc r2 The GNU tools recognize the PowerPC s special registers see Table 10 Table 10 Special registers Symbol Register LE Link register ctr Count register cr0 through cr7 Condition registers Other PowerPC special registers xer fpscr etc are supported by the GNU tools but do not have names since they are used implicitly by specific instructions qv mcrx these registers may also be referenced in assembly language by number The initial character in all assembler directives is the dot The directives are mri this first directive starts with two dots ABORT abort align appfile appline appline ascii asciz balign balignl balignw bb bc bf bi ba bas byte comm comm Common common s csect data data as deb wae a des ly rd Ss ade dE x wdehy debivb dcb ds debs dcb s dcb w dcb x debug def dim double ds ds b
19. d float Generates code that uses the floating point register set This is the default setting mmultiple Generates code that uses the load multiple word instructions and the store multiple word instructions These instructions are generated by default on POWER systems and not generated on PowerPC systems Do not use mmultiple on little endian PowerPC systems since those instructions do not work when the processor is in little endian mode The exceptions are PPC740 and PPC750 which permit the instructions usage in little endian mode mn multiple Generates code that does not use the load multiple word instructions and the store multiple word instructions These instructions are generated by default on POWER systems and not generated on PowerPC systems mstring Generates code that uses the load string instructions and the store string word instructions to save multiple registers and do small block moves These instructions are generated by default on POWER systems and not generated on PowerPC systems Do not use mstring on little endian PowerPC systems since those instructions do not work when the processor is in little endian mode The exceptions are PPC740 and PPC750 which permit the instructions in little endian mode mno string Generate code that does not use the load string instructions and the store string word instructions to save multiple registers and do small block moves These GNUPro Toolkit User s Guide for AIX on PowerPC
20. d to an ellipsis function Floating point double arguments are only passed in floating point registers If an ellipsis is present in the prototype floating point double arguments are passed in both floating point registers and general purpose registers When there are more argument words than available parameter registers the remaining words are passed in storage on the stack The values in storage are the same as if they were in registers Space for more than eight words of arguments floating point and nonfloating point must be reserved on the stack even if all the arguments were passed in registers The size of the parameter area is large enough to contain all the arguments passed on any call statement from a procedure associated with the stack frame Although not all the arguments for a particular call actually appear in storage they can be regarded as forming a list in this area each one occupying one or more words In C all function arguments are passed by value and the called function receives a copy of the value passed to it Call by value Parameters In prototype functions with a variable number of arguments indicated by an ellipsis as ina function the compiler widens all floating point arguments to double precision Integral arguments except for long int are widened to int The following information refers to call by value arguments are classified as floating point values or nonfloating point values Each nonfloating
21. ds d ds l ds p ds s ds w ds x eb ec ef ei eject else elsec elseif GNUPro Toolkit User s Guide for AIX on PowerPC m 25 Reference nd endc endef endfunc endif equ equiv err es exitm extern extern fail file fill float format func function global globl hword ident if ifc ifdef ifeq ifeqs ifge ifgt ifle iflt ifnc ifndef ifne ifnes ifnotdef include int irep irepc irp irpc 1comm 1comm lflags lglobl line linkonce list llen ln loc long long 1sym macro mexit mri name noformat nolist nopage octa offset optim org p2align p2alignl p2alignw page plen print psize purgem quad rename rep rept rva sbttl scl sect sect s section section s set short single size skip sleb128 space spc stabd stabn stabs stabx string struct tag tc text text this GCC requires the GNU assembler this gcc requires the gnu assembler title toc ttl type uleb128 val vbyte version weak word xcom xdef xref xstabs and zero See Assembler Directives in Using as in GNUPro Utilities for a description of what these directives do http www redhat com support manuals gnupro html Linker Features The GNU linker 1a resolves code addresses and debug symbols links the startup code and additional li
22. e always defined _AIX32 Indicates 32 bit mode Defined when maix32 is specified _ATX64 Indicates 64 bit mode Defined when maix64 is specified _LONG_LONG Is always defined Indicates support for the long long data type 14 m User s Guide for AIX on PowerPC GNUPro Toolkit 32 Bit ABI Summary ARCH_PWR Defined when compiling for the POWER architecture _ARCH_PWR2 Defined when compiling for the POWER2 architecture ARCH_PPC Defined when compiling for the PowerPC architecture ARCH_COM Defined when compiling for the common subset of the POWER and PowerPC architectures 32 Bit ABI Summary This section describes the 32 bit AIX Application Binary Interface ABI which the tools adhere to by default Table 3 shows the size and alignment for all data types Alignment within aggregates structures and unions is as shown with padding added if needed Aggregates have alignment equal to that of their most aligned member Aggregates have sizes which are a multiple of their alignment Table 3 Data type sizes and alignments for 32 bit ABI Type Size bytes Alignment bytes char 1 byte 1 byte short 2 bytes 2 bytes int 4 bytes 4 bytes unsigned 4 bytes 4 bytes long 4 bytes 4 bytes long long 8 bytes 8 bytes float 4 bytes 4 bytes double 8 bytes 4 bytes pointer 4 bytes 4 bytes Table 4 shows register usage GNUPro Toolkit User s Guide for AIX on
23. entry point Example 2 shows a typical linker script GNUPro Toolkit User s Guide for AIX on PowerPC m 27 Reference Example 2 Linker script 28 E User s Guide for AIX on PowerPC GNUPro Toolkit Debugger Features debug Debugger Features There are no PowerPC specific debugger command line options For a complete description of the GNUPro debugger see Debugging with GDB in GNUPro Debugging Tools GNUPro Toolkit User s Guide for AIX on PowerPC m 29 Reference 30 m User s Guide for AIX on PowerPC GNUPro Toolkit index Symbols __rtinit symbol 27 Numerics 32 bit ABI 15 64 bit ABI 20 A aggregate values 17 aggregates 15 20 alignment requirements 22 Application Binary Interface ABD 15 arguments 17 22 assembler 2 6 25 conventions 25 defining the __rtinit symbol 27 directives 25 instructions 2 labels 2 registers 25 B binary utilities 2 Bourne compatible shells setting PATH 3 C C shell setting PATH 3 case sensitivity 2 5 command line options 2 compiler 2 6 9 15 25 condition code register fields 16 21 contacting Red Hat ii conventions documentation 3 copyrights ii D data type sizes and alignments 32 bit 15 data type sizes and alignments 64 bit 20 debugger 2 5 29 documentation 1 3 double arguments 17 22 E environment pointer 18 environment variables setting 2 6
24. er there is a large common subset of instructions supported by both An MQ register is included in processors supporting the POWER architecture Use these options to specify which instructions are available on the processor you are using The default value of these options is determined when configuring GCC IMPORTANT The mcpu option overrides the specification of the options listed above It is recommended that you use the mcpu option instead of these options mpower allows GCC to generate instructions that are found only in the POWER architecture and to use the MQ register Specifying mpower2 implies power allowing GCC to generate instructions that are present in the POWER2 architecture but absent in the original POWER architecture mpowerpc allows GCC to generate instructions that are found only in the 32 bit subset of the PowerPC architecture Specifying mpowerpc gpopt implies mpowerpc and also allows GCC to use the optional PowerPC architecture instructions in the General Purpose group including floating point square root Specifying mpowerpc gfxopt implies mpowerpc and also allows GCC to use the optional PowerPC architecture instructions in the Graphics group including floating point select If you specify both mno power and mno powerpc GCC will use only the instructions in the common subset of both architectures plus some special AIX common mode calls and will not use the MQ register Specifying both mpower and
25. f a call statement or an actual argument of such a statement A function pointer is a full word quantity that is the address of a function descriptor The function descriptor is a three word object The first word contains the address of the entry point of the procedure the second has the address of the TOC of the module in which the procedure is bound and the third is the environment pointer There is only one function descriptor per entry point It is bound into the same module as the function it identifies if the function is external The descriptor has an external name which is the same as the function name but without a leading dot This descriptor name is used in all import and export operations Function Return Values Functions pass their return values according to type see Table 5 for 32 bit ABI Table 5 Functions and value returned for 32 bit ABI Type Register int r3 short r3 long LS long long r3 and r4 float fpl double fpl structure and union Structures and unions that will fit into general purpose registers are returned in r3 or in r3 and r4 if necessary The caller handles larger structures and unions by passing a pointer to space allocated to receive the return value The pointer is passed as a hidden first argument 18 m User s Guide for AIX on PowerPC GNUPro Toolkit 32 Bit ABI Summary Stack Frames This section describes 32 bit PowerPC stack fr
26. file names within makefiles The following strings are not case sensitive debugger commands assembler instructions and register names For the tools to function properly you must set environment variables For the Microsoft Windows operating system use the following examples as input for setting enviornment variables for the tools Replaceinstalldir with your default installation directory yymmdd indicates the release date printed on the CD Replace H host where host signifies the toolchain s name with H 1686 cygwin as a name SI SI R ET PROOT C NinstalldirNaix yymmdd ET PATH PROOT NH hostNBIN PATH SET INFOPATH PROOT Ninfo EM Set TMPDIR to point to a ramdisk if you have one SE TMPDIR SPROOTS For the Sun Solaris and Red Hat Linux operating systems use the following examples as input for setting environment variables for the tools Replace installdir with your default installation directory yymmdd indicates the release date printed on the CD Replace H host where host signifies the toolchain s name with H sparc sun solaris2 6 for Sun Solaris or H i 686 pc linux gnu 2 E User s Guide for AIX on PowerPC GNUPro Toolkit for Red Hat Linux 6 0 u For Bourne compatible shells bin sh bash or Korn shell use the following example s input PROOT installdir aix yymmdd PATH PROOT H host bin PATH INFOPATH PROOT info export PATH SID_E XEC_PREFIX INFOPATH
27. inker Features Example 1 Assembly file defining the __rt init symbol file my_rtinit s Csect data RW 3 globl _ rtinit extern init_ function extern fini function _ rtinit long 0 long fli _ rtinit Long f1f _ rtinit long f2i f1i align 3 EMIE Long init_ function long sli _ rtinit long 0 f2i long 0 long 0 long 0 flf long fini function long slf _ rtinit long 0 f2f long 0 long 0 long 0 align 3 sli string init function align 3 slf string fini function The following AIX linker options are not supported S v Z bbindcmds bbinder bbindopts bcalls bcaps bcror15 bdebugopt bdbg bdelcsect bex bfilelist bfl bgcbypass bglink binsert bi bloadmap bl bmap bnl bnobind bnocomprld bnocrld bnoerrmsg bnoglink bnoloadmap bnl bnoobjreorder bnoquiet bnoreorder bnotypchk bnox bquiet bR brename breorder btypchk bx bX and bxref For generic GNU Imker options see Command Language in Using 1d in GNUPro Utilities see http www redhat com support manuals gnupro html The GNU linker uses a script to determine how to process each section in an object file and how to lay out the executable The linker script is a declarative program consisting of a number of directives For instance the ENTRY directive specifies the symbol in the executable that will be the executable s
28. isters and general purpose registers When there are more argument words than available parameter registers the remaining words are passed in storage on the stack The values in storage are the same as if they were in registers Space for more than eight words of arguments floating point and nonfloating point must be reserved on the stack even if all the arguments were passed in registers The size of the parameter area is large enough to contain all the arguments passed on any call statement from a procedure associated with the stack frame Although not all the arguments for a particular call actually appear in storage they can be regarded as forming a list in this area each one occupying one or more words In C all function arguments are passed by value and the called function receives a copy of the value passed to it Call by value Parameters In prototype functions with a variable number of arguments indicated by an ellipsis as in function the compiler widens all floating point arguments to double precision Integral arguments except for long int are widened to int The following information refers to call by value In the following list arguments are classified as floating point values or nonfloating point values Each nonfloating scalar argument requires one word and appears in that word exactly as it would appear in a general purpose register Each floating point value occupies one word Float doubles occupy two s
29. l toc Modifies generation of the TOC Table Of Contents which is created for every executable file mfull toc is selected by default In that case GCC will allocate at least one TOC entry for each unique non automatic variable reference in your program GCC will also place floating point constants in the TOC However only 16 384 entries are available in the TOC If you receive a linker error message saying you have overflowed the available TOC space you can reduce the amount of TOC space used with mno fp in toc and mno sum in toc mno fp in toc prevents GCC from putting floating point constants in the TOC and mno sum in toc forces GCC to generate code to calculate the sum of an address and a constant at run time instead of putting that sum into the TOC you may specify one or both of these options each causing GCC to produce very slightly slower and larger code at the expense of conserving TOC space If you still run out of space in the TOC even when you specify both of these options specify mminimal toc instead which causes GCC to make only one TOC entry for every file When you specify mminimal toc GCC will produce code that is slower and larger using extremely little TOC space Use mminimal toc only on files that contain less frequently executed code mxl call Enables AIX XL compiler handling mno xl call Disables AIX XL compiler handling This is the default setting IMPORTANT On AIX pass floating point arguments
30. m 13 Reference instructions are generated by default on POWER systems and not generated on PowerPC systems mupdate Generate code that uses the load or store instructions that update the base register to the address of the calculated memory location These instructions are generated by default mno update Generate code that does not use the load or store instructions that update the base register to the address of the calculated memory location These instructions are generated by default If you use mno update there is a small window between the time that the stack pointer is updated and the address of the previous frame is stored this means code that walks the stack frame across interrupts or signals may get corrupted data mfused madd Generates code that uses the floating point multiply and accumulate instructions These instructions are generated by default if hardware floating point is used mno fused madd Generates code that does not use the floating point multiply and accumulate instructions These instructions are generated by default if hardware floating point is used maix64 Enables the 64 bit PowerPC ABI and calling conventions 64 bit pointers 64 bit long type and the infrastructure needed to support them maix32 Enables the 32 bit PowerPC ABI and calling conventions This is the default setting Preprocessor Symbols The compiler supports the following preprocessor symbols _IBMR2 _POWER _AIX Ar
31. ns A function pointer is a data type whose values range over function addresses Function pointers are supported in contexts such as the target of a call statement or an actual argument of such a statement A function pointer is a full word quantity that is the address of a function descriptor The function descriptor is a three word object The first word contains the address of the entry point of the procedure the second has the address of the TOC of the module in which the procedure is bound and the third is the environment pointer There is only one function descriptor per entry point It is bound into the same module as the function it identifies if the function is external The descriptor has an external name which is the same as the function name but without a leading dot This descriptor name is used in all import and export operations Function Return Values Functions pass their return values according to type see Table 8 Table 8 Function return values by type for 64 bit ABI Type Register int ES short r3 long ES long long E3 float fpl double fpl structure and union S The caller handles structures and unions by passing a pointer to space allocated to receive the return value The pointer is passed as a hidden first argument GNUPro Toolkit User s Guide for AIX on PowerPC m 23 Reference Stack Frames This section describes 64 bit PowerPC stack frames The st
32. o exit GDB type quit atthe gdb prompt The default prompt returns Assembler Listing from Source Code The following command produces an assembler listing gcc c g O Wa l hello c The c option tells GCC to compile or assemble the source files but not to link The 0 option produces optimized code The wa option tells the compiler to pass the comma separated list of options which follows it to the assembler The assembler option 1 requests an assembler listing Here is a partial excerpt of the output 0 221 foo 0 222 stabx foo F 11 f00 142 0 6 E User s Guide for AIX on PowerPC Red Hat 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 O OOO OO OO OO OO OO OO OO OO OO OO OO COM COM COM COM COM COM COM COM COM COM COM COM text text text text text text text text text text text text 00000000 00000004 00000008 0000000c 00000010 00000014 00000018 0000001c 00000020 00000024 00000028 0000002c function foo foo 16 gt bf 6 stabx b R 1 5 132 0 7c0802a6 90010008 9421ffc8 7c651b78 81620000 81220004 80890000 7cc52214 90cb0000 80620008 4bffffd9 60000000 line 1 extern _ mulh extern _ mull extern _ divss extern _ divus extern _ _quoss extern _ quous mflr 0 stw 0 8 1 stwu 1 56 1 mr 5 3 line 2 lwz 11 LC 0
33. ose registers LR CTR XER and FPSCR are volatile which means that they are not preserved across function calls Furthermore registers r0 r2 r11 and r12 may be modified by cross module calls so a function can not assume that the values of one of these registers is that placed there by the calling function The condition code register fields CRO CR1 CR5 CR6 and CR7 are volatile The condition code register fields CR2 CR3 and CR4 are nonvolatile so a function which modifies them must save and restore them Parameter Passing The linkage convention specifies the methods for parameter passing and whether return values are placed in floating point registers general purpose registers or both The general purpose registers available for argument passing are r3 through r10 The floating point registers available for argument passing are p3 through p13 16 User s Guide for AIX on PowerPC GNUPro Toolkit 32 Bit ABI Summary Prototyping affects how parameters are passed and whether parameter widening occurs In nonprototyped functions floating point arguments are widened to type double and integral types are widened to type int In prototyped functions no widening conversions occur except in arguments passed to an ellipsis function Floating point double arguments are only passed in floating point registers If an ellipsis is present in the prototype floating point double arguments are passed in both floating point reg
34. scalar argument requires one word and appears in that word exactly as it would appear in a general purpose register Each floating point value occupies one word Structure values appear in successive words as they would anywhere in storage satisfying all appropriate alignment requirements Structures align by rounding up to the nearest full word with any padding at the end A structure smaller than a word is left justified within its word or register Larger structures can occupy multiple registers and can be passed partly in storage and partly in registers Other aggregate values are passed by the caller making a copy of the structure and passing a pointer to that copy A function pointer is passed as a pointer to the routine s function descriptor The first word contains the entry point address 22 M User s Guide for AIX on PowerPC GNUPro Toolkit 64 Bit ABI Summary TOC Table of Contents The TOC is used to access global data by holding pointers to the global data The TOC section is accessed via the dedicated TOC pointer register r2 Accesses are normally made using the register indirect with immediate index mode supported by the PowerPC processor which limits a single TOC section to 65 536 bytes enough for 4 096 GOTO entries The value of the TOC pointer register is called the TOC base The TOC base is typically the first address in the TOC plus 0x8000 thus permitting a full 64 kilobyte TOC Pointers to Functio
35. uccessive words in the list Structure values appear in successive words as they would anywhere in storage satisfying all appropriate alignment requirements Structures align by rounding up to the nearest full word with any padding at the end A structure smaller than a word is left justified within its word or register Larger structures can occupy multiple registers and can be passed partly in storage and partly in registers Other aggregate values are passed by the caller making a copy of the structure and passing a pointer to that copy A function pointer is passed as a pointer to the routine s function descriptor The first word contains the entry point address GNUPro Toolkit User s Guide for AIX on PowerPC m 17 Reference TOC Table of Contents The TOC is used to access global data by holding pointers to the global data The TOC section is accessed via the dedicated TOC pointer register r2 Accesses are normally made using the register indirect with immediate index mode supported by the PowerPC processor which limits a single TOC section to 65 536 bytes enough for 8 192 GOTO entries The value of the TOC pointer register is called the TOC base The TOC base is typically the first address in the TOC plus 0x8000 thus permitting a full 64 kilobyte TOC Pointers to Functions A function pointer is a data type whose values range over function addresses Function pointers are supported in contexts such as the target o

Download Pdf Manuals

image

Related Search

Related Contents

株 主 各 位 柴野恒雄 第66期定時株主総会招集ご通知  VC3211H - Makita  InLine Patch Cat.6A S/FTP (PiMf) 500MHz 1.5m  Mode d`emploi - Leroy Merlin  Philips GoGear MP3 player SA2825    ドーム型ワンケーブルカメラ KB  Use and maintenance booklet of your Ridley bicycle  IAN 90976 - Lidl Service Website  nCounter™ Prep Station Information  

Copyright © All rights reserved.
Failed to retrieve file