[U-Boot] [PATCH 2/4] arm: add %function attribute to assembly functions

Simon Glass sjg at chromium.org
Sat Feb 18 23:03:59 CET 2012


Hi Anesh,

On Wed, Feb 15, 2012 at 5:57 AM, Aneesh V <aneesh at ti.com> wrote:
> This is done using the following directive preceding
> each function definition:
>
> .type <func-name>, %function
>
> This marks the symbol as a function in the object
> header which in turn helps the linker in some cases.
>
> In particular this was found needed for resolving ARM/Thumb
> calls correctly in a build with Thumb interworking enabled.
>
> This solves the following problem I had reported earlier:
>
> "When U-Boot/SPL is built using the Thumb instruction set the
> toolchain has a  potential issue with weakly linked symbols.
> If a function has a weakly linked default implementation in C
> and a real implementation in assembly GCC is confused about the
> instruction set of the assembly implementation. As a result
> the assembly function that is built in ARM is executed as
> if it is Thumb. This results in a crash"
>
> Signed-off-by: Aneesh V <aneesh at ti.com>
> ---
> Changes from RFC to V1:
> - This change completely replaces the previous workaround for
>  the ARM/Thumb interwork problem, which was to wrap around
>  the assembly function in question with a naked C function
> ---
>  arch/arm/cpu/arm1136/omap24xx/reset.S          |    3 +-
>  arch/arm/cpu/arm1136/start.S                   |    7 +++-
>  arch/arm/cpu/arm1176/s3c64xx/cpu_init.S        |    3 +-
>  arch/arm/cpu/arm1176/s3c64xx/reset.S           |    3 +-
>  arch/arm/cpu/arm1176/start.S                   |    9 +++--
>  arch/arm/cpu/arm1176/tnetv107x/lowlevel_init.S |    3 +-
>  arch/arm/cpu/arm720t/lpc2292/iap_entry.S       |    3 +-
>  arch/arm/cpu/arm720t/start.S                   |   12 ++++--
>  arch/arm/cpu/arm920t/a320/reset.S              |    1 +
>  arch/arm/cpu/arm920t/at91/lowlevel_init.S      |    3 +-
>  arch/arm/cpu/arm920t/ep93xx/lowlevel_init.S    |    3 +-
>  arch/arm/cpu/arm920t/ks8695/lowlevel_init.S    |    3 +-
>  arch/arm/cpu/arm920t/start.S                   |    6 ++-
>  arch/arm/cpu/arm925t/start.S                   |    9 +++--
>  arch/arm/cpu/arm926ejs/at91/lowlevel_init.S    |    4 +-
>  arch/arm/cpu/arm926ejs/davinci/lowlevel_init.S |    3 +-
>  arch/arm/cpu/arm926ejs/davinci/reset.S         |    3 +-
>  arch/arm/cpu/arm926ejs/mx28/start.S            |    3 +-
>  arch/arm/cpu/arm926ejs/nomadik/reset.S         |    3 +-
>  arch/arm/cpu/arm926ejs/omap/reset.S            |    3 +-
>  arch/arm/cpu/arm926ejs/orion5x/lowlevel_init.S |    3 +-
>  arch/arm/cpu/arm926ejs/start.S                 |    9 +++--
>  arch/arm/cpu/arm926ejs/versatile/reset.S       |    3 +-
>  arch/arm/cpu/arm946es/start.S                  |    9 +++--
>  arch/arm/cpu/arm_intcm/start.S                 |   15 ++------
>  arch/arm/cpu/armv7/mx5/lowlevel_init.S         |    3 +-
>  arch/arm/cpu/armv7/mx6/lowlevel_init.S         |    3 +-
>  arch/arm/cpu/armv7/omap-common/lowlevel_init.S |    9 +++--
>  arch/arm/cpu/armv7/omap-common/reset.S         |    1 +
>  arch/arm/cpu/armv7/omap3/lowlevel_init.S       |   45 ++++++++++++++++--------
>  arch/arm/cpu/armv7/s5pc1xx/cache.S             |    2 +
>  arch/arm/cpu/armv7/s5pc1xx/reset.S             |    3 +-
>  arch/arm/cpu/armv7/start.S                     |    9 +++--
>  arch/arm/cpu/armv7/tegra2/lowlevel_init.S      |    1 +
>  arch/arm/cpu/armv7/u8500/lowlevel.S            |    6 ++-
>  arch/arm/cpu/ixp/start.S                       |    9 +++--
>  arch/arm/cpu/lh7a40x/start.S                   |    9 +++--
>  arch/arm/cpu/pxa/start.S                       |    6 ++-
>  arch/arm/cpu/s3c44b0/start.S                   |    6 ++-
>  arch/arm/cpu/sa1100/start.S                    |    9 +++--
>  arch/arm/lib/_ashldi3.S                        |    6 ++-
>  arch/arm/lib/_ashrdi3.S                        |    6 ++-
>  arch/arm/lib/_divsi3.S                         |    6 ++-
>  arch/arm/lib/_lshrdi3.S                        |    6 ++-
>  arch/arm/lib/_modsi3.S                         |    3 +-
>  arch/arm/lib/_udivsi3.S                        |    6 ++-
>  arch/arm/lib/memcpy.S                          |    3 +-
>  arch/arm/lib/memset.S                          |    3 +-
>  48 files changed, 186 insertions(+), 100 deletions(-)
>
> diff --git a/arch/arm/cpu/arm1136/omap24xx/reset.S b/arch/arm/cpu/arm1136/omap24xx/reset.S
> index 5f8343f..917a934 100644
> --- a/arch/arm/cpu/arm1136/omap24xx/reset.S
> +++ b/arch/arm/cpu/arm1136/omap24xx/reset.S
> @@ -30,7 +30,8 @@
>
>  #include <asm/arch/omap2420.h>
>
> -.globl reset_cpu
> +.type  reset_cpu, %function
> +.global        reset_cpu

Should we introduce a macro to deal with this rather than writing it
out each time? EXPORT()?

[snip]

Regards,
Simon


More information about the U-Boot mailing list