summaryrefslogtreecommitdiff
path: root/lib/csu/crt0.c
diff options
context:
space:
mode:
authorKurt Miller <kurt@cvs.openbsd.org>2014-12-22 03:51:09 +0000
committerKurt Miller <kurt@cvs.openbsd.org>2014-12-22 03:51:09 +0000
commit4c3e2b03181a91c59b536d4cdec6f6f5d1cdf236 (patch)
tree85e45cf9486a5541d2fe1b1a8331d72958564c26 /lib/csu/crt0.c
parentd98892b19f775c4dd3ad9557727627fb148b2fd0 (diff)
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@
Diffstat (limited to 'lib/csu/crt0.c')
-rw-r--r--lib/csu/crt0.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/csu/crt0.c b/lib/csu/crt0.c
index aaef64a7a57..965eba66e97 100644
--- a/lib/csu/crt0.c
+++ b/lib/csu/crt0.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: crt0.c,v 1.2 2013/12/12 08:12:08 guenther Exp $ */
+/* $OpenBSD: crt0.c,v 1.3 2014/12/22 03:51:08 kurt Exp $ */
/*
* Copyright (c) 1995 Christopher G. Demetriou
@@ -35,6 +35,7 @@
#include <limits.h>
#include "md_init.h"
+#include "boot.h"
/* some defaults */
#ifndef MD_START_ARGS
@@ -64,9 +65,15 @@ extern void _mcleanup(void);
extern unsigned char _etext, _eprol;
#endif /* MCRT0 */
+#ifdef RCRT0
+#ifdef MD_RCRT0_START
+MD_RCRT0_START;
+#endif
+#else
#ifdef MD_CRT0_START
MD_CRT0_START;
#endif
+#endif
void
MD_START(MD_START_ARGS)