Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Don't process ELF sections that don't have the ALLOC fla...



details:   https://anonhg.NetBSD.org/src/rev/c33c6fd1b6cc
branches:  trunk
changeset: 827824:c33c6fd1b6cc
user:      maxv <maxv%NetBSD.org@localhost>
date:      Mon Nov 13 21:32:21 2017 +0000

description:
Don't process ELF sections that don't have the ALLOC flag set.

NOTE: you need to update both the prekern and the bootloader after this
change.

diffstat:

 sys/arch/amd64/stand/prekern/elf.c |  5 ++++-
 sys/lib/libsa/loadfile_elf32.c     |  6 +++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diffs (39 lines):

diff -r 31fa91d284ef -r c33c6fd1b6cc sys/arch/amd64/stand/prekern/elf.c
--- a/sys/arch/amd64/stand/prekern/elf.c        Mon Nov 13 21:14:03 2017 +0000
+++ b/sys/arch/amd64/stand/prekern/elf.c        Mon Nov 13 21:32:21 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: elf.c,v 1.10 2017/11/13 21:14:04 maxv Exp $    */
+/*     $NetBSD: elf.c,v 1.11 2017/11/13 21:32:21 maxv Exp $    */
 
 /*
  * Copyright (c) 2017 The NetBSD Foundation, Inc. All rights reserved.
@@ -272,6 +272,9 @@
        for (i = 0; i < eif.ehdr->e_shnum; i++) {
                shdr = &eif.shdr[i];
 
+               if (!(shdr->sh_flags & SHF_ALLOC)) {
+                       continue;
+               }
                if (shdr->sh_type != SHT_NOBITS &&
                    shdr->sh_type != SHT_PROGBITS) {
                        continue;
diff -r 31fa91d284ef -r c33c6fd1b6cc sys/lib/libsa/loadfile_elf32.c
--- a/sys/lib/libsa/loadfile_elf32.c    Mon Nov 13 21:14:03 2017 +0000
+++ b/sys/lib/libsa/loadfile_elf32.c    Mon Nov 13 21:32:21 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: loadfile_elf32.c,v 1.49 2017/11/13 20:21:10 maxv Exp $ */
+/* $NetBSD: loadfile_elf32.c,v 1.50 2017/11/13 21:32:21 maxv Exp $ */
 
 /*
  * Copyright (c) 1997, 2008, 2017 The NetBSD Foundation, Inc.
@@ -390,6 +390,10 @@
                addr = maxp;
                size = (size_t)shdr[i].sh_size;
 
+               if (!(shdr[i].sh_flags & SHF_ALLOC)) {
+                       continue;
+               }
+
                loaded = 0;
                switch (shdr[i].sh_type) {
                case SHT_NOBITS:



Home | Main Index | Thread Index | Old Index