7.5.1. Direct PLTs

A direct PLT has the data entry stored with the PLT sequence code. Therefore a direct PLT looks like a veneer added to a statically linked image, apart from the relocation in the data entry. Therefore the code and data items are stored in the code section of the module. Figure 7.1 shows a direct PLT and the relocation against it.

Figure 7.1. Function calls via direct PLTs

To view this graphic, your browser must support the SVG format. Either install a browser with native support, or install an appropriate plugin such as Adobe SVG Viewer.


Example 7.3. Sample output from fromelf -c image

** Section #1 'ER_RO' (SHT_PROGBITS) [SHF_ALLOC + SHF_EXECINSTR]
    Size   : 40 bytes (alignment 4)
    Address: 0x00008000

    $t
        0x00008000:    4778        xG      BX       pc
        0x00008002:    46C0        .F      MOV      r8,r8
    $a
        0x00008004:    E59FC000    ....    LDR      r12,[pc,#0] ; [0x800C] = 0
        0x00008008:    E12FFF1C    ../.    BX       r12
    $d
        0x0000800C:    00000000    ....    DCD    0
    $a
    .text
    foo
        0x00008010:    E92D4010    .@-.    PUSH     {r4,lr}
        0x00008014:    EBFFFFFA    ....    BL       0x8004 ; 0x8004
        0x00008018:    E59F0004    ....    LDR      r0,[pc,#4] ; [0x8024] = 0
        0x0000801C:    E5900000    ....    LDR      r0,[r0,#0]
        0x00008020:    E8BD8010    ....    POP      {r4,pc}
    $d
        0x00008024:    00000000    ....    DCD    0

This example output from fromelf shows the same code sequence for function foo, as described in BPABI relocation example. However, this time the output shows the complete output for the section (#1), which also includes the PLT sequence from address 0x8000 to 0x800C. The BL instruction within function foo branches to the PLT sequence. The PLT sequence at address 0x8004 loads an address into register R12 and then branches to that address. The value loaded into R12 is located at address 0x800C, which is the first entry in the dynamic relocation section, as described in BPABI relocation example. The dynamic linker must fill in the relocation when it loads the shared library into memory. This PLT sequence can be shared across different units, so that other functions that call bar can do so dynamically. The final part of the PLT sequence, not already described, is the Thumb code from address 0x8000-0x8004. This code, generated by the static linker, acts as a dynamic interworking veneer, so that it is possible for Thumb functions to safely call bar.

Copyright © 2010 ARM. All rights reserved.ARM DAI 0242A
Non-ConfidentialID011411