summaryrefslogtreecommitdiff
path: root/lib/csu
AgeCommit message (Collapse)Author
2016-09-01retire sparcTed Unangst
2016-08-08Look for a PT_GNU_RELRO section and, if present, mprotect that rangePhilip Guenther
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@
2016-08-07Teach mips64 to pass &_DYNAMIC to _dl_boot_bind().Philip Guenther
mips64be testing by deraadt@
2016-08-07alpha already calculates &_DYNAMIC for the _reloc_alpha_got() call, soPhilip Guenther
save that and pass it to _dl_boot_bind() too
2016-08-07Teach i386 to pass &_DYNAMIC to _dl_boot_bind()Philip Guenther
2016-08-07Psych: amd64 has been passing &_DYNAMIC to _dl_boot_bind() for 19 monthsPhilip Guenther
2016-08-07Flip the #ifdef logic: amd64, i386, and mips64 were the only static PIEPhilip Guenther
archs using the #else case
2016-07-05Missed a reference to dl_prebind.hPhilip Guenther
problem noted by Andrew Ngo (andrew.ngo (at) gmail.com)
2016-05-11remove hppa64 port, which we never got going beyond broken single users.Theo de Raadt
hppa reverse-stack gives us a valuable test case, but most developers don't have a 2nd one to proceed further with this. ok kettenis
2016-05-07Declare moncontrol(3) APIs in <sys/gmon.h>Philip Guenther
Export _gmonparam again. Make gcrt0.o use an reserved name for _monstartup() ok millert@
2016-03-24Unbreak arm and m88k: COPY relocations for weak symbols that are overloadedPhilip Guenther
with strong symbols in ld.so don't do what we need, so put definitions back in crt0 and make ld.so update __progname like it does environ. report and testing patrick@ jsg@
2016-03-20Rearrange C runtime bits: now that ld.so exports environ and __progname,Philip Guenther
move their definitions and initialization in static links to libc.a Make crt0 always invoke a new func _csu_finish() in libc to process the auxv and to either register the ld.so cleanup function (in dynamic links) or initialize environ and __progname and do MC_DISABLE_KBIND (in static links). In libc, get pagesize from auxv; cache that between getpagesize() and sysconf(_SC_PAGESIZE) ok mpi@ "good time" deraadt@
2016-03-13crt0.c is already setting environ, so don't set it in MD_START_SETUPPhilip Guenther
ok kettenis@ mpi@
2016-03-12Call mprotect() via its hidden _lib_mprotect alias to avoid accidentalPhilip Guenther
overriding ok deraadt@ kettenis@
2016-03-09We are done providing support for the vax.Theo de Raadt
lots of agreement.
2015-12-06Simplify the relocation code for the ld.so bootstrap and static pie: trackPhilip Guenther
just the dynamic tags are needed instead of reusing the generic elf_object_t structure. testing and feedback from miod@ ok kettenis@
2015-11-10libc.so can't be unloaded, so move the hidden atexit() and pthread_atfork()Philip Guenther
stubs for the executable from crtbegin.o into libc, which lets them be excluded from static links that don't use them. For this, drop the normal crt{begin,end}S.o from libc.so: the .init and .fini sections for libc aren't called at the right times anyway, so it's good that they're unused. libc.so just needs __guard_local and the .note.openbsd.ident section, so add them to stack_protector.c for now (this will be improved) "good time" deraadt@
2015-09-19We don't need to calculate the load offset. This also means we don't needMark Kettenis
to calculate the GOT address anymore. ok guenther@ (who spotted the latter bit)
2015-09-19Make sure we set PROT_EXEC on the GOT for BSS-PLT binaries on powerpc.Mark Kettenis
ok guenther@
2015-09-09Fetch the _GLOBAL)OFFSET_TABLE_ and _DYNAMIC pointers in a way that'sMark Kettenis
compatible with the Secure-PLT ABI.
2015-09-09Now that ld(1) will generate a read-only GOT for truly static binaries, weMark Kettenis
no longer have to use mprotect(2) to take away PROT_WRITE. This fixes ld -Z and paves the way for the new Secure-PLT ABI. ok miod@
2015-09-01In static binaries, invoke kbind() once to disable it.Philip Guenther
With much assistance from miod@ ok deraadt@@
2015-08-17Do not include os-note-elf.h here, otherwise we end up with duplicate OS notesMark Kettenis
in our binaries. ok miod@
2015-07-03static pie support for sparc.Miod Vallat
2015-04-07Make pthread_atfork() track the DSO that called it like atexit() does,Philip Guenther
unregistering callbacks if the DSO is unloaded. Move the callback handling from libpthread to libc, though libpthread still overrides the inner call to handle locking and thread-library reinitialization. Major version bump for both libc and libpthread. verification that this fixes various ports ajacoutot@ asm assistance miod@; ok millert@ deraadt@
2015-04-04gcc 2.x is deadPhilip Guenther
ok millert@
2015-02-07argc is passed as a long by the kernel, define it as such to match whatMiod Vallat
other ports do.
2015-01-16<sys/param.h> is not needed here either.Theo de Raadt
ok guenther millert doug
2015-01-01Inline the .cpsetup pseudo-statement in rcrt0 to avoid saving the "old" gpMiod Vallat
value, which we have no use for. ok kettenis@
2014-12-30self-relocating crt0 bits for sh, and enable static pie by default. With someMiod Vallat
archdep.h help from kettenis@
2014-12-29Make the PLT read-only on powerpc as well.Mark Kettenis
ok kurt@
2014-12-27Static PIE for mips64. Still something not quite right as a full make buildMark Kettenis
fails. ok kurt@
2014-12-27Only include "boot.h" if MD_RCRT0_START is defined. Should fix build on vax.Mark Kettenis
ok miod@
2014-12-27Static PIE support for alpha.Mark Kettenis
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@
2014-12-26Self-relocation code for powerpc.Kurt Miller
2014-12-25Use archdep.h GOT_PERMS define for mprotect of GOT. okay kettenis@Kurt Miller
2014-12-24Expand Elf_Rel relocations to include DT_JMPREL. Inspect DT_PLTREL valueKurt Miller
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@
2014-12-24Fix previos. Pointed out by kurt@.Mark Kettenis
2014-12-23Use the page size passed by the kernel in the Auxilliary Vector to handleMark Kettenis
architectures with variable page size.
2014-12-23Make sure the GOT and PLT are not writable.Mark Kettenis
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@
2014-12-23do not expose "ra" to cpp because it muddles up the .c code above.Theo de Raadt
instead handle it internally as $ra solution from kettenis, ok guenther
2014-12-23Set up the linkage table register (%r19) before calling _dl_boot_bind.Mark Kettenis
2014-12-22Self-relocation code for i386.Kurt Miller
2014-12-22Self-relocation code for hppa.Mark Kettenis
2014-12-22Self-relocation code for sparc64.Mark Kettenis
2014-12-22When skipping a relocation because the referenced symbol is undefined, makeMark Kettenis
sure we move on to the next relocation entry. While there, also skip relocations for REL architectures.
2014-12-22Introduce new csu0 variant for -static -pie binaries to use calledKurt Miller
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@
2014-11-22mop up a barely started project... getting in the way of grepping the tree!Theo de Raadt
2014-11-15Objects for the executable can be PIE instead of PIC, so remove the sparc64Philip Guenther
special case; no binary change ok kettenis@
2014-11-15ELF uberalles, so move the files up out of common_elfPhilip Guenther
ok miod@ deraadt@