News for hackers. Stuff that matters.
Re:32-bit x86 Position Independent Code – It's That Bad by JoshTriplett on Wednesday April 15, 2015 @01:29AM (#9379049)
> Instead of PIC, a big tables of places to patch with the final position.

Among other things, because that means the text section has to be writeable, and can't have a shared mapping across processes unless it's mapped in the same place in every process, which breaks address-space layout randomization (ASLR).

Re:32-bit x86 Position Independent Code – It's That Bad by atesti on Wednesday April 15, 2015 @01:41AM (#9379076)
On Windows, one can decide a default position for each DLL and if one is lucky, there is space available in that area of the virtual address space. Otherwise the loader needs to do the relocation work and modify pages and make them writeable temporarily.

If multiple processes load the same DLL and the default location happens to be chosen well and there is virtual address space in every process, then the linker can simply share the DLL.

That's how I think it was before ASLR came around.

I think Windows removes the writeable-flag again after relocating.

For the area I described (Mono's JIT vs. Mono's ahead of time compilation as PIC .so-file) I personally don't care that much for ASLR, because it's a managed language and because of specific circumstances of that project.

Re:32-bit x86 Position Independent Code – It's That Bad by JoshTriplett on Wednesday April 15, 2015 @02:03AM (#9379145)
Linux had a similar mechanism, "prelink", which also completely broke with ASLR.
Re:32-bit x86 Position Independent Code – It's That Bad by userbinator on Wednesday April 15, 2015 @06:56AM (#9380050)
Windows has ASLR too (since Vista) and it works with existing DLLs. Only pages which contain relocations can't be shared, which in practice means only code that accesses global data (including calls through the import table to other modules.) All the other pages can be.

The whole process image is writable when the loader is running - else how could it load the code into memory? :-) Section attributes are applied after loading.

Re:32-bit x86 Position Independent Code – It's That Bad by dblohm7 on Wednesday April 15, 2015 @02:26PM (#9383034)
Windows doesn't store those thunks in the text section. They're in the .idata section instead.
Re:32-bit x86 Position Independent Code – It's That Bad by yoklov on Wednesday April 15, 2015 @09:02AM (#9380646)
Off topic, but does anybody know if there's a way to turn off ASLR e.g. while debugging (honestly, i'd be interested if you can do this on any platform)? I'm pretty confident the answer is no, but it can really be a pain sometimes...
Re:32-bit x86 Position Independent Code – It's That Bad by tekacs on Wednesday April 15, 2015 @01:03PM (#9382394)
Either the linker, or GDB (or your debugger) can disable it for you. Under GDB it's controlled by the setting disable-randomization (defaults to false).
Re:32-bit x86 Position Independent Code – It's That Bad by detaro on Wednesday April 15, 2015 @09:07AM (#9380676)
/proc/sys/kernel/randomize_va_space on Linux?
Re:32-bit x86 Position Independent Code – It's That Bad by rwallace on Wednesday April 15, 2015 @12:12PM (#9381950)
On Windows, the linker has an option to do that.
Re:32-bit x86 Position Independent Code – It's That Bad by zurn on Thursday April 16, 2015 @01:31AM (#9386030)
setarch x86_64 --addr-no-randomize myprogram args...

(or -R for short)