You copied the Doc URL to your clipboard.

__attribute__((alias)) function attribute

This function attribute enables you to specify multiple aliases for a function.

Aliases must be defined in the same translation unit as the original function.


You cannot specify aliases in block scope. The compiler ignores aliasing attributes attached to local function definitions and treats the function definition as a normal local definition.

In the output object file, the compiler replaces alias calls with a call to the original function name, and emits the alias alongside the original name. For example:

static int oldname(int x, int y) {
     return x + y;
static int newname(int x, int y) __attribute__((alias("oldname")));
int caller(int x, int y) {
     return oldname(x,y) + newname(x,y);

This code compiles to:

newname                  ; Alternate entry point
oldname PROC
     MOV      r2,r0
     ADD      r0,r2,r1
     BX       lr
caller PROC
     PUSH     {r4,r5,lr}
     MOV      r3,r0
     MOV      r4,r1
     MOV      r1,r4
     MOV      r0,r3
     BL       oldname
     MOV      r5,r0
     MOV      r1,r4
     MOV      r0,r3
     BL       oldname
     ADD      r0,r0,r5
     POP      {r4,r5,pc}

If the original function is defined as static but the alias is defined as extern, then the compiler changes the original function to be external.


This function attribute is a GNU compiler extension that the ARM compiler supports.


Variables names might also be aliased using the corresponding variable attribute __attribute__((alias)).

return-type newname ([argument-list]) __attribute__((alias(" oldname ")));



is the name of the function to be aliased


is the new name of the aliased function.

#include <stdio.h>
void foo(void)
    printf("%s\n", __FUNCTION__);
void bar(void) __attribute__((alias("foo")));
void gazonk(void)
    bar(); // calls foo