Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I tell if jump is absolute or relative?

I'm studying for a test in assembly and in the subject of "Position-Independent-Code" I find the difference between a relative jump and an absolute jump confusing. How can I tell what kind of jump it is?

I understand what a relative jump is (the offset from current line). But what does an absolute jump look like? When does it happen?

like image 216
lolu Avatar asked Dec 02 '22 16:12

lolu


1 Answers

Anything that looks like just plain jmp label is relative.

Absolute jumps look like

  • jmp register
  • jmp [address]
  • jmp segment:absoluteaddr
  • jmp far [address]

Any far jump is absolute, any indirect jump is absolute, the combination (far, indirect) is therefore also absolute. Far jump only happen when necessary (you have to change cs and it's not a call). Indirect jumps are used for function pointers, branch tables (used in some cases for switch statements), dynamic dispatch (virtual methods) and maybe for imported functions (usually you call them, but maybe it's a tail call).

like image 50
harold Avatar answered Dec 20 '22 03:12

harold