2.1.4. --apcs=qualifer...qualifier

This option controls interworking and position independence when generating code.

By specifying qualifiers to the --apcs command-line option, you can define the variant of the Procedure Call Standard for the ARM architecture (AAPCS) used by the compiler.

Syntax

--apcs=qualifer...qualifier

Where qualifier...qualifier denotes a list of qualifiers. There must be:

  • at least one qualifier present

  • no spaces separating individual qualifiers in the list.

Each instance of qualifier must be one of:

/[no]interwork

Generates code with or without ARM/Thumb™ interworking support. The default is /nointerwork.

/[no]ropi

Enables or disables the generation of Read-Only Position-Independent (ROPI) code. The default is /noropi.

/[no]pic is an alias for /[no]ropi.

/[no]rwpi

Enables or disables the generation of Read/Write Position-Independent (RWPI) code. The default is /norwpi.

/[no]pid is an alias for /[no]rwpi.

/[no]fpic

Enables or disables the generation of read-only position-independent code where relative address references are independent of the location where your program is loaded.

Note

You can alternatively specify multiple qualifiers. For example, --apcs=/nointerwork/noropi/norwpi is equivalent to --apcs=/nointerwork --apcs=noropi/norwpi.

Default

If you do not specify an --apcs option, the compiler assumes --apcs=/nointerwork/noropi/norwpi.

Usage

/[no]interwork

By default, code is generated:

  • without interworking support, that is /nointerwork, unless you specify a --cpu option that corresponds to architecture ARMv5T or later

  • with interworking support, that is /interwork, for ARMv5T or later. This is because ARMv5T or later provides direct interworking support.

/[no]ropi

If you select the /ropi qualifier to generate ROPI code, the compiler:

  • addresses read-only code and data PC-relative

  • sets the Position Independent (PI) attribute on read-only output sections.

Note

--apcs=/ropi is not supported when compiling C++.

/[no]rwpi

If you select the /rwpi qualifier to generate RWPI code, the compiler:

  • addresses writable data using offsets from the static base register sb. This means that:

    • the base address of the RW data region can be fixed at runtime

    • data can have multiple instances

    • data can be, but does not have to be, position-independent.

  • sets the PI attribute on read/write output sections.

Note

Because the --lower_rwpi option is the default, code that is not RWPI is automatically transformed into equivalent code that is RWPI. This static initialization is done at runtime by the C++ constructor mechanism, even for C.

/[no]fpic

If you select this option, the compiler:

  • accesses all static data using PC-relative addressing

  • accesses all imported or exported read-write data using a Global Offset Table (GOT) entry created by the linker

  • accesses all read-only data relative to the PC.

You must compile your code with /fpic if it uses shared objects. This is because relative addressing is only implemented when your code makes use of System V shared libraries.

You do not need to compile with /fpic if you are building either a static image or static library.

The use of /fpic is supported when compiling C++. In this case, virtual table functions and typeinfo are placed in read-write areas so that they can be accessed relative to the location of the PC.

Restrictions

There are restrictions when you compile code with /ropi, or /rwpi, or /fpic.

/ropi

The main restrictions when compiling with /ropi are:

  • The use of --apcs=/ropi is not supported when compiling C++.

  • Some constructs that are legal C do not work when compiled for --apcs=/ropi. For example:

    extern const int ci; // ro
    const int *p2 = &ci; // this static initialization
                         // does not work with --apcs=/ropi
    

    To enable such static initializations to work, compile your code using the --lower_ropi option. For example:

    armcc --apcs=/ropi --lower_ropi
    
/rwpi

The main restrictions when compiling with /rwpi are:

  • Some constructs that are legal C do not work when compiled for --apcs=/rwpi. For example:

    int i;               // rw
    int *p1 = &i;        // this static initialization
                         // does not work with --apcs=/rwpi
                         // --no_lower_rwpi
    

    To enable such static initializations to work, compile your code using the --lower_rwpi option. For example:

    armcc --apcs=/rwpi
    

    Note

    You do not have to specify --lower_rwpi, because this is the default.

/fpic

The main restrictions when compiling with /fpic are:

  • If you use --apcs=/fpic, the compiler exports only functions and data marked __declspec(dllexport).

  • If you use --apcs=/fpic and --no_hide_all on the same command line, the compiler ignores __declspec(dll*) and exports all extern variables and functions. The compiler disables auto-inlining for exported functions.

  • If you use --apcs=/fpic in GNU mode, you must also use --no_hide_all.

See also

Copyright © 2007, 2010 ARM Limited. All rights reserved.ARM DUI 0348A
Non-Confidential