1
$\begingroup$

I am reading a book about data architecture, and I am wondering about the text segment and the memory adresses.

In one example(assembly using ARM) where the code was compiled there were adresses to global variables. Does this mean that the executable is always loaded in the same place in the text segment?, so that the adresses of the variables are always the same?

$\endgroup$
1
  • 1
    $\begingroup$ Not if the code is... relocatable. $\endgroup$
    – user16034
    Aug 9, 2022 at 16:04

1 Answer 1

1
$\begingroup$

One protection against hacker attacks is “address space randomisation”. Basically code is always loaded to a different address, making it harder to attack. So on a modern device it’s very unlikely to be loaded to a fixed place.

There are two methods to support this: “relocatable code” can be modified at load time to work correctly in the place where it is loaded. “Position independent code” is designed to work correctly no matter where it is loaded.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.