summaryrefslogtreecommitdiffstats
path: root/lib/csu (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Simplify the relocation code for the ld.so bootstrap and static pie: trackguenther2015-12-061-132/+71
| | | | | | | | just the dynamic tags are needed instead of reusing the generic elf_object_t structure. testing and feedback from miod@ ok kettenis@
* libc.so can't be unloaded, so move the hidden atexit() and pthread_atfork()guenther2015-11-101-22/+1
| | | | | | | | | | | 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@
* We don't need to calculate the load offset. This also means we don't needkettenis2015-09-191-8/+1
| | | | | | to calculate the GOT address anymore. ok guenther@ (who spotted the latter bit)
* Make sure we set PROT_EXEC on the GOT for BSS-PLT binaries on powerpc.kettenis2015-09-191-2/+10
| | | | ok guenther@
* Fetch the _GLOBAL)OFFSET_TABLE_ and _DYNAMIC pointers in a way that'skettenis2015-09-091-43/+9
| | | | compatible with the Secure-PLT ABI.
* Now that ld(1) will generate a read-only GOT for truly static binaries, wekettenis2015-09-091-72/+4
| | | | | | | 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@
* In static binaries, invoke kbind() once to disable it.guenther2015-09-0114-17/+122
| | | | | With much assistance from miod@ ok deraadt@@
* Do not include os-note-elf.h here, otherwise we end up with duplicate OS noteskettenis2015-08-171-3/+1
| | | | | | in our binaries. ok miod@
* static pie support for sparc.miod2015-07-032-4/+63
|
* Make pthread_atfork() track the DSO that called it like atexit() does,guenther2015-04-072-2/+29
| | | | | | | | | | 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@
* gcc 2.x is deadguenther2015-04-044-25/+8
| | | | ok millert@
* argc is passed as a long by the kernel, define it as such to match whatmiod2015-02-071-2/+2
| | | | other ports do.
* <sys/param.h> is not needed here either.deraadt2015-01-161-2/+1
| | | | ok guenther millert doug
* Inline the .cpsetup pseudo-statement in rcrt0 to avoid saving the "old" gpmiod2015-01-011-2/+4
| | | | value, which we have no use for. ok kettenis@
* self-relocating crt0 bits for sh, and enable static pie by default. With somemiod2014-12-301-6/+67
| | | | archdep.h help from kettenis@
* Make the PLT read-only on powerpc as well.kettenis2014-12-291-2/+2
| | | | ok kurt@
* Static PIE for mips64. Still something not quite right as a full make buildkettenis2014-12-271-1/+44
| | | | | | fails. ok kurt@
* Only include "boot.h" if MD_RCRT0_START is defined. Should fix build on vax.kettenis2014-12-271-1/+3
| | | | ok miod@
* Static PIE support for alpha.kettenis2014-12-272-8/+80
| | | | | | | | | | | | | 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@
* Self-relocation code for powerpc.kurt2014-12-261-1/+99
|
* Use archdep.h GOT_PERMS define for mprotect of GOT. okay kettenis@kurt2014-12-251-2/+2
|
* Expand Elf_Rel relocations to include DT_JMPREL. Inspect DT_PLTREL valuekurt2014-12-241-6/+21
| | | | | | | | 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@
* Fix previos. Pointed out by kurt@.kettenis2014-12-241-2/+2
|
* Use the page size passed by the kernel in the Auxilliary Vector to handlekettenis2014-12-231-5/+11
| | | | architectures with variable page size.
* Make sure the GOT and PLT are not writable.kettenis2014-12-231-1/+23
| | | | | | | | | | 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@
* do not expose "ra" to cpp because it muddles up the .c code above.deraadt2014-12-231-7/+5
| | | | | instead handle it internally as $ra solution from kettenis, ok guenther
* Set up the linkage table register (%r19) before calling _dl_boot_bind.kettenis2014-12-231-9/+9
|
* Self-relocation code for i386.kurt2014-12-221-1/+50
|
* Self-relocation code for hppa.kettenis2014-12-221-1/+73
|
* Self-relocation code for sparc64.kettenis2014-12-221-1/+44
|
* When skipping a relocation because the referenced symbol is undefined, makekettenis2014-12-221-5/+7
| | | | | | sure we move on to the next relocation entry. While there, also skip relocations for REL architectures.
* Introduce new csu0 variant for -static -pie binaries to use calledkurt2014-12-224-4/+315
| | | | | | | | | | | | | | | | | | 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@
* mop up a barely started project... getting in the way of grepping the tree!deraadt2014-11-222-152/+0
|
* Objects for the executable can be PIE instead of PIC, so remove the sparc64guenther2014-11-151-9/+1
| | | | | | special case; no binary change ok kettenis@
* ELF uberalles, so move the files up out of common_elfguenther2014-11-158-578/+14
| | | | ok miod@ deraadt@
* Merge Makefiles, moving the build up a level and putting the CPU-specificguenther2014-11-1215-858/+94
| | | | | | | build flags into conditionals in the Makefile, fixing a few inconsistencies in the process. \o/ miod@
* m68k is dead <sniff>guenther2014-11-103-134/+2
| | | | ok miod@
* It's been a quarter century: we can assume volatile is present with that name.guenther2014-04-181-2/+2
|
* Increase _STACKALIGNBYTES to 15 (was 7), and make sure the stack is alignedmiod2014-02-221-1/+3
| | | | | | | to a 16 byte boundary in csu (similar to what the other arches where _STACKALIGNBYTES != _ALIGNBYTES do). This is necessary for long double variables on the stack to be correctly aligned.
* build crt*S with -fPIC instead of -fpicmiod2014-01-141-2/+2
|
* Move atexit(3) into crtbegin.c and certbeginS.c such that we can pass thekettenis2013-12-284-4/+36
| | | | | | | | | | 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@
* Add assembly code to set up the arguments for the common C startup code. Thiskettenis2013-12-231-29/+19
| | | | | | | means we no longer rely on how the C compiler sets up the initial stack frame and allows us to get rid of MD_NO_CLEANUP. ok deraadt@, guenther@
* Sync Makefile with what other platforms do; makes dependency tracking actuallykettenis2013-12-231-14/+45
| | | | | | work. ok deraadt@, guenther@
* Fix typo, allow hppa64 to build a little furthertobiasu2013-12-201-2/+2
|
* Fix static linking of libpthread: have crt0 invoke __init_tcb() if it'sguenther2013-12-122-2/+12
| | | | | | defined and we don't think ld.so has already done the TCB setup. ok and much discussion miod@
* correct frame handlingderaadt2013-12-041-8/+3
| | | | with and ok guenther
* Merge the per-arch crt0.c files into common_elf/crt0.c, with MD macros inguenther2013-12-0342-1775/+605
| | | | | | the md_init.h files. Worked out with and ok miod@; ok matthew@
* mips64 no longer uses scrt0.o, and it was identical to crt0.o anyway.guenther2013-12-014-17/+5
| | | | | | Delete unused #ifndef SCRT0 conditionals. ok miod@
* The kernel and ld.so have passed 0 in r0 for use as the cleanupguenther2013-11-101-11/+6
| | | | | | | | | | callback for about a year, so it's safe to make __start() pass that as the cleanup argument to ___start(), and have *that* conditionally pass it to atexit(). Eliminate the no-longer-used obj and ps_strings arguments to position things correctly, simplifying the ASM wrapper slightly. ok kettenis@ miod@; testing patrick@
* The kernel and ld.so have passed 0 in r7 for use as the cleanupguenther2013-11-101-19/+5
| | | | | | | | | callback for about a year, so it's safe to make __start() treat that as the cleanup argument and conditionally pass it to atexit(). Eliminate the no-longer-used obj and ps_strings arguments to position things correctly, which lets us eliminate the ASM wrapper completely. ok kettenis@ miod@