12.07.2015 Views

The ARM-THUMB Procedure Call Standard

The ARM-THUMB Procedure Call Standard

The ARM-THUMB Procedure Call Standard

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>The</strong> <strong>ARM</strong>-<strong>THUMB</strong> <strong>Procedure</strong> <strong>Call</strong> <strong>Standard</strong><strong>The</strong> identity of a dynamically loaded library can be assigned statically or when the library is loaded. If it is assignedwhen the library is loaded, at least one location in the library’s read-only segment must be relocated.Whether one location or many needs to be relocated depends on how the library has been built— on whether thecode establishing the new static base is inline in each static-data-using routine, or out of line in one place.8.2.1 Basic static data addressing in a shared-library-using applicationIn the simplest possible program structure:oA number of client programs and a number of shared libraries are statically linked together. <strong>Call</strong>s betweenfunctions are direct.o <strong>The</strong> clients are built the same way as the libraries (this is not necessary— see, for example, section 8.2.3,Base-standard clients). By convention, the library index of the clients is 0.ooEach client executes in a separate process.<strong>The</strong> index of a library is the same in every process threading it.On starting up, each client establishes the following conditions, maintained invariant by clients and libraries:oo0[SB] points to a process data table (PDT), specific to the process.PDT[N] points to the static data for shared library N in this process.On entry to any routine, SB identifies it caller’s static data. After saving SB (<strong>ARM</strong>-state) or allocating a local staticbase (LSB) register (Thumb-state), a static-data-using routine can find its static data using LSB = 0[SB][N].On return, SB is restored (<strong>ARM</strong>-state) or unchanged (Thumb-state).8.2.2 Exported dataAlthough the offset of a datum within a library’s static data is fixed when the library is statically linked, offsetsbetween static data areas are not fixed, even if the entire system is statically linked. For example, the offsetsbetween library static data areas may be different in different processes threading the libraries.For this reason, a reference to a datum exported by another link unit (shared library or client) must be indirect, viaan address relocated when the static data is allocated. In other words, access to directly exported data requiresan element of dynamic linking. This standard does not specify how this done. <strong>ARM</strong> C and C++ tools use an extraindirection to address data identified asextern __shared_library exported_thing;That is, the address of exported_thing will be loaded SB-relative, then de-referenced. <strong>The</strong> dynamic linker mustrelocate this address when the library is attached to the process. Details are specific to the operating environment.8.2.3 Base-standard clientsA client program can be built non-re-entrant using:oo<strong>The</strong> shared-library-friendly (v6-avoiding) variant of the base standard in <strong>ARM</strong>-state.<strong>The</strong> base standard in Thumb-state.Such code addresses its static data (usually) by loading the address of a datum PC-relative. Such code must notbe threaded by more than once process.Because such code knows how to address its static data independent of SB, it is always safe for shared librarycode to call it directly.SWS ESPC 0002 A-05 Page 30 of 37

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!