• Masahiro Yamada's avatar
    asm_macros: set the default assembly code alignment to 4 byte · fed18b3a
    Masahiro Yamada authored
    Assembly routines are usually defined by using "func" and "endfunc":
    
        func foo
          ...
        endfunc foo
    
    Currently, the "func" macro does not specify ".align" directive
    by default.  It causes unaligned instruction under some circumstances.
    
    As far as I tested, this problem happens for GCC 5 or older.  It did
    not happen for GCC 6 or newer.  Taking into account that GCC 4.x / 5.x
    is still used, make sure that assembly code is at least 4 byte aligned.
    
    [ How to reproduce the problem ]
    
    For example, use GCC 5.3 downloaded from Linaro:
    http://releases.linaro.org/components/toolchain/binaries/5.3-2016.05/
    aarch64-linux-gnu/gcc-linaro-5.3.1-2016.05-x86_64_aarch64-linux-gnu.tar.xz
    
    Expand mbedtls-2.4.2 to the current directory.
    
    Try the following:
    
      $ git log --oneline -1
      77544efb
    
     Merge pull request #1071 from jeenu-arm/syntax-fix
      $ aarch64-linux-gnu-gcc --version | head -1
      aarch64-linux-gnu-gcc (Linaro GCC 5.3-2016.05) 5.3.1 20160412
      $ make CROSS_COMPILE=aarch64-linux-gnu- PLAT=uniphier \
        TRUSTED_BOARD_BOOT=1 MBEDTLS_DIR=mbedtls-2.4.2
        ( snip build log )
      $ aarch64-linux-gnu-nm build/uniphier/release/bl1/bl1.elf | grep handler
      00000000800088f4 T bl1_fwu_smc_handler
      00000000800084c8 T bl1_smc_handler
      000000008000a6e0 t _panic_handler
      000000008000a8e0 W plat_error_handler
      000000008000a8e8 W plat_panic_handler
      000000008000a8d8 W plat_reset_handler
      000000008000a39f T reset_handler
      000000008000a367 t smc_handler
      000000008000a2ef t smc_handler64
    
    You will notice "smc_handler64", "reset_handler", etc. are not properly
    aligned.
    Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
    fed18b3a
asm_macros_common.S 3.01 KB