X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=bfd%2Fptrace-core.c;h=e9802f8ea062b07a9d7385c15a98e26a386f5747;hb=refs%2Fheads%2Fconcurrent-displaced-stepping-2020-04-01;hp=4ac28aa1dece59ff7f0a2632d6902f71b3211b78;hpb=69d246d9338a35e64b2244835ac6e77164be668a;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/ptrace-core.c b/bfd/ptrace-core.c index 4ac28aa1de..e9802f8ea0 100644 --- a/bfd/ptrace-core.c +++ b/bfd/ptrace-core.c @@ -1,31 +1,31 @@ /* BFD backend for core files which use the ptrace_user structure - Copyright 1993, 1994, 1995, 1996, 1998, 1999, 2001, 2002, 2003, 2004 - Free Software Foundation, Inc. + Copyright (C) 1993-2020 Free Software Foundation, Inc. The structure of this file is based on trad-core.c written by John Gilmore of Cygnus Support. Modified to work with the ptrace_user structure by Kevin A. Buettner. (Longterm it may be better to merge this file with trad-core.c) -This file is part of BFD, the Binary File Descriptor library. + This file is part of BFD, the Binary File Descriptor library. -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 2 of the License, or -(at your option) any later version. + 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. + 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, write to the Free Software -Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, + MA 02110-1301, USA. */ #ifdef PTRACE_CORE -#include "bfd.h" #include "sysdep.h" +#include "bfd.h" #include "libbfd.h" #include @@ -34,35 +34,35 @@ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. #include struct trad_core_struct - { - asection *data_section; - asection *stack_section; - asection *reg_section; - struct ptrace_user u; - }; +{ + asection *data_section; + asection *stack_section; + asection *reg_section; + struct ptrace_user u; +}; -#define core_upage(bfd) (&((bfd)->tdata.trad_core_data->u)) -#define core_datasec(bfd) ((bfd)->tdata.trad_core_data->data_section) +#define core_upage(bfd) (&((bfd)->tdata.trad_core_data->u)) +#define core_datasec(bfd) ((bfd)->tdata.trad_core_data->data_section) #define core_stacksec(bfd) ((bfd)->tdata.trad_core_data->stack_section) -#define core_regsec(bfd) ((bfd)->tdata.trad_core_data->reg_section) +#define core_regsec(bfd) ((bfd)->tdata.trad_core_data->reg_section) /* forward declarations */ -const bfd_target *ptrace_unix_core_file_p PARAMS ((bfd *abfd)); -char * ptrace_unix_core_file_failing_command PARAMS ((bfd *abfd)); -int ptrace_unix_core_file_failing_signal PARAMS ((bfd *abfd)); +const bfd_target *ptrace_unix_core_file_p (bfd *abfd); +char * ptrace_unix_core_file_failing_command (bfd *abfd); +int ptrace_unix_core_file_failing_signal (bfd *abfd); #define ptrace_unix_core_file_matches_executable_p generic_core_file_matches_executable_p -static void swap_abort PARAMS ((void)); - -const bfd_target * -ptrace_unix_core_file_p (abfd) - bfd *abfd; +#define ptrace_unix_core_file_pid _bfd_nocore_core_file_pid +static void swap_abort (void); +bfd_cleanup +ptrace_unix_core_file_p (bfd *abfd) { int val; struct ptrace_user u; struct trad_core_struct *rawptr; - bfd_size_type amt; + size_t amt; + flagword flags; val = bfd_bread ((void *)&u, (bfd_size_type) sizeof u, abfd); if (val != sizeof u || u.pt_magic != _BCS_PTRACE_MAGIC @@ -89,13 +89,17 @@ ptrace_unix_core_file_p (abfd) /* Create the sections. */ - core_stacksec (abfd) = bfd_make_section_anyway (abfd, ".stack"); + flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS; + core_stacksec (abfd) = bfd_make_section_anyway_with_flags (abfd, ".stack", + flags); if (core_stacksec (abfd) == NULL) goto fail; - core_datasec (abfd) = bfd_make_section_anyway (abfd, ".data"); + core_datasec (abfd) = bfd_make_section_anyway_with_flags (abfd, ".data", + flags); if (core_datasec (abfd) == NULL) goto fail; - core_regsec (abfd) = bfd_make_section_anyway (abfd, ".reg"); + core_regsec (abfd) = bfd_make_section_anyway_with_flags (abfd, ".reg", + SEC_HAS_CONTENTS); if (core_regsec (abfd) == NULL) goto fail; @@ -103,10 +107,6 @@ ptrace_unix_core_file_p (abfd) text. I don't think that any of these things are supported on the system on which I am developing this for though. */ - core_stacksec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS; - core_datasec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS; - core_regsec (abfd)->flags = SEC_HAS_CONTENTS; - core_datasec (abfd)->size = u.pt_dsize; core_stacksec (abfd)->size = u.pt_ssize; core_regsec (abfd)->size = sizeof (u); @@ -124,7 +124,7 @@ ptrace_unix_core_file_p (abfd) core_datasec (abfd)->alignment_power = 2; core_regsec (abfd)->alignment_power = 2; - return abfd->xvec; + return _bfd_no_cleanup; fail: bfd_release (abfd, abfd->tdata.any); @@ -134,10 +134,10 @@ ptrace_unix_core_file_p (abfd) } char * -ptrace_unix_core_file_failing_command (abfd) - bfd *abfd; +ptrace_unix_core_file_failing_command (bfd *abfd) { char *com = abfd->tdata.trad_core_data->u.pt_comm; + if (*com) return com; else @@ -145,15 +145,14 @@ ptrace_unix_core_file_failing_command (abfd) } int -ptrace_unix_core_file_failing_signal (abfd) - bfd *abfd; +ptrace_unix_core_file_failing_signal (bfd *abfd) { return abfd->tdata.trad_core_data->u.pt_sigframe.sig_num; } /* If somebody calls any byte-swapping routines, shoot them. */ static void -swap_abort () +swap_abort (void) { abort (); /* This way doesn't require any declaration for ANSI to fuck up */ } @@ -165,7 +164,7 @@ swap_abort () #define NO_PUT64 ((void (*) (bfd_uint64_t, void *)) swap_abort) #define NO_GETS64 ((bfd_int64_t (*) (const void *)) swap_abort) -const bfd_target ptrace_core_vec = +const bfd_target core_ptrace_vec = { "trad-core", bfd_target_unknown_flavour, @@ -175,7 +174,7 @@ const bfd_target ptrace_core_vec = HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED), (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ - 0, /* symbol prefix */ + 0, /* symbol prefix */ ' ', /* ar_pad_char */ 16, /* ar_max_namelen */ NO_GET64, NO_GETS64, NO_PUT64, /* 64 bit data */ @@ -192,12 +191,12 @@ const bfd_target ptrace_core_vec = ptrace_unix_core_file_p /* a core file */ }, { /* bfd_set_format */ - bfd_false, bfd_false, - bfd_false, bfd_false + _bfd_bool_bfd_false_error, bfd_false, + _bfd_bool_bfd_false_error, bfd_false }, { /* bfd_write_contents */ - bfd_false, bfd_false, - bfd_false, bfd_false + _bfd_bool_bfd_false_error, bfd_false, + _bfd_bool_bfd_false_error, bfd_false }, BFD_JUMP_TABLE_GENERIC (_bfd_generic), @@ -212,7 +211,7 @@ const bfd_target ptrace_core_vec = NULL, - (PTR) 0 /* backend_data */ + NULL /* backend_data */ }; #endif /* PTRACE_CORE */