[C/C++] Indirect branch…

“indirect branch” means “branching into value of register”. Usual branching jumps to the address computed from argument value and PC – PC relative address. So, there is offset limitation. But, ‘indirect jump’ can go to anywhere within supported address – usually, register size == instruction domain size == supporting memory size.

Here ARM example.

BX LR,
LDR PC, XX,
ADD PC, XX, XX

Then, which case can be interpreted to ‘indirect branch’ in C/C++ – Yes, it’s totally dependent on compiler. We just assume general case?

* Return from function call. (BX LR)
* Function call by "function pointer" (LDR PC, XX)
    - using function pointer explicitly.
    - using virtual function pointer table of class.
... anything else???
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s