06.02.2013 Views

ARM Compiler toolchain Using the Linker - ARM Information Center

ARM Compiler toolchain Using the Linker - ARM Information Center

ARM Compiler toolchain Using the Linker - ARM Information Center

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

7.24 <strong>Using</strong> $Super$$ and $Sub$$ to patch symbol definitions<br />

7.24.1 See also<br />

Accessing and managing symbols with armlink<br />

There are situations where an existing symbol cannot be modified because, for example, it is<br />

located in an external library or in ROM code. In such cases you can use <strong>the</strong> $Super$$ and $Sub$$<br />

patterns to patch an existing symbol.<br />

To patch <strong>the</strong> definition of <strong>the</strong> function foo():<br />

$Super$$foo Identifies <strong>the</strong> original unpatched function foo(). Use this to call <strong>the</strong> original<br />

function directly.<br />

$Sub$$foo Identifies <strong>the</strong> new function that is called instead of <strong>the</strong> original function foo().<br />

Use this to add processing before or after <strong>the</strong> original function.<br />

Note<br />

The $Sub$$ and $Super$$ mechanism only works at static link time, $Super$$ references cannot<br />

be imported or exported into <strong>the</strong> dynamic symbol table.<br />

The following example shows how to insert a call to <strong>the</strong> function ExtraFunc() before <strong>the</strong> call to<br />

<strong>the</strong> legacy function foo().<br />

extern void ExtraFunc(void); extern void $Super$$foo(void):<br />

/* this function is called instead of <strong>the</strong> original foo() */<br />

void $Sub$$foo(void)<br />

{<br />

ExtraFunc(); /* does some extra setup work */<br />

$Super$$foo(); /* calls <strong>the</strong> original foo() function */<br />

/* To avoid calling <strong>the</strong> original foo() function<br />

* omit <strong>the</strong> $Super$$foo(); function call.<br />

*/<br />

}<br />

O<strong>the</strong>r information<br />

Example 7-7 <strong>Using</strong> $Super$$ and $Sub$$<br />

• ELF for <strong>the</strong> <strong>ARM</strong> Architecture,<br />

http://infocenter.arm.com/help/topic/com.arm.doc.ihi0044-/index.html<br />

<strong>ARM</strong> DUI 0474C Copyright © 2010-2011 <strong>ARM</strong>. All rights reserved. 7-28<br />

ID080411 Non-Confidential

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!