Next: , Previous: Pragma Link_With, Up: Implementation Defined Pragmas


Pragma Linker_Alias

Syntax:

     pragma Linker_Alias (
       [Entity =>] LOCAL_NAME,
       [Target =>] static_string_EXPRESSION);

LOCAL_NAME must refer to an object that is declared at the library level. This pragma establishes the given entity as a linker alias for the given target. It is equivalent to __attribute__((alias)) in GNU C and causes LOCAL_NAME to be emitted as an alias for the symbol static_string_EXPRESSION in the object file, that is to say no space is reserved for LOCAL_NAME by the assembler and it will be resolved to the same address as static_string_EXPRESSION by the linker.

The actual linker name for the target must be used (e.g. the fully encoded name with qualification in Ada, or the mangled name in C++), or it must be declared using the C convention with pragma Import or pragma Export.

Not all target machines support this pragma. On some of them it is accepted only if pragma Weak_External has been applied to LOCAL_NAME.

     --  Example of the use of pragma Linker_Alias
     
     package p is
       i : Integer := 1;
       pragma Export (C, i);
     
       new_name_for_i : Integer;
       pragma Linker_Alias (new_name_for_i, "i");
     end p;