Page 1 of 1

Load-time relocation and ASLR

Posted: Mon Sep 15, 2014 10:49 am
by dansmahajan
I've a confusion regarding load-time relocation, suppose there are two different shared libraries (having no common symbols) viz. "a.so" and "b.so",compiled with -shared option(no -fpic) and
some code "x" is linked with library "a.so" and other independent code "y" is linked with both the libraries.

After loading these codes, common library "a.so" was loaded at different address ??
Clearly dynamic linker/loader has to perform relocation two times resulting in extra computing and moreover library was consuming space in both the process. Doesn't that defeat the whole purpose of the shared libraries ??
Is ASLR the reason behind this ??
So with load-time libraries what have we gained (apart from saved disk space)???

One more question if above assumption is correct then why windows dll (32bit) is not using pic??
Can someone drag me to epiphany??

Re: Load-time relocation and ASLR

Posted: Mon Sep 15, 2014 11:31 am
by dansmahajan
ASLR in windows works by calculating some offset at the boot time. This technique might be good for client systems but for servers doesn't it makes the code susceptible ???

Re: Load-time relocation and ASLR

Posted: Mon Sep 15, 2014 12:16 pm
by alexfru
dansmahajan wrote:ASLR in windows works by calculating some offset at the boot time. This technique might be good for client systems but for servers doesn't it makes the code susceptible ???
That bootime ASLR offset affects only the kernel. Apps are affected differently every time they're loaded into memory.

Re: Load-time relocation and ASLR

Posted: Mon Sep 15, 2014 8:23 pm
by dansmahajan
alexfru wrote:
dansmahajan wrote:ASLR in windows works by calculating some offset at the boot time. This technique might be good for client systems but for servers doesn't it makes the code susceptible ???
That bootime ASLR offset affects only the kernel. Apps are affected differently every time they're loaded into memory.
Then why to have base address for each DLL ??

Re: Load-time relocation and ASLR

Posted: Mon Sep 15, 2014 9:37 pm
by alexfru
dansmahajan wrote: Then why to have base address for each DLL ??
There was life before ASLR! :) Further, some EXEs and DLLs aren't relocatable and can function only when loaded at a specific address.

Re: Load-time relocation and ASLR

Posted: Wed Sep 17, 2014 10:11 am
by dansmahajan
Shared library issue was due to lazy loading not because of ASLR. First call was made to the other library resulting in different address and relocation.