Module Name: src Committed By: joerg Date: Tue Sep 7 21:32:03 UTC 2010
Modified Files: src/sys/kern: exec_elf.c Log Message: Remember the end of the last text segment and set up a fake data segment if size 0 and starting after the text segments, if no data segment was found. Unbreaks sbrk on platforms where all loaded segments are executable (PR 43817). The cast of executable segments after data segments is left out for now. To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/sys/kern/exec_elf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/kern/exec_elf.c diff -u src/sys/kern/exec_elf.c:1.24 src/sys/kern/exec_elf.c:1.25 --- src/sys/kern/exec_elf.c:1.24 Fri Aug 20 14:59:53 2010 +++ src/sys/kern/exec_elf.c Tue Sep 7 21:32:03 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: exec_elf.c,v 1.24 2010/08/20 14:59:53 joerg Exp $ */ +/* $NetBSD: exec_elf.c,v 1.25 2010/09/07 21:32:03 joerg Exp $ */ /*- * Copyright (c) 1994, 2000, 2005 The NetBSD Foundation, Inc. @@ -57,7 +57,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(1, "$NetBSD: exec_elf.c,v 1.24 2010/08/20 14:59:53 joerg Exp $"); +__KERNEL_RCSID(1, "$NetBSD: exec_elf.c,v 1.25 2010/09/07 21:32:03 joerg Exp $"); #ifdef _KERNEL_OPT #include "opt_pax.h" @@ -636,7 +636,7 @@ { Elf_Ehdr *eh = epp->ep_hdr; Elf_Phdr *ph, *pp; - Elf_Addr phdr = 0, pos = 0; + Elf_Addr phdr = 0, pos = 0, end_text = 0; int error, i, nload; char *interp = NULL; u_long phsize; @@ -737,9 +737,6 @@ * Consider this as text segment, if it is executable. * If there is more than one text segment, pick the * largest. - * - * If it is not executable, use the last section - * as data segment to make break() happy. */ if (ph[i].p_flags & PF_X) { if (epp->ep_taddr == ELFDEFNNAME(NO_ADDR) || @@ -747,6 +744,7 @@ epp->ep_taddr = addr; epp->ep_tsize = size; } + end_text = addr + size; } else { epp->ep_daddr = addr; epp->ep_dsize = size; @@ -775,8 +773,8 @@ } if (epp->ep_daddr == ELFDEFNNAME(NO_ADDR)) { - epp->ep_daddr = epp->ep_taddr; - epp->ep_dsize = epp->ep_tsize; + epp->ep_daddr = end_text; + epp->ep_dsize = 0; } /*