summaryrefslogtreecommitdiffstats
path: root/lib/csu
diff options
context:
space:
mode:
authorkettenis <kettenis@openbsd.org>2015-09-19 20:11:22 +0000
committerkettenis <kettenis@openbsd.org>2015-09-19 20:11:22 +0000
commit7afb7909958322d23edbee34baf894d026a81268 (patch)
tree72bae31509089e00616f0de6716205f8341078b8 /lib/csu
parentMake bootstrapping code compatible with the Secure-PLT ABI. (diff)
downloadwireguard-openbsd-7afb7909958322d23edbee34baf894d026a81268.tar.xz
wireguard-openbsd-7afb7909958322d23edbee34baf894d026a81268.zip
Make sure we set PROT_EXEC on the GOT for BSS-PLT binaries on powerpc.
ok guenther@
Diffstat (limited to 'lib/csu')
-rw-r--r--lib/csu/boot.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/csu/boot.h b/lib/csu/boot.h
index 1af62c3e0e1..ee8e7b91c65 100644
--- a/lib/csu/boot.h
+++ b/lib/csu/boot.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: boot.h,v 1.12 2015/08/17 17:13:58 kettenis Exp $ */
+/* $OpenBSD: boot.h,v 1.13 2015/09/19 20:11:22 kettenis Exp $ */
/*
* Copyright (c) 1998 Per Fogelstrom, Opsycon AB
@@ -50,6 +50,8 @@
#include "stdlib.h"
#include "dl_prebind.h"
+#define DT_PROC(n) ((n) - DT_LOPROC + DT_NUM)
+
#ifdef RCRT0
/*
@@ -75,6 +77,7 @@ _dl_boot_bind(const long sp, long *dl_data, Elf_Dyn *dynamicp)
int n, argc;
char **argv, **envp;
long loff;
+ int prot_exec = 0;
/*
* Scan argument and environment vectors. Find dynamic
@@ -287,9 +290,14 @@ _dl_boot_bind(const long sp, long *dl_data, Elf_Dyn *dynamicp)
mprotect((void *)start, size, PROT_READ);
#endif
+#if defined(__powerpc__)
+ if (dynld.Dyn.info[DT_PROC(DT_PPC_GOT)] == 0)
+ prot_exec = PROT_EXEC;
+#endif
+
start = ELF_TRUNC((Elf_Addr)__got_start, pagesize);
size = ELF_ROUND((Elf_Addr)__got_end - start, pagesize);
- mprotect((void *)start, size, GOT_PERMS);
+ mprotect((void *)start, size, GOT_PERMS | prot_exec);
}
#ifdef __alpha__