0

I have read about ASLR and understand that it randomizes the location in memory where an executable is loaded every time it is run.

But I have a doubt, take an example of an elf executable. It tells where the program should be loaded in virtual memory, at what virtual memory address it should be loaded. Let us take for example a program that should be loaded at va 0x00000040 and it is necessary for it to be loaded there because if it made a jmp call or anything related to where the memory address linker had put the address in reference with where it is loaded.

If the program is loaded at va 0x40 and link address is also 0x40 and instruction there is to jmp to 0x45 if program is loaded at va 0x40 then jmp will be at right place, but imagine if the program is loaded at address 0x100 than jmp 0x45 is not where it should jmp.

How does ASLR do this?

forest
  • 64,616
  • 20
  • 206
  • 257
OSdev
  • 1
  • Thanks for suggesting but i read but it not solved my doubt – OSdev Mar 21 '22 at 06:00
  • 4
    Programs using ASLR must use [position independent code](https://en.wikipedia.org/wiki/Position-independent_code). Any remaining absolute addresses need to be fixed by the program loader when loading the program into memory. – Steffen Ullrich Mar 21 '22 at 06:10
  • @SteffenUllrich Thanks a lot it solved my problem – OSdev Mar 21 '22 at 06:29

0 Answers0