DynamoRIO / dynamorio

Dynamic Instrumentation Tool Platform
Other
2.62k stars 554 forks source link

remove fixed from elf_loader_map_phdrs #1183

Open derekbruening opened 9 years ago

derekbruening commented 9 years ago

From zhao...@google.com on June 07, 2013 10:56:33

elf_loader_map_phdrs(elf_loader_t *elf, bool fixed, map_fn_t map_func, unmap_fn_t unmap_func, prot_fn_t prot_func, bool reachable) is used to load a ELF object into memory.

fixed is to indicate if the object should be loaded into a fixed memory only. It is set true for executable and false for shared libraries, which causes issue #1001 where a PIE with preferred base at 0. So now fixed is only a hint and can be overwritten, but we will still enforce the addr for PIE with non-0 preferred base.

Do we really need fixed? It seems that MAP_FIXED is not that necessary, it basically means if there is a conflict, what should we do. MAP_FIXED will replace the target memory blindly, which might not be good as it kick-out some other memory. On the other hand, no MAP_FIXED will cause an executable shifted, which is not good either. I am not sure which one is better, maybe no fixed?

So the real question is, if there is a memory overlap and the elf object is not relocatable, what should we do?

Original issue: http://code.google.com/p/dynamorio/issues/detail?id=1183

derekbruening commented 9 years ago

From bruen...@google.com on June 07, 2013 08:16:26

The load should fail if it's not relocatable and its preferred base is not available. The question is, does our loader detect this later during relocation processing? If it does, we can just remove MAP_FIXED right now. If it doesn't and it thinks the load succeeded, we have to add a check before we can remove MAP_FIXED. Alternatively, we can check from the headers up front whether it's relocatable, and if not, pass MAP_FIXED.

Labels: OpSys-Linux