From patchwork Fri Oct 7 12:37:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Kolesov X-Patchwork-Id: 16342 Received: (qmail 129954 invoked by alias); 7 Oct 2016 12:38:13 -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 129874 invoked by uid 89); 7 Oct 2016 12:38:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=libgloss X-HELO: smtprelay.synopsys.com Received: from smtprelay.synopsys.com (HELO smtprelay.synopsys.com) (198.182.47.9) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 07 Oct 2016 12:38:09 +0000 Received: from dc8secmta1.synopsys.com (dc8secmta1.synopsys.com [10.13.218.200]) by smtprelay.synopsys.com (Postfix) with ESMTP id 26FE124E20A3 for ; Fri, 7 Oct 2016 05:38:08 -0700 (PDT) Received: from dc8secmta1.internal.synopsys.com (dc8secmta1.internal.synopsys.com [127.0.0.1]) by dc8secmta1.internal.synopsys.com (Service) with ESMTP id 1A95827113 for ; Fri, 7 Oct 2016 05:38:08 -0700 (PDT) Received: from mailhost.synopsys.com (mailhost3.synopsys.com [10.12.238.238]) by dc8secmta1.internal.synopsys.com (Service) with ESMTP id D958A27102 for ; Fri, 7 Oct 2016 05:38:07 -0700 (PDT) Received: from mailhost.synopsys.com (localhost [127.0.0.1]) by mailhost.synopsys.com (Postfix) with ESMTP id C29A1294; Fri, 7 Oct 2016 05:38:07 -0700 (PDT) Received: from akolesov-lab.internal.synopsys.com (akolesov-lab.internal.synopsys.com [10.121.8.134]) by mailhost.synopsys.com (Postfix) with ESMTP id C964728C; Fri, 7 Oct 2016 05:38:06 -0700 (PDT) From: Anton Kolesov To: gdb-patches@sourceware.org Cc: Anton Kolesov , Francois Bedard Subject: [PATCH 3/3] arc: Add support for Newlib Date: Fri, 7 Oct 2016 15:37:50 +0300 Message-Id: <1475843870-11449-3-git-send-email-Anton.Kolesov@synopsys.com> In-Reply-To: <1475843870-11449-1-git-send-email-Anton.Kolesov@synopsys.com> References: <1475843870-11449-1-git-send-email-Anton.Kolesov@synopsys.com> Add support for Newlib as an OS/ABI. The only thing that is specific to it relatively to "generic" baremetal target is location of PC register in jump buffer for longjump support. Sniffer uses .ivt section to decide if ELF file is for ARC Newlib or not. gdb/ChangeLog: * arc-newlib-tdep.c: New file. * configure.tgt: Add newlib support for ARC. --- gdb/arc-newlib-tdep.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++ gdb/configure.tgt | 7 +++++- 2 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 gdb/arc-newlib-tdep.c diff --git a/gdb/arc-newlib-tdep.c b/gdb/arc-newlib-tdep.c new file mode 100644 index 0000000..d93bf85 --- /dev/null +++ b/gdb/arc-newlib-tdep.c @@ -0,0 +1,69 @@ +/* Target-dependent code for Newlib ARC. + + Copyright (C) 2016 Free Software Foundation, Inc. + Contributed by Synopsys Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include "defs.h" + +#include "gdbarch.h" +#include "arc-tdep.h" +#include "osabi.h" + +/* Implement the 'init_osabi' method of struct gdb_osabi_handler. */ + +static void +arc_newlib_init_osabi (struct gdbarch_info info, struct gdbarch *gdbarch) +{ + if (arc_debug) + debug_printf ("arc-newlib: Initialization.\n"); + + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + + /* Offset of original PC in longjmp jump buffer (in registers). Value of PC + offset can be found in newlib/libc/machine/arc/setjmp.S. */ + tdep->jb_pc = 18; +} + +/* Recognize ARC Newlib object files. */ + +static enum gdb_osabi +arc_newlib_osabi_sniffer (bfd *abfd) +{ + if (arc_debug) + debug_printf ("arc-newlib: OS/ABI sniffer.\n"); + + /* crt0.S in libgloss for ARC defines .ivt section for interrupt handlers. + If this section is not present then this is likely not a newlib - could be + a Linux application or some non-newlib baremetal application. */ + if (bfd_get_section_by_name (abfd, ".ivt") != NULL) + return GDB_OSABI_NEWLIB; + else + return GDB_OSABI_UNKNOWN; +} + +/* Provide a prototype to silence -Wmissing-prototypes. */ +extern initialize_file_ftype _initialize_arc_newlib_tdep; + +void +_initialize_arc_newlib_tdep (void) +{ + gdbarch_register_osabi_sniffer (bfd_arch_arc, bfd_target_elf_flavour, + arc_newlib_osabi_sniffer); + gdbarch_register_osabi (bfd_arch_arc, 0, GDB_OSABI_NEWLIB, + arc_newlib_init_osabi); +} diff --git a/gdb/configure.tgt b/gdb/configure.tgt index ef041de..a64fe42 100644 --- a/gdb/configure.tgt +++ b/gdb/configure.tgt @@ -83,8 +83,13 @@ am33_2.0*-*-linux*) solib-svr4.o" ;; +arc*-*-elf32) + # Target: baremetal ARC elf32 (newlib) target + gdb_target_obs="arc-newlib-tdep.o arc-tdep.o" + ;; + arc*-*-*) - # Target: baremetal ARC elf32 target + # Target: Unidentified ARC target gdb_target_obs="arc-tdep.o" ;;