summaryrefslogtreecommitdiff
path: root/lib/csu
AgeCommit message (Collapse)Author
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@
2013-12-28Move atexit(3) into crtbegin.c and certbeginS.c such that we can pass theMark Kettenis
right __dso_handle and have dlopen'ed shared objects run their atexit handlers when they get unloaded. This is what Linux does, and several ports depend on this behaviour (and will crash upon exit without this chang). Based on an earlier diff from matthew@ Tested by ajacoutot@ ok deraadt@
2013-12-12Fix static linking of libpthread: have crt0 invoke __init_tcb() if it'sPhilip Guenther
defined and we don't think ld.so has already done the TCB setup. ok and much discussion miod@
2013-12-03Merge the per-arch crt0.c files into common_elf/crt0.c, with MD macros inPhilip Guenther
the md_init.h files. Worked out with and ok miod@; ok matthew@
2012-12-05Remove excessive sys/cdefs.h inclusionTheo de Raadt
ok guenther millert kettenis
2012-09-08Reverse the order that ctors and dtors are run in accordance withMatthew Dempsky
GCC's documentation. Fixes GNU C++'s init_priority attribute. ok miod
2012-08-28Add __guard_local as a hidden symbol to ld.so, kernel, and everyMatthew Dempsky
executable and DSO (via crtbegin.c/crtbeginS.c). Not used yet, but needed before GCC can start emitting -fstack-protector code that uses them instead of __guard.
2010-05-01Sprinkle a few __used markers to prevent gcc4 from throwing away essentialMark Kettenis
bits of code and data. With this change gcc4 builds usable crt*.o on sparc64, other architectures probably need some more love. ok marco@, jsg@
2009-07-14Don't specify mode(SI) attribute for __EH_FRAME_END__ as we haveJonathan Gray
32 bit ints on OpenBSD. ok kettenis@
2009-04-13Add gcj java class registration hooks for gcc3 elf archs. From NetBSDKurt Miller
with minor differences. okay kettenis@ drahn@