From owner-svn-src-all@FreeBSD.ORG Thu Mar 25 14:21:22 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id ACB421065680; Thu, 25 Mar 2010 14:21:22 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 817768FC18; Thu, 25 Mar 2010 14:21:22 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o2PELMTp046989; Thu, 25 Mar 2010 14:21:22 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o2PELMra046987; Thu, 25 Mar 2010 14:21:22 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201003251421.o2PELMra046987@svn.freebsd.org> From: Nathan Whitehorn Date: Thu, 25 Mar 2010 14:21:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r205641 - head/sys/kern X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Mar 2010 14:21:22 -0000 Author: nwhitehorn Date: Thu Mar 25 14:21:22 2010 New Revision: 205641 URL: http://svn.freebsd.org/changeset/base/205641 Log: Change the way text_addr and data_addr are computed to use the executable status of segments instead of detecting the main text segment by which segment contains the program entry point. This affects obreak() and is required for correct operation of that function on 64-bit PowerPC systems. The previous behavior was apparently required only for the Alpha, which is no longer supported. Reviewed by: jhb Tested on: amd64, sparc64, powerpc Modified: head/sys/kern/imgact_elf.c Modified: head/sys/kern/imgact_elf.c ============================================================================== --- head/sys/kern/imgact_elf.c Thu Mar 25 13:47:21 2010 (r205640) +++ head/sys/kern/imgact_elf.c Thu Mar 25 14:21:22 2010 (r205641) @@ -832,13 +832,8 @@ __CONCAT(exec_, __elfN(imgact))(struct i phdr[i].p_vaddr + et_dyn_addr - seg_addr); /* - * Is this .text or .data? We can't use - * VM_PROT_WRITE or VM_PROT_EXEC, it breaks the - * alpha terribly and possibly does other bad - * things so we stick to the old way of figuring - * it out: If the segment contains the program - * entry point, it's a text segment, otherwise it - * is a data segment. + * Make the largest executable segment the official + * text segment and all others data. * * Note that obreak() assumes that data_addr + * data_size == end of data load area, and the ELF @@ -846,12 +841,10 @@ __CONCAT(exec_, __elfN(imgact))(struct i * address. If multiple data segments exist, the * last one will be used. */ - if (hdr->e_entry >= phdr[i].p_vaddr && - hdr->e_entry < (phdr[i].p_vaddr + - phdr[i].p_memsz)) { + + if (phdr[i].p_flags & PF_X && text_size < seg_size) { text_size = seg_size; text_addr = seg_addr; - entry = (u_long)hdr->e_entry + et_dyn_addr; } else { data_size = seg_size; data_addr = seg_addr; @@ -871,6 +864,8 @@ __CONCAT(exec_, __elfN(imgact))(struct i data_size = text_size; } + entry = (u_long)hdr->e_entry + et_dyn_addr; + /* * Check limits. It should be safe to check the * limits after loading the segments since we do