summaryrefslogtreecommitdiff
path: root/gnu/usr.bin/binutils/ld/ldmain.c
diff options
context:
space:
mode:
authorDale Rahn <drahn@cvs.openbsd.org>2003-01-17 20:50:14 +0000
committerDale Rahn <drahn@cvs.openbsd.org>2003-01-17 20:50:14 +0000
commitc74953a6610ab567e0d578b0efe913e513e987ae (patch)
treefe6189df78259efcd870a8677b3d4f20437ab56f /gnu/usr.bin/binutils/ld/ldmain.c
parent2dd69e36ac9facfcacc4c30c34e093939131f7db (diff)
This is a project to modify executables so that they do not have any
executable regions which are writable. If a section of an executable is writable and executable, it is much easier for errant code to modify the executable's behavior. Two current areas in shared library environments which have this critical problem are the GOT (Global Offset Table) and PLT (Procedure Linkage Table). The PLT is required to be executable and both GOT and PLT are writable on most architectures. On most ELF architecture machines this would cause shared libraries to have data and BSS marked as executable. Padding to the linker script for programs and shared libraries/objects to isolate the GOT and PLT into their own load sections in the executables. This allows only the text(readonly) region and the PLT region to be marked executable with the normal data and BSS not marked as executable. The PLT region is still marked executable on most architectures because the PLT lives in the "data" or "BSS" regions and the dynamic loader will need to modify it. Since the GOT and PLT should only ever be written by the dynamic linker, it will be modified to mprotect those regions so that they are not writable during normal execution. If the dynamic linker needs to modify the regions later, (eg for lazy binding), it will mprotect the region, make the necessary changes, and mprotect it back. Since it is possible to receive a signal which would interrupt the program flow and perhaps cause the dynamic linker to modify the same (or nearby) PLT references, it is now necessary for signals to be blocked for the duration of the mprotect.
Diffstat (limited to 'gnu/usr.bin/binutils/ld/ldmain.c')
-rw-r--r--gnu/usr.bin/binutils/ld/ldmain.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/gnu/usr.bin/binutils/ld/ldmain.c b/gnu/usr.bin/binutils/ld/ldmain.c
index 0b8120ffc9d..3ed628a546e 100644
--- a/gnu/usr.bin/binutils/ld/ldmain.c
+++ b/gnu/usr.bin/binutils/ld/ldmain.c
@@ -249,6 +249,7 @@ main (argc, argv)
force_make_executable = false;
config.magic_demand_paged = true;
config.text_read_only = true;
+ config.data_bss_contig = false;
emulation = get_emulation (argc, argv);
ldemul_choose_mode (emulation);