diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2014-02-25 21:40:40 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2014-02-25 21:40:40 +0000 |
commit | a87fd491fabf6b46b5784c7022917e59920fd554 (patch) | |
tree | 1381cfa307fb7cec21599dca595ad8ff4ef9d846 /sys | |
parent | b653ae083972d24396f9408915f82528880e53eb (diff) |
Do not actually write to the area spanned by the PT_OPENBSD_RANDOMIZE if
LOAD_DATA is not set in flags; allows a two-pass kernel load using COUNT_KERNEL
and then LOAD_KERNEL to work; similar to sparc loadfile_sparc.c 1.3.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/lib/libsa/loadfile_elf.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/sys/lib/libsa/loadfile_elf.c b/sys/lib/libsa/loadfile_elf.c index 493aedd0e85..e9ee42440de 100644 --- a/sys/lib/libsa/loadfile_elf.c +++ b/sys/lib/libsa/loadfile_elf.c @@ -1,5 +1,5 @@ /* $NetBSD: loadfile.c,v 1.10 2000/12/03 02:53:04 tsutsui Exp $ */ -/* $OpenBSD: loadfile_elf.c,v 1.7 2013/12/28 02:51:07 deraadt Exp $ */ +/* $OpenBSD: loadfile_elf.c,v 1.8 2014/02/25 21:40:39 miod Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -98,10 +98,15 @@ ELFNAME(exec)(int fd, Elf_Ehdr *elf, u_long *marks, int flags) if (phdr[i].p_type == PT_OPENBSD_RANDOMIZE) { int m; - /* Fill segment. */ - for (pos = 0; pos < phdr[i].p_filesz; pos += m) { - m = MIN(phdr[i].p_filesz - pos, sizeof(rnddata)); - BCOPY(rnddata, phdr[i].p_paddr + pos, m); + /* Fill segment if asked for. */ + if (flags & LOAD_DATA) { + for (pos = 0; pos < phdr[i].p_filesz; + pos += m) { + m = MIN(phdr[i].p_filesz - pos, + sizeof(rnddata)); + BCOPY(rnddata, phdr[i].p_paddr + pos, + m); + } } continue; } |