| |||
| Home > Compiler Command-line Options > Command-line options > --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.
--apcs=qualifer...qualifier
Where denotes
a list of qualifiers. There must be:qualifier...qualifier
at least one qualifier present
no spaces separating individual qualifiers in the list.
Each instance of must
be one of:qualifier
/[no]interworkGenerates code with or without ARM/Thumb™ interworking support. The
default is /nointerwork.
/[no]ropiEnables or disables the generation of Read-Only Position-Independent (ROPI)
code. The default is /noropi.
/[no]pic is an alias for /[no]ropi.
/[no]rwpiEnables or disables the generation of Read/Write Position-Independent (RWPI)
code. The default is /norwpi.
/[no]pid is an alias for /[no]rwpi.
/[no]fpicEnables or disables the generation of read-only position-independent code where relative address references are independent of the location where your program is loaded.
You can alternatively specify multiple qualifiers. For example, --apcs=/nointerwork/noropi/norwpi is
equivalent to --apcs=/nointerwork --apcs=noropi/norwpi.
If you do not specify an --apcs option, the
compiler assumes --apcs=/nointerwork/noropi/norwpi.
/[no]interworkBy 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]ropiIf
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.
--apcs=/ropi is not supported when compiling
C++.
/[no]rwpiIf
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.
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]fpicIf 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.
There are restrictions when you compile code with /ropi,
or /rwpi, or /fpic.
/ropiThe 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 option.
For example:--lower_ropi
armcc --apcs=/ropi --lower_ropi
/rwpiThe 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
You do not have to specify --lower_rwpi,
because this is the default.
/fpicThe 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.
Writing reentrant and thread-safe code in the Libraries Guide
Veneer generation in the Linker Guide
Chapter 6 BPABI and System V Shared Libraries and Executables in the Linker Guide
Procedure Call Standard for the ARM architecture in .install_directory\Documentation\Specifications\...