|ARM Technical Support Knowledge Articles|
$Super mechanism applies to Global Symbols.
The linker applies the following transformation:
1.) Definition of
$Sub$$<Symbol Name> is renamed to
2.) Original definition of
<Symbol Name> is renamed to
This has the effect of swapping
$Sub$$<Symbol Name> with
<Symbol Name> allowing access to the original with
It is not restricted to Code Symbols, although that is the most common use case. It is possible to use
$Super/$Sub to patch const data as well. Please see the following example:
const int aa = 0;
const int $Sub$$aa = 2;
extern const int aa;
printf("aa = %d \n", aa);
 Command lines:
armcc -c -g test1.c main.c
armlink -o main.axf test1.o main.o
aa = 0
 Command lines:
armcc -c -g test1.c test2.c main.c
armlink -o main.axf test1.o test2.c main.o
aa = 2
This can be more complicated if you are trying to patch const data generated in the compiler. In general if the data is Global and visible outside the object the compiler has to label the data with a Symbol, which can in theory be "patched" by the
$Sub/$Super mechanism. However we must be careful about optimisations that the compiler might make, for example if there are multiple const data symbols the compiler will load a pointer to the start of the data section and access the data as an offset from that base (base pointer sharing optimization). The
$Sub/$Super mechanism will not work in this case as the compiler has not used a relocation to the name of the data.
If the code can be rewritten it is possible to prevent the compiler from using the base pointer optimisation by compiling the .constdata separately from the code accessing it.
If performance is not critical then data access could be abstracted behind a non-inline function. To patch the data, simply patch the function.
1. Using $Super$$ and $Sub$$ to patch symbol definitions
Article last edited on: 2011-09-30 17:07:23
Did you find this article helpful? Yes No
How can we improve this article?