Andreas Kling
d988bd86e4
LibELF: Map text segments read-only at first
...
To support upcoming W^X changes in the kernel, the dynamic loader needs
to be careful about the order in which permissions are added to shared
library text segments.
We now start by mapping text segments read-only (no-write, no-exec).
If relocations are needed, we make them writable, and then finally,
for all text segments, we finish by making them read+exec.
2021-01-29 14:52:22 +01:00
Andreas Kling
3438b77aa4
LibELF: Tidy up DynamicLoader::load_program_headers() a bit
...
Remove a confusing temporary, rename some things and add assertions.
2021-01-29 13:45:41 +01:00
Jorropo
c33d50872e
LibELF: perror on failed mmap in load_program_headers ( #5159 )
2021-01-29 08:50:43 +01:00
Andreas Kling
322c161ee4
LibELF: Implement ASLR for shared libraries :^)
...
Use mmap() with the new MAP_RANDOMIZED flag to load shared libraries at
random addresses in each process.
To avoid address space collisions, we start by doing a large chunk mmap
that covers enough VM for both text and data, then we unmap and remap
the data segment separately, once we know everything will fit.
This is pretty cool! :^)
2021-01-28 16:23:38 +01:00
Andreas Kling
67bc5e0bbd
DynamicLoader: Pass MAP_FIXED to mmap() where applicable
...
Otherwise the kernel is free to allocate a different address.
2021-01-27 21:14:42 +01:00
Andreas Kling
adcc1c1eff
LibELF: Cache the DynamicObject in DynamicLoader
...
This avoids reparsing the same dynamic library file multiple times.
2021-01-25 18:57:06 +01:00
Andreas Kling
41d8734288
LibELF: Use Optional<SymbolLookupResult> as a return type
...
Instead of storing a "found" state inside the result object.
2021-01-25 18:57:06 +01:00
Andreas Kling
a5de46684b
LibELF: Convert String::format() to String::formatted()
2021-01-25 18:57:06 +01:00
Andreas Kling
e9fd81b964
LibELF: Convert dbgprintf() in DynamicLoader class to dbgln()
2021-01-25 18:57:06 +01:00
asynts
eea72b9b5c
Everywhere: Hook up remaining debug macros to Debug.h.
2021-01-25 09:47:36 +01:00
asynts
acdcf59a33
Everywhere: Remove unnecessary debug comments.
...
It would be tempting to uncomment these statements, but that won't work
with the new changes.
This was done with the following commands:
find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec awk -i inplace '$0 !~ /\/\/#define/ { if (!toggle) { print; } else { toggle = !toggle } } ; $0 ~/\/\/#define/ { toggle = 1 }' {} \;
find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec awk -i inplace '$0 !~ /\/\/ #define/ { if (!toggle) { print; } else { toggle = !toggle } } ; $0 ~/\/\/ #define/ { toggle = 1 }' {} \;
2021-01-25 09:47:36 +01:00
Andreas Kling
13d7c09125
Libraries: Move to Userland/Libraries/
2021-01-12 12:17:46 +01:00