Go to a specific address in C

How can I use JMP for a specific address in C?

I want to use

goto 0x10080000

This does not work, is there any other way to change the program counter address?

+4
source share
3 answers

You can specify the address of the function pointer, and then go to:

((void (*)(void))0x10008000)();

To make this clearer:

typedef void (*func_t)(void);
...
((func_t)0x10008000)();

But this is a function, the compiler will generate a branch instruction that expects to return (then you decide whether to return your function or not). Also note that the compiler will generate code that expects to find the C function at the given address, about how the function arguments are given and returned.

, .

+9

GCC goto. , :

void *address = 0x10080000;
...
goto *address;
+4

The assembly instructions should also work:

asm("jump 0x10080000");

+2
source

All Articles