From patchwork Sun Mar 29 08:13:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 5879 Received: (qmail 127584 invoked by alias); 29 Mar 2015 08:13:53 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 127559 invoked by uid 89); 29 Mar 2015 08:13:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: smtp.gentoo.org Received: from smtp.gentoo.org (HELO smtp.gentoo.org) (140.211.166.183) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Sun, 29 Mar 2015 08:13:48 +0000 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id E547E340BB3 for ; Sun, 29 Mar 2015 08:13:46 +0000 (UTC) From: Mike Frysinger To: gdb-patches@sourceware.org Subject: [PATCH 1/4] sim: mcore: drop sbrk support Date: Sun, 29 Mar 2015 04:13:42 -0400 Message-Id: <1427616825-27500-1-git-send-email-vapier@gentoo.org> X-IsSubscribed: yes The sbrk syscall assumes the sbrk region starts after the bss and the current implementation requires a bss section to exist. Since there is no requirement for programs to have a bss in general, we want to drop this check. However, there is still the sbrk syscall that wants to know about the region. Since libgloss doesn't actually use the sbrk syscall (it implements sbrk in its own way), and the sim really shouldn't enforce a specific memory layout on programs, lets simply delete sbrk support. Now it always returns an error. Committed. --- sim/mcore/ChangeLog | 6 ++++++ sim/mcore/interp.c | 42 +++--------------------------------------- 2 files changed, 9 insertions(+), 39 deletions(-) diff --git a/sim/mcore/ChangeLog b/sim/mcore/ChangeLog index c309a05..f6089c8 100644 --- a/sim/mcore/ChangeLog +++ b/sim/mcore/ChangeLog @@ -1,3 +1,9 @@ +2015-03-29 Mike Frysinger + + * interp.c (heap_ptr, int_sbrk): Delete. + (handle_trap1): Change case 69 (sbrk) to always return -1. + (sim_load): Delete bss checks and heap_ptr setup. + 2015-03-16 Mike Frysinger * interp.c: Strip trailing whitespace. diff --git a/sim/mcore/interp.c b/sim/mcore/interp.c index 4eb1a59..b06bd1f 100644 --- a/sim/mcore/interp.c +++ b/sim/mcore/interp.c @@ -38,7 +38,6 @@ typedef long int word; typedef unsigned long int uword; static int target_big_endian = 0; -static unsigned long heap_ptr = 0; host_callback * callback; @@ -174,21 +173,6 @@ static int issue_messages = 0; #define PARM4 5 #define RET1 2 /* register for return values. */ -static long -int_sbrk (int inc_bytes) -{ - long addr; - - addr = heap_ptr; - - heap_ptr += inc_bytes; - - if (issue_messages && heap_ptr>cpu.gr[0]) - fprintf (stderr, "Warning: heap_ptr overlaps stack!\n"); - - return addr; -} - static void wbat (word x, word v) { @@ -588,8 +572,10 @@ handle_trap1 (void) break; case 69: + /* Historically this was sbrk(), but no one used it, and the + implementation didn't actually work, so it's a stub now. */ a[0] = (unsigned long) (cpu.gr[PARM1]); - cpu.gr[RET1] = int_sbrk (a[0]); + cpu.gr[RET1] = -1; break; default: @@ -1871,7 +1857,6 @@ sim_load (SIM_DESC sd, const char *prog, bfd *abfd, int from_tty) { bfd * handle; - asection * s_bss; handle = bfd_openr (prog, 0); /* could be "mcore" */ if (!handle) @@ -1890,27 +1875,6 @@ sim_load (SIM_DESC sd, const char *prog, bfd *abfd, int from_tty) return SIM_RC_FAIL; } - /* Look for that bss section. */ - s_bss = bfd_get_section_by_name (handle, ".bss"); - - if (!s_bss) - { - printf("``%s'' has no bss section.\n", prog); - return SIM_RC_FAIL; - } - - /* Appropriately paranoid would check that we have - a traditional text/data/bss ordering within memory. */ - - /* figure the end of the bss section */ -#if 0 - printf ("bss section at 0x%08x for 0x%08x bytes\n", - (unsigned long) bfd_get_section_vma (handle, s_bss), - (unsigned long) bfd_section_size (handle, s_bss)); -#endif - heap_ptr = ((unsigned long) bfd_get_section_vma (handle, s_bss) - + (unsigned long) bfd_section_size (handle, s_bss)); - /* Clean up after ourselves. */ bfd_close (handle);