Load-time relocation and ASLR

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
dansmahajan
Member
Member
Posts: 62
Joined: Mon Jan 07, 2013 10:38 am

Load-time relocation and ASLR

Post 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??
dansmahajan
Member
Member
Posts: 62
Joined: Mon Jan 07, 2013 10:38 am

Re: Load-time relocation and ASLR

Post 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 ???
alexfru
Member
Member
Posts: 1112
Joined: Tue Mar 04, 2014 5:27 am

Re: Load-time relocation and ASLR

Post 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.
dansmahajan
Member
Member
Posts: 62
Joined: Mon Jan 07, 2013 10:38 am

Re: Load-time relocation and ASLR

Post 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 ??
alexfru
Member
Member
Posts: 1112
Joined: Tue Mar 04, 2014 5:27 am

Re: Load-time relocation and ASLR

Post 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.
dansmahajan
Member
Member
Posts: 62
Joined: Mon Jan 07, 2013 10:38 am

Re: Load-time relocation and ASLR

Post 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.
Post Reply