summaryrefslogtreecommitdiffstats
path: root/lib/csu/amd64
AgeCommit message (Collapse)AuthorFilesLines
2020-10-15crt0 MD _dl_exit() performs syscall to SYS_exit directly, but thenderaadt1-6/+2
some of these functions were returning. That makes the +1word address a fairly strong and easily located gadget. Put a hard-trap instruction after the syscall. This remains a gadget for 'terminal system' calls (such as execve), but hey that's why we have pledge w/o "exec" throughout the tree. Quite surprisingly, hppa's delay-slot load of SYS_exit makes it the safest of the bunch, not that this helps anyone. ok kettenis
2020-10-14use symbolic SYS_exit instead of the value 1deraadt1-3/+2
ok kettenis
2016-03-20Rearrange C runtime bits: now that ld.so exports environ and __progname,guenther1-9/+1
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@
2015-09-01In static binaries, invoke kbind() once to disable it.guenther1-2/+8
With much assistance from miod@ ok deraadt@@
2014-12-22Introduce new csu0 variant for -static -pie binaries to use calledkurt1-1/+46
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-12Merge Makefiles, moving the build up a level and putting the CPU-specificguenther1-61/+0
build flags into conditionals in the Makefile, fixing a few inconsistencies in the process. \o/ miod@
2013-12-03Merge the per-arch crt0.c files into common_elf/crt0.c, with MD macros inguenther3-124/+25
the md_init.h files. Worked out with and ok miod@; ok matthew@
2013-11-10The kernel and ld.so pass 0 in %rdx for use as the cleanup callbackguenther1-11/+6
for about a year, so it's safe to add the test and atexit() call. While here, drop the no-longer-used obj and ps_strings and the asm to set those up, switch from sys/param.h to limits.h, and ANSIfy. ok kettenis@
2011-11-08Pass install the -S option to avoid a window where the target isn'tguenther1-2/+2
executable (by mode or content), which can trip up builds with 'make -j' (The generic fix is in share/mk/*; some Makefiles have their own INSTALL lines) ok millert@ deraadt@
2011-03-30Make sure everything run from .init and .fini sections gets a properly alignedkettenis1-2/+3
stack. ok deraadt@, fgsch@
2009-10-27rcsid[] and sccsid[] and copyright[] are essentially unmaintained (andderaadt1-2/+2
unmaintainable). these days, people use source. these id's do not provide any benefit, and do hurt the small install media (the 33,000 line diff is essentially mechanical) ok with the idea millert, ok dms
2008-11-11Compile crt0.o, crtbegin.o and crtend.o with -fpie/-fPIE. This requireskurt1-7/+7
gcc with pie support to be built first. ok kettenis@
2008-10-06The recent change to bsd.own.mk to allow PICFLAG to be overridden madekurt1-3/+1
these previously ignored PICFLAG settings become active. Remove PICFLAG overrides to restore -fpic/-fPIC modes. In snaps for a week. okay drahn@
2008-07-28Remove separate pic versions of crt0, crtbegin, crtend. Nextkurt1-21/+2
release we are taking a different approach. Idea from kettenis@. okay kettenis@ weingart@
2008-06-25Build pic versions of crt0, crtbegin & crtend for amd64, i386, powerpc,kurt1-2/+23
sparc64. The rest will come later. okay drahn@ no objection miod@ "Get it in" deraadt@
2007-10-17remove "unused variable" warningschl1-2/+1
tested by deraadt@ on a gcc2 arch looks ok ray@ ok deraadt@
2005-08-04zap rcsid. Okay deraadt@, krw@espie1-5/+1
2004-01-28things for amd64; from art@mickey3-0/+250