Aliases must be defined in the same translation unit as the original
function.
Note
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:
AREA ||.text||, CODE, READONLY, ALIGN=2
newname ; Alternate entry point
oldname PROC
MOV r2,r0
ADD r0,r2,r1
BX lr
ENDP
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}
ENDP
Note
This function attribute is a GNU compiler extension that the
ARM compiler supports.
Note
Variables names might also be aliased using the
corresponding variable attribute __attribute__((alias))
.