Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Near and Far JMPs

Tags:

x86

assembly

nasm

I am doing Linux assembly and I understand that is has a flat memory model. What I am confused about is NEAR and FAR JMPs.

NEAR is in the same segment while FAR is another segment. From what I understand there are no segments in linux virtual memory? Also how do we know if my program's code is laid out in multiple segments?

like image 937
ST-User Avatar asked Feb 11 '13 12:02

ST-User


1 Answers

It hasn't been segments for a long time now. The correct term in protected mode x86 is selector.

Having said that, the difference between a near jump and a far one is that the former maintains the same code selector cs while the latter (usually) changes it.

In a flat memory model, the former case is almost always how it's done.

You could have an operating system where the flat memory model is served by multiple selectors but I can't see a useful use case for it, and it's not the way Linux works, at least on x86.

like image 99
paxdiablo Avatar answered Sep 27 '22 17:09

paxdiablo