8.18 --branch_tables, --no_branch_tables

Controls whether the compiler places branch tables for switch statements in the code section or a separate data section.

The compiler uses several different techniques to generate code for switch statements. Some of these techniques create a table of branch offsets.

With the --branch_tables option, the compiler places the branch offset table in the code section. In the following example, lines highlighted with *** contain these branch offsets:

** Section #1 '.text' (SHT_PROGBITS) [SHF_ALLOC + SHF_EXECINSTR]
    Size   : 72 bytes (alignment 2)
    Address: 0x00000000

    $t
    .text
    f
        0x00000000:    b510        ..      PUSH     {r4,lr}
        0x00000002:    2807        .(      CMP      r0,#7
        0x00000004:    d21b        ..      BCS      {pc}+0x3a ; 0x3e
        0x00000006:    e8dff000    ....    TBB      [pc,r0]
    $d
        0x0000000a:    0704        ..      DCW    1796                  ***
        0x0000000c:    13100d0a    ....    DCDU   319819018             ***
        0x00000010:    0016        ..      DCW    22                    ***
    $t
        0x00000012:    2005        .       MOVS     r0,#5
        0x00000014:    f7fffffe    ....    BL       g

The --no_branch_tables option instructs the compiler to insert the branch offset table into a separate data section instead:

** Section #1 '.text' (SHT_PROGBITS) [SHF_ALLOC + SHF_EXECINSTR]
    Size   : 72 bytes (alignment 4)
    Address: 0x00000000
			
    $t
    .text
    f
        0x00000000:    b510        ..      PUSH     {r4,lr}
        0x00000002:    2807        .(      CMP      r0,#7
        0x00000004:    d218        ..      BCS      {pc}+0x34 ; 0x38
        0x00000006:    4b0f        .K      LDR      r3,[pc,#60] ; [0x44] = 0
        0x00000008:    e8d3f000    ....    TBB      [r3,r0]
        0x0000000c:    2005        .       MOVS     r0,#5
        0x0000000e:    f7fffffe    ....    BL       g
        ...
			
** Section #4 'c.f.00000006' (SHT_PROGBITS) [SHF_ALLOC]
    Size   : 7 bytes
    Address: 0x00000000
			
    0x000000:   00 03 06 09 0c 0f 12                               .......	

Default

The default is --branch_tables.

--execute_only implies --no_branch_tables, unless --branch_tables is explicitly specified.

Note:

Do not use --execute_only in conjunction with --branch_tables. If you do, then the compiler places the branch offset table in an unreadable, execute-only code region.
Non-ConfidentialPDF file icon PDF versionARM DUI0472M
Copyright © 2010-2016 ARM Limited or its affiliates. All rights reserved.