summaryrefslogtreecommitdiff
path: root/usr.sbin/mkuboot/copy_elf.c
diff options
context:
space:
mode:
authorRyan Thomas McBride <mcbride@cvs.openbsd.org>2014-01-01 09:24:55 +0000
committerRyan Thomas McBride <mcbride@cvs.openbsd.org>2014-01-01 09:24:55 +0000
commit6b31c74caabab1a94333911a7fa1cbe80fa9a15f (patch)
treec65291d44219f27907eddeb38917c4a6f35f3216 /usr.sbin/mkuboot/copy_elf.c
parentbfa22818f38a58aaa7037f6416bd3e5842a96a25 (diff)
Fix 'make bsd.umg' by skipping PT_OPENBSD_RANDOMIZE segments, as well as
other innocuous segment types (PT_NOTE, PT_NULL). Handle PT_LOAD, fail on any others. Thanks kettenis and millert for feedback ok deraadt
Diffstat (limited to 'usr.sbin/mkuboot/copy_elf.c')
-rw-r--r--usr.sbin/mkuboot/copy_elf.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/usr.sbin/mkuboot/copy_elf.c b/usr.sbin/mkuboot/copy_elf.c
index b6aff8bad1a..60e5e77e531 100644
--- a/usr.sbin/mkuboot/copy_elf.c
+++ b/usr.sbin/mkuboot/copy_elf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: copy_elf.c,v 1.4 2013/12/31 07:15:57 mcbride Exp $ */
+/* $OpenBSD: copy_elf.c,v 1.5 2014/01/01 09:24:54 mcbride Exp $ */
/*
* Copyright (c) 2013 Miodrag Vallat.
@@ -137,11 +137,30 @@ ELFNAME(copy_elf)(int ifd, const char *iname, int ofd, const char *oname,
err(1, "%s", iname);
#ifdef DEBUG
- fprintf(stderr, "vaddr %p offset %p filesz %p memsz %p\n",
- elfoff2h(phdr.p_vaddr), elfoff2h(phdr.p_offset),
- elfoff2h(phdr.p_filesz), elfoff2h(phdr.p_memsz));
+ fprintf(stderr,
+ "vaddr %p type %#x offset %p filesz %p memsz %p\n",
+ elfoff2h(phdr.p_vaddr), letoh32(phdr.p_type),
+ elfoff2h(phdr.p_offset), elfoff2h(phdr.p_filesz),
+ elfoff2h(phdr.p_memsz));
#endif
- if (i == 0)
+
+ switch (letoh32(phdr.p_type)) {
+ case PT_LOAD:
+ break;
+ case PT_NULL:
+ case PT_NOTE:
+ case PT_OPENBSD_RANDOMIZE:
+#ifdef DEBUG
+ fprintf(stderr, "skipping segment type %#x\n",
+ letoh32(phdr.p_type));
+#endif
+ continue;
+ default:
+ errx(1, "unexpected segment type %#x",
+ letoh32(phdr.p_type));
+ }
+
+ if (i == 0)
vaddr = elfoff2h(phdr.p_vaddr);
else if (vaddr != elfoff2h(phdr.p_vaddr)) {
#ifdef DEBUG