#
1.35 |
|
18-Nov-2023 |
deraadt |
crt0 uses a helper function in a MD src/libexec/ld.so .h file (rather than reproducing the relevant defines and code in a different place) to perform minor relocations. If things go very wrong, it would call _dl_exit() -- a locally defined crt0 function which is syscall exit(2). We don't need to call exit(2) for this obscure case which doesn't happen and provides no debugging information. An 'abort' is going to provide better information. So let's change the function name to _dso_abort() and make it a single illegal instruction. ok guenther
|
Revision tags: OPENBSD_7_3_BASE OPENBSD_7_4_BASE
|
#
1.34 |
|
21-Oct-2022 |
deraadt |
static binaries self-mprotect their relro in crt0. mimmutable() also works here. ok kettenis
|
Revision tags: OPENBSD_7_1_BASE OPENBSD_7_2_BASE
|
#
1.33 |
|
12-Jan-2022 |
guenther |
Lift the '#ifdef RCRT0' conditional out of boot*.h to crt0.c
Prep for dropping #includes from archdep.h: pull in <machine/reloc.h> and declare _dl_exit() in boot*.h
ok kettenis@
|
#
1.32 |
|
16-Nov-2021 |
guenther |
Sync boot.h with ld.so's boot.c, getting rid of struct boot_dyn, only initializing the variables we need to, and switching to a "while < end-of-array" style for DT_REL/RELA processing
ok drahn@ kettenis@
|
#
1.31 |
|
14-Nov-2021 |
guenther |
Split out the hppa and mips64 versions of boot.h similar to how I split ld.so/boot.c in 2019: * delete extraneous #includes * delete jmprel handling on non-hppa * delete RELOC_GOT() and DT_PROC bits on non-mips64
ok visa@
|
Revision tags: OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
|
#
1.30 |
|
10-May-2019 |
guenther |
ld.so boot cleanup support: - put functions and data which are only used before calling the executable's start function into their own page-aligned segments for unmapping (only done on amd64, arm64, armv7, powerpc, and sparc64 so far) - pass .init_array and .preinit_array functions an addition argument which is a callback to get a structure which includes a function that frees the boot text and data - sometimes delay doing RELRO processing: for a shared-object marked DF_1_INITFIRST do it after the object's .init_array, for the executable do it after the .preinit_array - improve test-ld.so to link against libpthread and trigger its initialization late libc changes to use this will come later
ok kettenis@
|
Revision tags: OPENBSD_6_5_BASE
|
#
1.29 |
|
22-Nov-2018 |
guenther |
Make alpha less special: _dl_boot_bind() is written to complete relocation of ld.so's GOT without using it, so _reloc_alpha_got() merely made the call to _dl_boot_bind() from asm simpler...while itself being a call that required special handling.
diff and muild baking by miod@ ok guenther@
|
Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
|
#
1.28 |
|
29-Jan-2017 |
chl |
remove unused variables
ok krw@ guenther@
|
#
1.27 |
|
02-Jan-2017 |
kettenis |
Remove the (now unused) code to determine the page size. Also get rid of the extern declaration of __got_{start,end}.
ok guenther@
|
#
1.26 |
|
24-Dec-2016 |
kettenis |
Replace return by break; requested by guenther@
|
#
1.25 |
|
24-Dec-2016 |
kettenis |
Remove code that reprotects the GOT based on the __got_start and __got_end symbols. Either the PT_LOAD RWX->RX case ot PT_GNU_RELRO should cover this already for anything we care about. And lld, the llvm linker, doesn't emit the __got_start and __got_end symbols and there are good reasons to leave it that way.
ok guenther@
|
#
1.24 |
|
19-Dec-2016 |
krw |
A couple more unused variables.
tweak & ok kettenis@
|
#
1.23 |
|
01-Sep-2016 |
tedu |
retire sparc
|
#
1.22 |
|
08-Aug-2016 |
guenther |
Look for a PT_GNU_RELRO section and, if present, mprotect that range instead of the [__got_start, __got_end) range.
Also, instead of mprotecting the [__plt_start, __plt_end) range, just scan for sections which are both writable and executable and mprotect them to read-only. (This part was stolen from kettenis@)
ok kettenis@
|
#
1.21 |
|
07-Aug-2016 |
guenther |
Teach mips64 to pass &_DYNAMIC to _dl_boot_bind().
mips64be testing by deraadt@
|
#
1.20 |
|
07-Aug-2016 |
guenther |
alpha already calculates &_DYNAMIC for the _reloc_alpha_got() call, so save that and pass it to _dl_boot_bind() too
|
#
1.19 |
|
07-Aug-2016 |
guenther |
Teach i386 to pass &_DYNAMIC to _dl_boot_bind()
|
#
1.18 |
|
07-Aug-2016 |
guenther |
Psych: amd64 has been passing &_DYNAMIC to _dl_boot_bind() for 19 months
|
#
1.17 |
|
07-Aug-2016 |
guenther |
Flip the #ifdef logic: amd64, i386, and mips64 were the only static PIE archs using the #else case
|
Revision tags: OPENBSD_6_0_BASE
|
#
1.16 |
|
05-Jul-2016 |
guenther |
Missed a reference to dl_prebind.h
problem noted by Andrew Ngo (andrew.ngo (at) gmail.com)
|
#
1.15 |
|
12-Mar-2016 |
guenther |
Call mprotect() via its hidden _lib_mprotect alias to avoid accidental overriding
ok deraadt@ kettenis@
|
Revision tags: OPENBSD_5_9_BASE
|
#
1.14 |
|
06-Dec-2015 |
guenther |
Simplify the relocation code for the ld.so bootstrap and static pie: track just the dynamic tags are needed instead of reusing the generic elf_object_t structure.
testing and feedback from miod@ ok kettenis@
|
#
1.13 |
|
19-Sep-2015 |
kettenis |
Make sure we set PROT_EXEC on the GOT for BSS-PLT binaries on powerpc.
ok guenther@
|
#
1.12 |
|
17-Aug-2015 |
kettenis |
Do not include os-note-elf.h here, otherwise we end up with duplicate OS notes in our binaries.
ok miod@
|
Revision tags: OPENBSD_5_8_BASE
|
#
1.11 |
|
03-Jul-2015 |
miod |
static pie support for sparc.
|
Revision tags: OPENBSD_5_7_BASE
|
#
1.10 |
|
16-Jan-2015 |
deraadt |
<sys/param.h> is not needed here either. ok guenther millert doug
|
#
1.9 |
|
29-Dec-2014 |
kettenis |
Make the PLT read-only on powerpc as well.
ok kurt@
|
#
1.8 |
|
27-Dec-2014 |
kettenis |
Static PIE support for alpha.
This adds alpha-specific first-pass GOT relocation code to boot.h. The assembly code is pure magic. The numeric register names don't make it easier to understand (or compare with the equivalent ld.so code). Unfortunately the assembler only understands a few symbolic register names.
Renames the crt0.o entry point to __start. Our compiler was already using __start and the linker will soon follow.
ok kurt@
|
#
1.7 |
|
25-Dec-2014 |
kurt |
Use archdep.h GOT_PERMS define for mprotect of GOT. okay kettenis@
|
#
1.6 |
|
24-Dec-2014 |
kurt |
Expand Elf_Rel relocations to include DT_JMPREL. Inspect DT_PLTREL value to determine if DT_JMPREL relocations are REL or RELA and conditionally perform DT_JMPREL in either REL or RELA as needed (idea from kettenis@). Remove unneeded i386 RELA implementation. i386 static pie working now.
okay kettenis@
|
#
1.5 |
|
24-Dec-2014 |
kettenis |
Fix previos. Pointed out by kurt@.
|
#
1.4 |
|
23-Dec-2014 |
kettenis |
Use the page size passed by the kernel in the Auxilliary Vector to handle architectures with variable page size.
|
#
1.3 |
|
23-Dec-2014 |
kettenis |
Make sure the GOT and PLT are not writable.
Note that ommitting PROT_EXEC for the PLT is deliberate; static PIE binaries should never actually hit the PLT.
We're still debating what to do when mprotect(2) fails. But that is no excuse not to at least attempt to fix things up.
ok deraadt@
|
#
1.2 |
|
22-Dec-2014 |
kettenis |
When skipping a relocation because the referenced symbol is undefined, make sure we move on to the next relocation entry.
While there, also skip relocations for REL architectures.
|
#
1.1 |
|
22-Dec-2014 |
kurt |
Introduce new csu0 variant for -static -pie binaries to use called rcsu0.o where the initial 'r' is for relocatable. rcsu0.o performs self-relocation on static pie binaries by calling a slightly modified copy of ld.so's _dl_boot_bind() in boot.h.
The first arch implementatation is also included for amd64 where __start calls _dl_boot_bind() and then calls ___start(). Includes parts from kettenis@ to help get R_X86_64_64 relocations working and proper handling for undefined weak symbols.
This is the first part of several to get static pie self-relocating binaries working. binutils, gcc and kernel changes are forthcoming to complete the solution, then per-arch implementations are needed for MD_RCRT0_START in csu.
okay kettenis@ pascal@ deraadt@
|
#
1.34 |
|
21-Oct-2022 |
deraadt |
static binaries self-mprotect their relro in crt0. mimmutable() also works here. ok kettenis
|
Revision tags: OPENBSD_7_1_BASE OPENBSD_7_2_BASE
|
#
1.33 |
|
12-Jan-2022 |
guenther |
Lift the '#ifdef RCRT0' conditional out of boot*.h to crt0.c
Prep for dropping #includes from archdep.h: pull in <machine/reloc.h> and declare _dl_exit() in boot*.h
ok kettenis@
|
#
1.32 |
|
16-Nov-2021 |
guenther |
Sync boot.h with ld.so's boot.c, getting rid of struct boot_dyn, only initializing the variables we need to, and switching to a "while < end-of-array" style for DT_REL/RELA processing
ok drahn@ kettenis@
|
#
1.31 |
|
14-Nov-2021 |
guenther |
Split out the hppa and mips64 versions of boot.h similar to how I split ld.so/boot.c in 2019: * delete extraneous #includes * delete jmprel handling on non-hppa * delete RELOC_GOT() and DT_PROC bits on non-mips64
ok visa@
|
Revision tags: OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
|
#
1.30 |
|
10-May-2019 |
guenther |
ld.so boot cleanup support: - put functions and data which are only used before calling the executable's start function into their own page-aligned segments for unmapping (only done on amd64, arm64, armv7, powerpc, and sparc64 so far) - pass .init_array and .preinit_array functions an addition argument which is a callback to get a structure which includes a function that frees the boot text and data - sometimes delay doing RELRO processing: for a shared-object marked DF_1_INITFIRST do it after the object's .init_array, for the executable do it after the .preinit_array - improve test-ld.so to link against libpthread and trigger its initialization late libc changes to use this will come later
ok kettenis@
|
Revision tags: OPENBSD_6_5_BASE
|
#
1.29 |
|
22-Nov-2018 |
guenther |
Make alpha less special: _dl_boot_bind() is written to complete relocation of ld.so's GOT without using it, so _reloc_alpha_got() merely made the call to _dl_boot_bind() from asm simpler...while itself being a call that required special handling.
diff and muild baking by miod@ ok guenther@
|
Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
|
#
1.28 |
|
29-Jan-2017 |
chl |
remove unused variables
ok krw@ guenther@
|
#
1.27 |
|
02-Jan-2017 |
kettenis |
Remove the (now unused) code to determine the page size. Also get rid of the extern declaration of __got_{start,end}.
ok guenther@
|
#
1.26 |
|
24-Dec-2016 |
kettenis |
Replace return by break; requested by guenther@
|
#
1.25 |
|
24-Dec-2016 |
kettenis |
Remove code that reprotects the GOT based on the __got_start and __got_end symbols. Either the PT_LOAD RWX->RX case ot PT_GNU_RELRO should cover this already for anything we care about. And lld, the llvm linker, doesn't emit the __got_start and __got_end symbols and there are good reasons to leave it that way.
ok guenther@
|
#
1.24 |
|
19-Dec-2016 |
krw |
A couple more unused variables.
tweak & ok kettenis@
|
#
1.23 |
|
01-Sep-2016 |
tedu |
retire sparc
|
#
1.22 |
|
08-Aug-2016 |
guenther |
Look for a PT_GNU_RELRO section and, if present, mprotect that range instead of the [__got_start, __got_end) range.
Also, instead of mprotecting the [__plt_start, __plt_end) range, just scan for sections which are both writable and executable and mprotect them to read-only. (This part was stolen from kettenis@)
ok kettenis@
|
#
1.21 |
|
07-Aug-2016 |
guenther |
Teach mips64 to pass &_DYNAMIC to _dl_boot_bind().
mips64be testing by deraadt@
|
#
1.20 |
|
07-Aug-2016 |
guenther |
alpha already calculates &_DYNAMIC for the _reloc_alpha_got() call, so save that and pass it to _dl_boot_bind() too
|
#
1.19 |
|
07-Aug-2016 |
guenther |
Teach i386 to pass &_DYNAMIC to _dl_boot_bind()
|
#
1.18 |
|
07-Aug-2016 |
guenther |
Psych: amd64 has been passing &_DYNAMIC to _dl_boot_bind() for 19 months
|
#
1.17 |
|
07-Aug-2016 |
guenther |
Flip the #ifdef logic: amd64, i386, and mips64 were the only static PIE archs using the #else case
|
Revision tags: OPENBSD_6_0_BASE
|
#
1.16 |
|
05-Jul-2016 |
guenther |
Missed a reference to dl_prebind.h
problem noted by Andrew Ngo (andrew.ngo (at) gmail.com)
|
#
1.15 |
|
12-Mar-2016 |
guenther |
Call mprotect() via its hidden _lib_mprotect alias to avoid accidental overriding
ok deraadt@ kettenis@
|
Revision tags: OPENBSD_5_9_BASE
|
#
1.14 |
|
06-Dec-2015 |
guenther |
Simplify the relocation code for the ld.so bootstrap and static pie: track just the dynamic tags are needed instead of reusing the generic elf_object_t structure.
testing and feedback from miod@ ok kettenis@
|
#
1.13 |
|
19-Sep-2015 |
kettenis |
Make sure we set PROT_EXEC on the GOT for BSS-PLT binaries on powerpc.
ok guenther@
|
#
1.12 |
|
17-Aug-2015 |
kettenis |
Do not include os-note-elf.h here, otherwise we end up with duplicate OS notes in our binaries.
ok miod@
|
Revision tags: OPENBSD_5_8_BASE
|
#
1.11 |
|
03-Jul-2015 |
miod |
static pie support for sparc.
|
Revision tags: OPENBSD_5_7_BASE
|
#
1.10 |
|
16-Jan-2015 |
deraadt |
<sys/param.h> is not needed here either. ok guenther millert doug
|
#
1.9 |
|
29-Dec-2014 |
kettenis |
Make the PLT read-only on powerpc as well.
ok kurt@
|
#
1.8 |
|
27-Dec-2014 |
kettenis |
Static PIE support for alpha.
This adds alpha-specific first-pass GOT relocation code to boot.h. The assembly code is pure magic. The numeric register names don't make it easier to understand (or compare with the equivalent ld.so code). Unfortunately the assembler only understands a few symbolic register names.
Renames the crt0.o entry point to __start. Our compiler was already using __start and the linker will soon follow.
ok kurt@
|
#
1.7 |
|
25-Dec-2014 |
kurt |
Use archdep.h GOT_PERMS define for mprotect of GOT. okay kettenis@
|
#
1.6 |
|
24-Dec-2014 |
kurt |
Expand Elf_Rel relocations to include DT_JMPREL. Inspect DT_PLTREL value to determine if DT_JMPREL relocations are REL or RELA and conditionally perform DT_JMPREL in either REL or RELA as needed (idea from kettenis@). Remove unneeded i386 RELA implementation. i386 static pie working now.
okay kettenis@
|
#
1.5 |
|
24-Dec-2014 |
kettenis |
Fix previos. Pointed out by kurt@.
|
#
1.4 |
|
23-Dec-2014 |
kettenis |
Use the page size passed by the kernel in the Auxilliary Vector to handle architectures with variable page size.
|
#
1.3 |
|
23-Dec-2014 |
kettenis |
Make sure the GOT and PLT are not writable.
Note that ommitting PROT_EXEC for the PLT is deliberate; static PIE binaries should never actually hit the PLT.
We're still debating what to do when mprotect(2) fails. But that is no excuse not to at least attempt to fix things up.
ok deraadt@
|
#
1.2 |
|
22-Dec-2014 |
kettenis |
When skipping a relocation because the referenced symbol is undefined, make sure we move on to the next relocation entry.
While there, also skip relocations for REL architectures.
|
#
1.1 |
|
22-Dec-2014 |
kurt |
Introduce new csu0 variant for -static -pie binaries to use called rcsu0.o where the initial 'r' is for relocatable. rcsu0.o performs self-relocation on static pie binaries by calling a slightly modified copy of ld.so's _dl_boot_bind() in boot.h.
The first arch implementatation is also included for amd64 where __start calls _dl_boot_bind() and then calls ___start(). Includes parts from kettenis@ to help get R_X86_64_64 relocations working and proper handling for undefined weak symbols.
This is the first part of several to get static pie self-relocating binaries working. binutils, gcc and kernel changes are forthcoming to complete the solution, then per-arch implementations are needed for MD_RCRT0_START in csu.
okay kettenis@ pascal@ deraadt@
|
#
1.33 |
|
12-Jan-2022 |
guenther |
Lift the '#ifdef RCRT0' conditional out of boot*.h to crt0.c
Prep for dropping #includes from archdep.h: pull in <machine/reloc.h> and declare _dl_exit() in boot*.h
ok kettenis@
|
#
1.32 |
|
16-Nov-2021 |
guenther |
Sync boot.h with ld.so's boot.c, getting rid of struct boot_dyn, only initializing the variables we need to, and switching to a "while < end-of-array" style for DT_REL/RELA processing
ok drahn@ kettenis@
|
#
1.31 |
|
14-Nov-2021 |
guenther |
Split out the hppa and mips64 versions of boot.h similar to how I split ld.so/boot.c in 2019: * delete extraneous #includes * delete jmprel handling on non-hppa * delete RELOC_GOT() and DT_PROC bits on non-mips64
ok visa@
|
Revision tags: OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
|
#
1.30 |
|
10-May-2019 |
guenther |
ld.so boot cleanup support: - put functions and data which are only used before calling the executable's start function into their own page-aligned segments for unmapping (only done on amd64, arm64, armv7, powerpc, and sparc64 so far) - pass .init_array and .preinit_array functions an addition argument which is a callback to get a structure which includes a function that frees the boot text and data - sometimes delay doing RELRO processing: for a shared-object marked DF_1_INITFIRST do it after the object's .init_array, for the executable do it after the .preinit_array - improve test-ld.so to link against libpthread and trigger its initialization late libc changes to use this will come later
ok kettenis@
|
Revision tags: OPENBSD_6_5_BASE
|
#
1.29 |
|
22-Nov-2018 |
guenther |
Make alpha less special: _dl_boot_bind() is written to complete relocation of ld.so's GOT without using it, so _reloc_alpha_got() merely made the call to _dl_boot_bind() from asm simpler...while itself being a call that required special handling.
diff and muild baking by miod@ ok guenther@
|
Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
|
#
1.28 |
|
29-Jan-2017 |
chl |
remove unused variables
ok krw@ guenther@
|
#
1.27 |
|
02-Jan-2017 |
kettenis |
Remove the (now unused) code to determine the page size. Also get rid of the extern declaration of __got_{start,end}.
ok guenther@
|
#
1.26 |
|
24-Dec-2016 |
kettenis |
Replace return by break; requested by guenther@
|
#
1.25 |
|
24-Dec-2016 |
kettenis |
Remove code that reprotects the GOT based on the __got_start and __got_end symbols. Either the PT_LOAD RWX->RX case ot PT_GNU_RELRO should cover this already for anything we care about. And lld, the llvm linker, doesn't emit the __got_start and __got_end symbols and there are good reasons to leave it that way.
ok guenther@
|
#
1.24 |
|
19-Dec-2016 |
krw |
A couple more unused variables.
tweak & ok kettenis@
|
#
1.23 |
|
01-Sep-2016 |
tedu |
retire sparc
|
#
1.22 |
|
08-Aug-2016 |
guenther |
Look for a PT_GNU_RELRO section and, if present, mprotect that range instead of the [__got_start, __got_end) range.
Also, instead of mprotecting the [__plt_start, __plt_end) range, just scan for sections which are both writable and executable and mprotect them to read-only. (This part was stolen from kettenis@)
ok kettenis@
|
#
1.21 |
|
07-Aug-2016 |
guenther |
Teach mips64 to pass &_DYNAMIC to _dl_boot_bind().
mips64be testing by deraadt@
|
#
1.20 |
|
07-Aug-2016 |
guenther |
alpha already calculates &_DYNAMIC for the _reloc_alpha_got() call, so save that and pass it to _dl_boot_bind() too
|
#
1.19 |
|
07-Aug-2016 |
guenther |
Teach i386 to pass &_DYNAMIC to _dl_boot_bind()
|
#
1.18 |
|
07-Aug-2016 |
guenther |
Psych: amd64 has been passing &_DYNAMIC to _dl_boot_bind() for 19 months
|
#
1.17 |
|
07-Aug-2016 |
guenther |
Flip the #ifdef logic: amd64, i386, and mips64 were the only static PIE archs using the #else case
|
Revision tags: OPENBSD_6_0_BASE
|
#
1.16 |
|
05-Jul-2016 |
guenther |
Missed a reference to dl_prebind.h
problem noted by Andrew Ngo (andrew.ngo (at) gmail.com)
|
#
1.15 |
|
12-Mar-2016 |
guenther |
Call mprotect() via its hidden _lib_mprotect alias to avoid accidental overriding
ok deraadt@ kettenis@
|
Revision tags: OPENBSD_5_9_BASE
|
#
1.14 |
|
06-Dec-2015 |
guenther |
Simplify the relocation code for the ld.so bootstrap and static pie: track just the dynamic tags are needed instead of reusing the generic elf_object_t structure.
testing and feedback from miod@ ok kettenis@
|
#
1.13 |
|
19-Sep-2015 |
kettenis |
Make sure we set PROT_EXEC on the GOT for BSS-PLT binaries on powerpc.
ok guenther@
|
#
1.12 |
|
17-Aug-2015 |
kettenis |
Do not include os-note-elf.h here, otherwise we end up with duplicate OS notes in our binaries.
ok miod@
|
Revision tags: OPENBSD_5_8_BASE
|
#
1.11 |
|
03-Jul-2015 |
miod |
static pie support for sparc.
|
Revision tags: OPENBSD_5_7_BASE
|
#
1.10 |
|
16-Jan-2015 |
deraadt |
<sys/param.h> is not needed here either. ok guenther millert doug
|
#
1.9 |
|
29-Dec-2014 |
kettenis |
Make the PLT read-only on powerpc as well.
ok kurt@
|
#
1.8 |
|
27-Dec-2014 |
kettenis |
Static PIE support for alpha.
This adds alpha-specific first-pass GOT relocation code to boot.h. The assembly code is pure magic. The numeric register names don't make it easier to understand (or compare with the equivalent ld.so code). Unfortunately the assembler only understands a few symbolic register names.
Renames the crt0.o entry point to __start. Our compiler was already using __start and the linker will soon follow.
ok kurt@
|
#
1.7 |
|
25-Dec-2014 |
kurt |
Use archdep.h GOT_PERMS define for mprotect of GOT. okay kettenis@
|
#
1.6 |
|
24-Dec-2014 |
kurt |
Expand Elf_Rel relocations to include DT_JMPREL. Inspect DT_PLTREL value to determine if DT_JMPREL relocations are REL or RELA and conditionally perform DT_JMPREL in either REL or RELA as needed (idea from kettenis@). Remove unneeded i386 RELA implementation. i386 static pie working now.
okay kettenis@
|
#
1.5 |
|
24-Dec-2014 |
kettenis |
Fix previos. Pointed out by kurt@.
|
#
1.4 |
|
23-Dec-2014 |
kettenis |
Use the page size passed by the kernel in the Auxilliary Vector to handle architectures with variable page size.
|
#
1.3 |
|
23-Dec-2014 |
kettenis |
Make sure the GOT and PLT are not writable.
Note that ommitting PROT_EXEC for the PLT is deliberate; static PIE binaries should never actually hit the PLT.
We're still debating what to do when mprotect(2) fails. But that is no excuse not to at least attempt to fix things up.
ok deraadt@
|
#
1.2 |
|
22-Dec-2014 |
kettenis |
When skipping a relocation because the referenced symbol is undefined, make sure we move on to the next relocation entry.
While there, also skip relocations for REL architectures.
|
#
1.1 |
|
22-Dec-2014 |
kurt |
Introduce new csu0 variant for -static -pie binaries to use called rcsu0.o where the initial 'r' is for relocatable. rcsu0.o performs self-relocation on static pie binaries by calling a slightly modified copy of ld.so's _dl_boot_bind() in boot.h.
The first arch implementatation is also included for amd64 where __start calls _dl_boot_bind() and then calls ___start(). Includes parts from kettenis@ to help get R_X86_64_64 relocations working and proper handling for undefined weak symbols.
This is the first part of several to get static pie self-relocating binaries working. binutils, gcc and kernel changes are forthcoming to complete the solution, then per-arch implementations are needed for MD_RCRT0_START in csu.
okay kettenis@ pascal@ deraadt@
|
#
1.32 |
|
16-Nov-2021 |
guenther |
Sync boot.h with ld.so's boot.c, getting rid of struct boot_dyn, only initializing the variables we need to, and switching to a "while < end-of-array" style for DT_REL/RELA processing
ok drahn@ kettenis@
|
#
1.31 |
|
14-Nov-2021 |
guenther |
Split out the hppa and mips64 versions of boot.h similar to how I split ld.so/boot.c in 2019: * delete extraneous #includes * delete jmprel handling on non-hppa * delete RELOC_GOT() and DT_PROC bits on non-mips64
ok visa@
|
Revision tags: OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
|
#
1.30 |
|
10-May-2019 |
guenther |
ld.so boot cleanup support: - put functions and data which are only used before calling the executable's start function into their own page-aligned segments for unmapping (only done on amd64, arm64, armv7, powerpc, and sparc64 so far) - pass .init_array and .preinit_array functions an addition argument which is a callback to get a structure which includes a function that frees the boot text and data - sometimes delay doing RELRO processing: for a shared-object marked DF_1_INITFIRST do it after the object's .init_array, for the executable do it after the .preinit_array - improve test-ld.so to link against libpthread and trigger its initialization late libc changes to use this will come later
ok kettenis@
|
Revision tags: OPENBSD_6_5_BASE
|
#
1.29 |
|
22-Nov-2018 |
guenther |
Make alpha less special: _dl_boot_bind() is written to complete relocation of ld.so's GOT without using it, so _reloc_alpha_got() merely made the call to _dl_boot_bind() from asm simpler...while itself being a call that required special handling.
diff and muild baking by miod@ ok guenther@
|
Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
|
#
1.28 |
|
29-Jan-2017 |
chl |
remove unused variables
ok krw@ guenther@
|
#
1.27 |
|
02-Jan-2017 |
kettenis |
Remove the (now unused) code to determine the page size. Also get rid of the extern declaration of __got_{start,end}.
ok guenther@
|
#
1.26 |
|
24-Dec-2016 |
kettenis |
Replace return by break; requested by guenther@
|
#
1.25 |
|
24-Dec-2016 |
kettenis |
Remove code that reprotects the GOT based on the __got_start and __got_end symbols. Either the PT_LOAD RWX->RX case ot PT_GNU_RELRO should cover this already for anything we care about. And lld, the llvm linker, doesn't emit the __got_start and __got_end symbols and there are good reasons to leave it that way.
ok guenther@
|
#
1.24 |
|
19-Dec-2016 |
krw |
A couple more unused variables.
tweak & ok kettenis@
|
#
1.23 |
|
01-Sep-2016 |
tedu |
retire sparc
|
#
1.22 |
|
08-Aug-2016 |
guenther |
Look for a PT_GNU_RELRO section and, if present, mprotect that range instead of the [__got_start, __got_end) range.
Also, instead of mprotecting the [__plt_start, __plt_end) range, just scan for sections which are both writable and executable and mprotect them to read-only. (This part was stolen from kettenis@)
ok kettenis@
|
#
1.21 |
|
07-Aug-2016 |
guenther |
Teach mips64 to pass &_DYNAMIC to _dl_boot_bind().
mips64be testing by deraadt@
|
#
1.20 |
|
07-Aug-2016 |
guenther |
alpha already calculates &_DYNAMIC for the _reloc_alpha_got() call, so save that and pass it to _dl_boot_bind() too
|
#
1.19 |
|
07-Aug-2016 |
guenther |
Teach i386 to pass &_DYNAMIC to _dl_boot_bind()
|
#
1.18 |
|
07-Aug-2016 |
guenther |
Psych: amd64 has been passing &_DYNAMIC to _dl_boot_bind() for 19 months
|
#
1.17 |
|
07-Aug-2016 |
guenther |
Flip the #ifdef logic: amd64, i386, and mips64 were the only static PIE archs using the #else case
|
Revision tags: OPENBSD_6_0_BASE
|
#
1.16 |
|
05-Jul-2016 |
guenther |
Missed a reference to dl_prebind.h
problem noted by Andrew Ngo (andrew.ngo (at) gmail.com)
|
#
1.15 |
|
12-Mar-2016 |
guenther |
Call mprotect() via its hidden _lib_mprotect alias to avoid accidental overriding
ok deraadt@ kettenis@
|
Revision tags: OPENBSD_5_9_BASE
|
#
1.14 |
|
06-Dec-2015 |
guenther |
Simplify the relocation code for the ld.so bootstrap and static pie: track just the dynamic tags are needed instead of reusing the generic elf_object_t structure.
testing and feedback from miod@ ok kettenis@
|
#
1.13 |
|
19-Sep-2015 |
kettenis |
Make sure we set PROT_EXEC on the GOT for BSS-PLT binaries on powerpc.
ok guenther@
|
#
1.12 |
|
17-Aug-2015 |
kettenis |
Do not include os-note-elf.h here, otherwise we end up with duplicate OS notes in our binaries.
ok miod@
|
Revision tags: OPENBSD_5_8_BASE
|
#
1.11 |
|
03-Jul-2015 |
miod |
static pie support for sparc.
|
Revision tags: OPENBSD_5_7_BASE
|
#
1.10 |
|
16-Jan-2015 |
deraadt |
<sys/param.h> is not needed here either. ok guenther millert doug
|
#
1.9 |
|
29-Dec-2014 |
kettenis |
Make the PLT read-only on powerpc as well.
ok kurt@
|
#
1.8 |
|
27-Dec-2014 |
kettenis |
Static PIE support for alpha.
This adds alpha-specific first-pass GOT relocation code to boot.h. The assembly code is pure magic. The numeric register names don't make it easier to understand (or compare with the equivalent ld.so code). Unfortunately the assembler only understands a few symbolic register names.
Renames the crt0.o entry point to __start. Our compiler was already using __start and the linker will soon follow.
ok kurt@
|
#
1.7 |
|
25-Dec-2014 |
kurt |
Use archdep.h GOT_PERMS define for mprotect of GOT. okay kettenis@
|
#
1.6 |
|
24-Dec-2014 |
kurt |
Expand Elf_Rel relocations to include DT_JMPREL. Inspect DT_PLTREL value to determine if DT_JMPREL relocations are REL or RELA and conditionally perform DT_JMPREL in either REL or RELA as needed (idea from kettenis@). Remove unneeded i386 RELA implementation. i386 static pie working now.
okay kettenis@
|
#
1.5 |
|
24-Dec-2014 |
kettenis |
Fix previos. Pointed out by kurt@.
|
#
1.4 |
|
23-Dec-2014 |
kettenis |
Use the page size passed by the kernel in the Auxilliary Vector to handle architectures with variable page size.
|
#
1.3 |
|
23-Dec-2014 |
kettenis |
Make sure the GOT and PLT are not writable.
Note that ommitting PROT_EXEC for the PLT is deliberate; static PIE binaries should never actually hit the PLT.
We're still debating what to do when mprotect(2) fails. But that is no excuse not to at least attempt to fix things up.
ok deraadt@
|
#
1.2 |
|
22-Dec-2014 |
kettenis |
When skipping a relocation because the referenced symbol is undefined, make sure we move on to the next relocation entry.
While there, also skip relocations for REL architectures.
|
#
1.1 |
|
22-Dec-2014 |
kurt |
Introduce new csu0 variant for -static -pie binaries to use called rcsu0.o where the initial 'r' is for relocatable. rcsu0.o performs self-relocation on static pie binaries by calling a slightly modified copy of ld.so's _dl_boot_bind() in boot.h.
The first arch implementatation is also included for amd64 where __start calls _dl_boot_bind() and then calls ___start(). Includes parts from kettenis@ to help get R_X86_64_64 relocations working and proper handling for undefined weak symbols.
This is the first part of several to get static pie self-relocating binaries working. binutils, gcc and kernel changes are forthcoming to complete the solution, then per-arch implementations are needed for MD_RCRT0_START in csu.
okay kettenis@ pascal@ deraadt@
|
#
1.31 |
|
14-Nov-2021 |
guenther |
Split out the hppa and mips64 versions of boot.h similar to how I split ld.so/boot.c in 2019: * delete extraneous #includes * delete jmprel handling on non-hppa * delete RELOC_GOT() and DT_PROC bits on non-mips64
ok visa@
|
Revision tags: OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
|
#
1.30 |
|
10-May-2019 |
guenther |
ld.so boot cleanup support: - put functions and data which are only used before calling the executable's start function into their own page-aligned segments for unmapping (only done on amd64, arm64, armv7, powerpc, and sparc64 so far) - pass .init_array and .preinit_array functions an addition argument which is a callback to get a structure which includes a function that frees the boot text and data - sometimes delay doing RELRO processing: for a shared-object marked DF_1_INITFIRST do it after the object's .init_array, for the executable do it after the .preinit_array - improve test-ld.so to link against libpthread and trigger its initialization late libc changes to use this will come later
ok kettenis@
|
Revision tags: OPENBSD_6_5_BASE
|
#
1.29 |
|
22-Nov-2018 |
guenther |
Make alpha less special: _dl_boot_bind() is written to complete relocation of ld.so's GOT without using it, so _reloc_alpha_got() merely made the call to _dl_boot_bind() from asm simpler...while itself being a call that required special handling.
diff and muild baking by miod@ ok guenther@
|
Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
|
#
1.28 |
|
29-Jan-2017 |
chl |
remove unused variables
ok krw@ guenther@
|
#
1.27 |
|
02-Jan-2017 |
kettenis |
Remove the (now unused) code to determine the page size. Also get rid of the extern declaration of __got_{start,end}.
ok guenther@
|
#
1.26 |
|
24-Dec-2016 |
kettenis |
Replace return by break; requested by guenther@
|
#
1.25 |
|
24-Dec-2016 |
kettenis |
Remove code that reprotects the GOT based on the __got_start and __got_end symbols. Either the PT_LOAD RWX->RX case ot PT_GNU_RELRO should cover this already for anything we care about. And lld, the llvm linker, doesn't emit the __got_start and __got_end symbols and there are good reasons to leave it that way.
ok guenther@
|
#
1.24 |
|
19-Dec-2016 |
krw |
A couple more unused variables.
tweak & ok kettenis@
|
#
1.23 |
|
01-Sep-2016 |
tedu |
retire sparc
|
#
1.22 |
|
08-Aug-2016 |
guenther |
Look for a PT_GNU_RELRO section and, if present, mprotect that range instead of the [__got_start, __got_end) range.
Also, instead of mprotecting the [__plt_start, __plt_end) range, just scan for sections which are both writable and executable and mprotect them to read-only. (This part was stolen from kettenis@)
ok kettenis@
|
#
1.21 |
|
07-Aug-2016 |
guenther |
Teach mips64 to pass &_DYNAMIC to _dl_boot_bind().
mips64be testing by deraadt@
|
#
1.20 |
|
07-Aug-2016 |
guenther |
alpha already calculates &_DYNAMIC for the _reloc_alpha_got() call, so save that and pass it to _dl_boot_bind() too
|
#
1.19 |
|
07-Aug-2016 |
guenther |
Teach i386 to pass &_DYNAMIC to _dl_boot_bind()
|
#
1.18 |
|
07-Aug-2016 |
guenther |
Psych: amd64 has been passing &_DYNAMIC to _dl_boot_bind() for 19 months
|
#
1.17 |
|
07-Aug-2016 |
guenther |
Flip the #ifdef logic: amd64, i386, and mips64 were the only static PIE archs using the #else case
|
Revision tags: OPENBSD_6_0_BASE
|
#
1.16 |
|
05-Jul-2016 |
guenther |
Missed a reference to dl_prebind.h
problem noted by Andrew Ngo (andrew.ngo (at) gmail.com)
|
#
1.15 |
|
12-Mar-2016 |
guenther |
Call mprotect() via its hidden _lib_mprotect alias to avoid accidental overriding
ok deraadt@ kettenis@
|
Revision tags: OPENBSD_5_9_BASE
|
#
1.14 |
|
06-Dec-2015 |
guenther |
Simplify the relocation code for the ld.so bootstrap and static pie: track just the dynamic tags are needed instead of reusing the generic elf_object_t structure.
testing and feedback from miod@ ok kettenis@
|
#
1.13 |
|
19-Sep-2015 |
kettenis |
Make sure we set PROT_EXEC on the GOT for BSS-PLT binaries on powerpc.
ok guenther@
|
#
1.12 |
|
17-Aug-2015 |
kettenis |
Do not include os-note-elf.h here, otherwise we end up with duplicate OS notes in our binaries.
ok miod@
|
Revision tags: OPENBSD_5_8_BASE
|
#
1.11 |
|
03-Jul-2015 |
miod |
static pie support for sparc.
|
Revision tags: OPENBSD_5_7_BASE
|
#
1.10 |
|
16-Jan-2015 |
deraadt |
<sys/param.h> is not needed here either. ok guenther millert doug
|
#
1.9 |
|
29-Dec-2014 |
kettenis |
Make the PLT read-only on powerpc as well.
ok kurt@
|
#
1.8 |
|
27-Dec-2014 |
kettenis |
Static PIE support for alpha.
This adds alpha-specific first-pass GOT relocation code to boot.h. The assembly code is pure magic. The numeric register names don't make it easier to understand (or compare with the equivalent ld.so code). Unfortunately the assembler only understands a few symbolic register names.
Renames the crt0.o entry point to __start. Our compiler was already using __start and the linker will soon follow.
ok kurt@
|
#
1.7 |
|
25-Dec-2014 |
kurt |
Use archdep.h GOT_PERMS define for mprotect of GOT. okay kettenis@
|
#
1.6 |
|
24-Dec-2014 |
kurt |
Expand Elf_Rel relocations to include DT_JMPREL. Inspect DT_PLTREL value to determine if DT_JMPREL relocations are REL or RELA and conditionally perform DT_JMPREL in either REL or RELA as needed (idea from kettenis@). Remove unneeded i386 RELA implementation. i386 static pie working now.
okay kettenis@
|
#
1.5 |
|
24-Dec-2014 |
kettenis |
Fix previos. Pointed out by kurt@.
|
#
1.4 |
|
23-Dec-2014 |
kettenis |
Use the page size passed by the kernel in the Auxilliary Vector to handle architectures with variable page size.
|
#
1.3 |
|
23-Dec-2014 |
kettenis |
Make sure the GOT and PLT are not writable.
Note that ommitting PROT_EXEC for the PLT is deliberate; static PIE binaries should never actually hit the PLT.
We're still debating what to do when mprotect(2) fails. But that is no excuse not to at least attempt to fix things up.
ok deraadt@
|
#
1.2 |
|
22-Dec-2014 |
kettenis |
When skipping a relocation because the referenced symbol is undefined, make sure we move on to the next relocation entry.
While there, also skip relocations for REL architectures.
|
#
1.1 |
|
22-Dec-2014 |
kurt |
Introduce new csu0 variant for -static -pie binaries to use called rcsu0.o where the initial 'r' is for relocatable. rcsu0.o performs self-relocation on static pie binaries by calling a slightly modified copy of ld.so's _dl_boot_bind() in boot.h.
The first arch implementatation is also included for amd64 where __start calls _dl_boot_bind() and then calls ___start(). Includes parts from kettenis@ to help get R_X86_64_64 relocations working and proper handling for undefined weak symbols.
This is the first part of several to get static pie self-relocating binaries working. binutils, gcc and kernel changes are forthcoming to complete the solution, then per-arch implementations are needed for MD_RCRT0_START in csu.
okay kettenis@ pascal@ deraadt@
|
#
1.30 |
|
10-May-2019 |
guenther |
ld.so boot cleanup support: - put functions and data which are only used before calling the executable's start function into their own page-aligned segments for unmapping (only done on amd64, arm64, armv7, powerpc, and sparc64 so far) - pass .init_array and .preinit_array functions an addition argument which is a callback to get a structure which includes a function that frees the boot text and data - sometimes delay doing RELRO processing: for a shared-object marked DF_1_INITFIRST do it after the object's .init_array, for the executable do it after the .preinit_array - improve test-ld.so to link against libpthread and trigger its initialization late libc changes to use this will come later
ok kettenis@
|
Revision tags: OPENBSD_6_5_BASE
|
#
1.29 |
|
22-Nov-2018 |
guenther |
Make alpha less special: _dl_boot_bind() is written to complete relocation of ld.so's GOT without using it, so _reloc_alpha_got() merely made the call to _dl_boot_bind() from asm simpler...while itself being a call that required special handling.
diff and muild baking by miod@ ok guenther@
|
Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
|
#
1.28 |
|
29-Jan-2017 |
chl |
remove unused variables
ok krw@ guenther@
|
#
1.27 |
|
02-Jan-2017 |
kettenis |
Remove the (now unused) code to determine the page size. Also get rid of the extern declaration of __got_{start,end}.
ok guenther@
|
#
1.26 |
|
24-Dec-2016 |
kettenis |
Replace return by break; requested by guenther@
|
#
1.25 |
|
24-Dec-2016 |
kettenis |
Remove code that reprotects the GOT based on the __got_start and __got_end symbols. Either the PT_LOAD RWX->RX case ot PT_GNU_RELRO should cover this already for anything we care about. And lld, the llvm linker, doesn't emit the __got_start and __got_end symbols and there are good reasons to leave it that way.
ok guenther@
|
#
1.24 |
|
19-Dec-2016 |
krw |
A couple more unused variables.
tweak & ok kettenis@
|
#
1.23 |
|
01-Sep-2016 |
tedu |
retire sparc
|
#
1.22 |
|
08-Aug-2016 |
guenther |
Look for a PT_GNU_RELRO section and, if present, mprotect that range instead of the [__got_start, __got_end) range.
Also, instead of mprotecting the [__plt_start, __plt_end) range, just scan for sections which are both writable and executable and mprotect them to read-only. (This part was stolen from kettenis@)
ok kettenis@
|
#
1.21 |
|
07-Aug-2016 |
guenther |
Teach mips64 to pass &_DYNAMIC to _dl_boot_bind().
mips64be testing by deraadt@
|
#
1.20 |
|
07-Aug-2016 |
guenther |
alpha already calculates &_DYNAMIC for the _reloc_alpha_got() call, so save that and pass it to _dl_boot_bind() too
|
#
1.19 |
|
07-Aug-2016 |
guenther |
Teach i386 to pass &_DYNAMIC to _dl_boot_bind()
|
#
1.18 |
|
07-Aug-2016 |
guenther |
Psych: amd64 has been passing &_DYNAMIC to _dl_boot_bind() for 19 months
|
#
1.17 |
|
07-Aug-2016 |
guenther |
Flip the #ifdef logic: amd64, i386, and mips64 were the only static PIE archs using the #else case
|
Revision tags: OPENBSD_6_0_BASE
|
#
1.16 |
|
05-Jul-2016 |
guenther |
Missed a reference to dl_prebind.h
problem noted by Andrew Ngo (andrew.ngo (at) gmail.com)
|
#
1.15 |
|
12-Mar-2016 |
guenther |
Call mprotect() via its hidden _lib_mprotect alias to avoid accidental overriding
ok deraadt@ kettenis@
|
Revision tags: OPENBSD_5_9_BASE
|
#
1.14 |
|
06-Dec-2015 |
guenther |
Simplify the relocation code for the ld.so bootstrap and static pie: track just the dynamic tags are needed instead of reusing the generic elf_object_t structure.
testing and feedback from miod@ ok kettenis@
|
#
1.13 |
|
19-Sep-2015 |
kettenis |
Make sure we set PROT_EXEC on the GOT for BSS-PLT binaries on powerpc.
ok guenther@
|
#
1.12 |
|
17-Aug-2015 |
kettenis |
Do not include os-note-elf.h here, otherwise we end up with duplicate OS notes in our binaries.
ok miod@
|
Revision tags: OPENBSD_5_8_BASE
|
#
1.11 |
|
03-Jul-2015 |
miod |
static pie support for sparc.
|
Revision tags: OPENBSD_5_7_BASE
|
#
1.10 |
|
16-Jan-2015 |
deraadt |
<sys/param.h> is not needed here either. ok guenther millert doug
|
#
1.9 |
|
29-Dec-2014 |
kettenis |
Make the PLT read-only on powerpc as well.
ok kurt@
|
#
1.8 |
|
27-Dec-2014 |
kettenis |
Static PIE support for alpha.
This adds alpha-specific first-pass GOT relocation code to boot.h. The assembly code is pure magic. The numeric register names don't make it easier to understand (or compare with the equivalent ld.so code). Unfortunately the assembler only understands a few symbolic register names.
Renames the crt0.o entry point to __start. Our compiler was already using __start and the linker will soon follow.
ok kurt@
|
#
1.7 |
|
25-Dec-2014 |
kurt |
Use archdep.h GOT_PERMS define for mprotect of GOT. okay kettenis@
|
#
1.6 |
|
24-Dec-2014 |
kurt |
Expand Elf_Rel relocations to include DT_JMPREL. Inspect DT_PLTREL value to determine if DT_JMPREL relocations are REL or RELA and conditionally perform DT_JMPREL in either REL or RELA as needed (idea from kettenis@). Remove unneeded i386 RELA implementation. i386 static pie working now.
okay kettenis@
|
#
1.5 |
|
24-Dec-2014 |
kettenis |
Fix previos. Pointed out by kurt@.
|
#
1.4 |
|
23-Dec-2014 |
kettenis |
Use the page size passed by the kernel in the Auxilliary Vector to handle architectures with variable page size.
|
#
1.3 |
|
23-Dec-2014 |
kettenis |
Make sure the GOT and PLT are not writable.
Note that ommitting PROT_EXEC for the PLT is deliberate; static PIE binaries should never actually hit the PLT.
We're still debating what to do when mprotect(2) fails. But that is no excuse not to at least attempt to fix things up.
ok deraadt@
|
#
1.2 |
|
22-Dec-2014 |
kettenis |
When skipping a relocation because the referenced symbol is undefined, make sure we move on to the next relocation entry.
While there, also skip relocations for REL architectures.
|
#
1.1 |
|
22-Dec-2014 |
kurt |
Introduce new csu0 variant for -static -pie binaries to use called rcsu0.o where the initial 'r' is for relocatable. rcsu0.o performs self-relocation on static pie binaries by calling a slightly modified copy of ld.so's _dl_boot_bind() in boot.h.
The first arch implementatation is also included for amd64 where __start calls _dl_boot_bind() and then calls ___start(). Includes parts from kettenis@ to help get R_X86_64_64 relocations working and proper handling for undefined weak symbols.
This is the first part of several to get static pie self-relocating binaries working. binutils, gcc and kernel changes are forthcoming to complete the solution, then per-arch implementations are needed for MD_RCRT0_START in csu.
okay kettenis@ pascal@ deraadt@
|
#
1.29 |
|
22-Nov-2018 |
guenther |
Make alpha less special: _dl_boot_bind() is written to complete relocation of ld.so's GOT without using it, so _reloc_alpha_got() merely made the call to _dl_boot_bind() from asm simpler...while itself being a call that required special handling.
diff and muild baking by miod@ ok guenther@
|
Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
|
#
1.28 |
|
29-Jan-2017 |
chl |
remove unused variables
ok krw@ guenther@
|
#
1.27 |
|
02-Jan-2017 |
kettenis |
Remove the (now unused) code to determine the page size. Also get rid of the extern declaration of __got_{start,end}.
ok guenther@
|
#
1.26 |
|
24-Dec-2016 |
kettenis |
Replace return by break; requested by guenther@
|
#
1.25 |
|
24-Dec-2016 |
kettenis |
Remove code that reprotects the GOT based on the __got_start and __got_end symbols. Either the PT_LOAD RWX->RX case ot PT_GNU_RELRO should cover this already for anything we care about. And lld, the llvm linker, doesn't emit the __got_start and __got_end symbols and there are good reasons to leave it that way.
ok guenther@
|
#
1.24 |
|
19-Dec-2016 |
krw |
A couple more unused variables.
tweak & ok kettenis@
|
#
1.23 |
|
01-Sep-2016 |
tedu |
retire sparc
|
#
1.22 |
|
08-Aug-2016 |
guenther |
Look for a PT_GNU_RELRO section and, if present, mprotect that range instead of the [__got_start, __got_end) range.
Also, instead of mprotecting the [__plt_start, __plt_end) range, just scan for sections which are both writable and executable and mprotect them to read-only. (This part was stolen from kettenis@)
ok kettenis@
|
#
1.21 |
|
07-Aug-2016 |
guenther |
Teach mips64 to pass &_DYNAMIC to _dl_boot_bind().
mips64be testing by deraadt@
|
#
1.20 |
|
07-Aug-2016 |
guenther |
alpha already calculates &_DYNAMIC for the _reloc_alpha_got() call, so save that and pass it to _dl_boot_bind() too
|
#
1.19 |
|
07-Aug-2016 |
guenther |
Teach i386 to pass &_DYNAMIC to _dl_boot_bind()
|
#
1.18 |
|
07-Aug-2016 |
guenther |
Psych: amd64 has been passing &_DYNAMIC to _dl_boot_bind() for 19 months
|
#
1.17 |
|
07-Aug-2016 |
guenther |
Flip the #ifdef logic: amd64, i386, and mips64 were the only static PIE archs using the #else case
|
Revision tags: OPENBSD_6_0_BASE
|
#
1.16 |
|
05-Jul-2016 |
guenther |
Missed a reference to dl_prebind.h
problem noted by Andrew Ngo (andrew.ngo (at) gmail.com)
|
#
1.15 |
|
12-Mar-2016 |
guenther |
Call mprotect() via its hidden _lib_mprotect alias to avoid accidental overriding
ok deraadt@ kettenis@
|
Revision tags: OPENBSD_5_9_BASE
|
#
1.14 |
|
06-Dec-2015 |
guenther |
Simplify the relocation code for the ld.so bootstrap and static pie: track just the dynamic tags are needed instead of reusing the generic elf_object_t structure.
testing and feedback from miod@ ok kettenis@
|
#
1.13 |
|
19-Sep-2015 |
kettenis |
Make sure we set PROT_EXEC on the GOT for BSS-PLT binaries on powerpc.
ok guenther@
|
#
1.12 |
|
17-Aug-2015 |
kettenis |
Do not include os-note-elf.h here, otherwise we end up with duplicate OS notes in our binaries.
ok miod@
|
Revision tags: OPENBSD_5_8_BASE
|
#
1.11 |
|
03-Jul-2015 |
miod |
static pie support for sparc.
|
Revision tags: OPENBSD_5_7_BASE
|
#
1.10 |
|
16-Jan-2015 |
deraadt |
<sys/param.h> is not needed here either. ok guenther millert doug
|
#
1.9 |
|
29-Dec-2014 |
kettenis |
Make the PLT read-only on powerpc as well.
ok kurt@
|
#
1.8 |
|
27-Dec-2014 |
kettenis |
Static PIE support for alpha.
This adds alpha-specific first-pass GOT relocation code to boot.h. The assembly code is pure magic. The numeric register names don't make it easier to understand (or compare with the equivalent ld.so code). Unfortunately the assembler only understands a few symbolic register names.
Renames the crt0.o entry point to __start. Our compiler was already using __start and the linker will soon follow.
ok kurt@
|
#
1.7 |
|
25-Dec-2014 |
kurt |
Use archdep.h GOT_PERMS define for mprotect of GOT. okay kettenis@
|
#
1.6 |
|
24-Dec-2014 |
kurt |
Expand Elf_Rel relocations to include DT_JMPREL. Inspect DT_PLTREL value to determine if DT_JMPREL relocations are REL or RELA and conditionally perform DT_JMPREL in either REL or RELA as needed (idea from kettenis@). Remove unneeded i386 RELA implementation. i386 static pie working now.
okay kettenis@
|
#
1.5 |
|
24-Dec-2014 |
kettenis |
Fix previos. Pointed out by kurt@.
|
#
1.4 |
|
23-Dec-2014 |
kettenis |
Use the page size passed by the kernel in the Auxilliary Vector to handle architectures with variable page size.
|
#
1.3 |
|
23-Dec-2014 |
kettenis |
Make sure the GOT and PLT are not writable.
Note that ommitting PROT_EXEC for the PLT is deliberate; static PIE binaries should never actually hit the PLT.
We're still debating what to do when mprotect(2) fails. But that is no excuse not to at least attempt to fix things up.
ok deraadt@
|
#
1.2 |
|
22-Dec-2014 |
kettenis |
When skipping a relocation because the referenced symbol is undefined, make sure we move on to the next relocation entry.
While there, also skip relocations for REL architectures.
|
#
1.1 |
|
22-Dec-2014 |
kurt |
Introduce new csu0 variant for -static -pie binaries to use called rcsu0.o where the initial 'r' is for relocatable. rcsu0.o performs self-relocation on static pie binaries by calling a slightly modified copy of ld.so's _dl_boot_bind() in boot.h.
The first arch implementatation is also included for amd64 where __start calls _dl_boot_bind() and then calls ___start(). Includes parts from kettenis@ to help get R_X86_64_64 relocations working and proper handling for undefined weak symbols.
This is the first part of several to get static pie self-relocating binaries working. binutils, gcc and kernel changes are forthcoming to complete the solution, then per-arch implementations are needed for MD_RCRT0_START in csu.
okay kettenis@ pascal@ deraadt@
|
Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
|
#
1.28 |
|
29-Jan-2017 |
chl |
remove unused variables
ok krw@ guenther@
|
#
1.27 |
|
02-Jan-2017 |
kettenis |
Remove the (now unused) code to determine the page size. Also get rid of the extern declaration of __got_{start,end}.
ok guenther@
|
#
1.26 |
|
24-Dec-2016 |
kettenis |
Replace return by break; requested by guenther@
|
#
1.25 |
|
24-Dec-2016 |
kettenis |
Remove code that reprotects the GOT based on the __got_start and __got_end symbols. Either the PT_LOAD RWX->RX case ot PT_GNU_RELRO should cover this already for anything we care about. And lld, the llvm linker, doesn't emit the __got_start and __got_end symbols and there are good reasons to leave it that way.
ok guenther@
|
#
1.24 |
|
19-Dec-2016 |
krw |
A couple more unused variables.
tweak & ok kettenis@
|
#
1.23 |
|
01-Sep-2016 |
tedu |
retire sparc
|
#
1.22 |
|
08-Aug-2016 |
guenther |
Look for a PT_GNU_RELRO section and, if present, mprotect that range instead of the [__got_start, __got_end) range.
Also, instead of mprotecting the [__plt_start, __plt_end) range, just scan for sections which are both writable and executable and mprotect them to read-only. (This part was stolen from kettenis@)
ok kettenis@
|
#
1.21 |
|
07-Aug-2016 |
guenther |
Teach mips64 to pass &_DYNAMIC to _dl_boot_bind().
mips64be testing by deraadt@
|
#
1.20 |
|
07-Aug-2016 |
guenther |
alpha already calculates &_DYNAMIC for the _reloc_alpha_got() call, so save that and pass it to _dl_boot_bind() too
|
#
1.19 |
|
07-Aug-2016 |
guenther |
Teach i386 to pass &_DYNAMIC to _dl_boot_bind()
|
#
1.18 |
|
07-Aug-2016 |
guenther |
Psych: amd64 has been passing &_DYNAMIC to _dl_boot_bind() for 19 months
|
#
1.17 |
|
07-Aug-2016 |
guenther |
Flip the #ifdef logic: amd64, i386, and mips64 were the only static PIE archs using the #else case
|
Revision tags: OPENBSD_6_0_BASE
|
#
1.16 |
|
05-Jul-2016 |
guenther |
Missed a reference to dl_prebind.h
problem noted by Andrew Ngo (andrew.ngo (at) gmail.com)
|
#
1.15 |
|
12-Mar-2016 |
guenther |
Call mprotect() via its hidden _lib_mprotect alias to avoid accidental overriding
ok deraadt@ kettenis@
|
Revision tags: OPENBSD_5_9_BASE
|
#
1.14 |
|
06-Dec-2015 |
guenther |
Simplify the relocation code for the ld.so bootstrap and static pie: track just the dynamic tags are needed instead of reusing the generic elf_object_t structure.
testing and feedback from miod@ ok kettenis@
|
#
1.13 |
|
19-Sep-2015 |
kettenis |
Make sure we set PROT_EXEC on the GOT for BSS-PLT binaries on powerpc.
ok guenther@
|
#
1.12 |
|
17-Aug-2015 |
kettenis |
Do not include os-note-elf.h here, otherwise we end up with duplicate OS notes in our binaries.
ok miod@
|
Revision tags: OPENBSD_5_8_BASE
|
#
1.11 |
|
03-Jul-2015 |
miod |
static pie support for sparc.
|
Revision tags: OPENBSD_5_7_BASE
|
#
1.10 |
|
16-Jan-2015 |
deraadt |
<sys/param.h> is not needed here either. ok guenther millert doug
|
#
1.9 |
|
29-Dec-2014 |
kettenis |
Make the PLT read-only on powerpc as well.
ok kurt@
|
#
1.8 |
|
27-Dec-2014 |
kettenis |
Static PIE support for alpha.
This adds alpha-specific first-pass GOT relocation code to boot.h. The assembly code is pure magic. The numeric register names don't make it easier to understand (or compare with the equivalent ld.so code). Unfortunately the assembler only understands a few symbolic register names.
Renames the crt0.o entry point to __start. Our compiler was already using __start and the linker will soon follow.
ok kurt@
|
#
1.7 |
|
25-Dec-2014 |
kurt |
Use archdep.h GOT_PERMS define for mprotect of GOT. okay kettenis@
|
#
1.6 |
|
24-Dec-2014 |
kurt |
Expand Elf_Rel relocations to include DT_JMPREL. Inspect DT_PLTREL value to determine if DT_JMPREL relocations are REL or RELA and conditionally perform DT_JMPREL in either REL or RELA as needed (idea from kettenis@). Remove unneeded i386 RELA implementation. i386 static pie working now.
okay kettenis@
|
#
1.5 |
|
24-Dec-2014 |
kettenis |
Fix previos. Pointed out by kurt@.
|
#
1.4 |
|
23-Dec-2014 |
kettenis |
Use the page size passed by the kernel in the Auxilliary Vector to handle architectures with variable page size.
|
#
1.3 |
|
23-Dec-2014 |
kettenis |
Make sure the GOT and PLT are not writable.
Note that ommitting PROT_EXEC for the PLT is deliberate; static PIE binaries should never actually hit the PLT.
We're still debating what to do when mprotect(2) fails. But that is no excuse not to at least attempt to fix things up.
ok deraadt@
|
#
1.2 |
|
22-Dec-2014 |
kettenis |
When skipping a relocation because the referenced symbol is undefined, make sure we move on to the next relocation entry.
While there, also skip relocations for REL architectures.
|
#
1.1 |
|
22-Dec-2014 |
kurt |
Introduce new csu0 variant for -static -pie binaries to use called rcsu0.o where the initial 'r' is for relocatable. rcsu0.o performs self-relocation on static pie binaries by calling a slightly modified copy of ld.so's _dl_boot_bind() in boot.h.
The first arch implementatation is also included for amd64 where __start calls _dl_boot_bind() and then calls ___start(). Includes parts from kettenis@ to help get R_X86_64_64 relocations working and proper handling for undefined weak symbols.
This is the first part of several to get static pie self-relocating binaries working. binutils, gcc and kernel changes are forthcoming to complete the solution, then per-arch implementations are needed for MD_RCRT0_START in csu.
okay kettenis@ pascal@ deraadt@
|