projects
/
deliverable
/
binutils-gdb.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
ubsan: moxie: left shift of negative value
[deliverable/binutils-gdb.git]
/
bfd
/
trad-core.c
diff --git
a/bfd/trad-core.c
b/bfd/trad-core.c
index defad69f4677e95c55c0aeb38a82f41e0827a25c..3c47099ced5845338f00ff6853e04366bfa68ed4 100644
(file)
--- a/
bfd/trad-core.c
+++ b/
bfd/trad-core.c
@@
-1,29
+1,28
@@
/* BFD back end for traditional Unix core files (U-area and raw sections)
/* BFD back end for traditional Unix core files (U-area and raw sections)
- Copyright 1988, 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999,
- 2000, 2001, 2002, 2003, 2004
- Free Software Foundation, Inc.
+ Copyright (C) 1988-2019 Free Software Foundation, Inc.
Written by John Gilmore of Cygnus Support.
Written by John Gilmore of Cygnus Support.
-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. */
-#include "bfd.h"
#include "sysdep.h"
#include "sysdep.h"
+#include "bfd.h"
#include "libbfd.h"
#include "libbfd.h"
-#include "libaout.h"
/* BFD a.out internal data structures */
+#include "libaout.h" /* BFD a.out internal data structures */
#include <sys/param.h>
#ifdef HAVE_DIRENT_H
#include <sys/param.h>
#ifdef HAVE_DIRENT_H
@@
-47,6
+46,10
@@
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
#include TRAD_HEADER
#endif
#include TRAD_HEADER
#endif
+#ifndef NBPG
+# define NBPG getpagesize()
+#endif
+
struct trad_core_struct
{
asection *data_section;
struct trad_core_struct
{
asection *data_section;
@@
-55,31
+58,27
@@
struct trad_core_struct
struct user u;
};
struct 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_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 */
/* forward declarations */
-const bfd_target *trad_unix_core_file_p PARAMS ((bfd *abfd));
-char * trad_unix_core_file_failing_command PARAMS ((bfd *abfd));
-int trad_unix_core_file_failing_signal PARAMS ((bfd *abfd));
-bfd_boolean trad_unix_core_file_matches_executable_p
- PARAMS ((bfd *core_bfd, bfd *exec_bfd));
-static void swap_abort PARAMS ((void));
+#define trad_unix_core_file_matches_executable_p generic_core_file_matches_executable_p
+#define trad_unix_core_file_pid _bfd_nocore_core_file_pid
-/* Handle 4.2-style (and perhaps also sysV-style) core dump file. */
-const bfd_target *
-trad_unix_core_file_p (abfd)
- bfd *abfd;
+/* Handle 4.2-style (and perhaps also sysV-style) core dump file. */
+static const bfd_target *
+trad_unix_core_file_p (bfd *abfd)
{
int val;
struct user u;
struct trad_core_struct *rawptr;
bfd_size_type amt;
{
int val;
struct user u;
struct trad_core_struct *rawptr;
bfd_size_type amt;
+ flagword flags;
#ifdef TRAD_CORE_USER_OFFSET
/* If defined, this macro is the file position of the user struct. */
#ifdef TRAD_CORE_USER_OFFSET
/* If defined, this macro is the file position of the user struct. */
@@
-109,32
+108,29
@@
trad_unix_core_file_p (abfd)
/* Check that the size claimed is no greater than the file size. */
{
/* Check that the size claimed is no greater than the file size. */
{
- FILE *stream = bfd_cache_lookup (abfd);
struct stat statbuf;
struct stat statbuf;
- if (fstat (fileno (stream), &statbuf) < 0)
- {
- bfd_set_error (bfd_error_system_call);
- return 0;
- }
- if ((unsigned long) (NBPG * (UPAGES + u.u_dsize
+ if (bfd_stat (abfd, &statbuf) < 0)
+ return 0;
+
+ if ((ufile_ptr) NBPG * (UPAGES + u.u_dsize
#ifdef TRAD_CORE_DSIZE_INCLUDES_TSIZE
#ifdef TRAD_CORE_DSIZE_INCLUDES_TSIZE
-
- u.u_tsize
+ - u.u_tsize
#endif
#endif
-
+ u.u_ssize)
)
- > (u
nsigned long
) statbuf.st_size)
+
+ u.u_ssize
)
+ > (u
file_ptr
) statbuf.st_size)
{
bfd_set_error (bfd_error_wrong_format);
return 0;
}
#ifndef TRAD_CORE_ALLOW_ANY_EXTRA_SIZE
{
bfd_set_error (bfd_error_wrong_format);
return 0;
}
#ifndef TRAD_CORE_ALLOW_ANY_EXTRA_SIZE
- if ((
unsigned long) (
NBPG * (UPAGES + u.u_dsize + u.u_ssize)
+ if ((
(ufile_ptr)
NBPG * (UPAGES + u.u_dsize + u.u_ssize)
#ifdef TRAD_CORE_EXTRA_SIZE_ALLOWED
/* Some systems write the file too big. */
#ifdef TRAD_CORE_EXTRA_SIZE_ALLOWED
/* Some systems write the file too big. */
-
+ TRAD_CORE_EXTRA_SIZE_ALLOWED
+ + TRAD_CORE_EXTRA_SIZE_ALLOWED
#endif
#endif
-
)
- < (u
nsigned long
) statbuf.st_size)
+ )
+ < (u
file_ptr
) statbuf.st_size)
{
/* The file is too big. Maybe it's not a core file
or we otherwise have bad values for u_dsize and u_ssize). */
{
/* The file is too big. Maybe it's not a core file
or we otherwise have bad values for u_dsize and u_ssize). */
@@
-159,20
+155,20
@@
trad_unix_core_file_p (abfd)
/* Create the sections. */
/* 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;
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;
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;
if (core_regsec (abfd) == NULL)
goto fail;
- 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 = NBPG * u.u_dsize
#ifdef TRAD_CORE_DSIZE_INCLUDES_TSIZE
- NBPG * u.u_tsize
core_datasec (abfd)->size = NBPG * u.u_dsize
#ifdef TRAD_CORE_DSIZE_INCLUDES_TSIZE
- NBPG * u.u_tsize
@@
-233,9
+229,8
@@
trad_unix_core_file_p (abfd)
return NULL;
}
return NULL;
}
-char *
-trad_unix_core_file_failing_command (abfd)
- bfd *abfd;
+static char *
+trad_unix_core_file_failing_command (bfd *abfd)
{
#ifndef NO_CORE_COMMAND
char *com = abfd->tdata.trad_core_data->u.u_comm;
{
#ifndef NO_CORE_COMMAND
char *com = abfd->tdata.trad_core_data->u.u_comm;
@@
-246,9
+241,8
@@
trad_unix_core_file_failing_command (abfd)
return 0;
}
return 0;
}
-int
-trad_unix_core_file_failing_signal (ignore_abfd)
- bfd *ignore_abfd ATTRIBUTE_UNUSED;
+static int
+trad_unix_core_file_failing_signal (bfd *ignore_abfd ATTRIBUTE_UNUSED)
{
#ifdef TRAD_UNIX_CORE_FILE_FAILING_SIGNAL
return TRAD_UNIX_CORE_FILE_FAILING_SIGNAL(ignore_abfd);
{
#ifdef TRAD_UNIX_CORE_FILE_FAILING_SIGNAL
return TRAD_UNIX_CORE_FILE_FAILING_SIGNAL(ignore_abfd);
@@
-256,18
+250,10
@@
trad_unix_core_file_failing_signal (ignore_abfd)
return -1; /* FIXME, where is it? */
#endif
}
return -1; /* FIXME, where is it? */
#endif
}
-
-bfd_boolean
-trad_unix_core_file_matches_executable_p (core_bfd, exec_bfd)
- bfd *core_bfd ATTRIBUTE_UNUSED;
- bfd *exec_bfd ATTRIBUTE_UNUSED;
-{
- return TRUE; /* FIXME, We have no way of telling at this point */
-}
\f
/* If somebody calls any byte-swapping routines, shoot them. */
static void
\f
/* 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 */
}
{
abort (); /* This way doesn't require any declaration for ANSI to fuck up */
}
@@
-279,7
+265,7
@@
swap_abort ()
#define NO_PUT64 ((void (*) (bfd_uint64_t, void *)) swap_abort)
#define NO_GETS64 ((bfd_int64_t (*) (const void *)) 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
trad_core
_vec =
+const bfd_target
core_trad
_vec =
{
"trad-core",
bfd_target_unknown_flavour,
{
"trad-core",
bfd_target_unknown_flavour,
@@
-289,9
+275,10
@@
const bfd_target trad_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 */
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 */
- ' ', /* ar_pad_char */
- 16, /* ar_max_namelen */
+ 0, /* symbol prefix */
+ ' ', /* ar_pad_char */
+ 16, /* ar_max_namelen */
+ 0, /* match priority. */
NO_GET64, NO_GETS64, NO_PUT64, /* 64 bit data */
NO_GET, NO_GETS, NO_PUT, /* 32 bit data */
NO_GET, NO_GETS, NO_PUT, /* 16 bit data */
NO_GET64, NO_GETS64, NO_PUT64, /* 64 bit data */
NO_GET, NO_GETS, NO_PUT, /* 32 bit data */
NO_GET, NO_GETS, NO_PUT, /* 16 bit data */
@@
-306,12
+293,16
@@
const bfd_target trad_core_vec =
trad_unix_core_file_p /* a core file */
},
{ /* bfd_set_format */
trad_unix_core_file_p /* a core file */
},
{ /* bfd_set_format */
- bfd_false, bfd_false,
- bfd_false, bfd_false
+ _bfd_bool_bfd_false_error,
+ _bfd_bool_bfd_false_error,
+ _bfd_bool_bfd_false_error,
+ _bfd_bool_bfd_false_error
},
{ /* bfd_write_contents */
},
{ /* bfd_write_contents */
- bfd_false, bfd_false,
- bfd_false, bfd_false
+ _bfd_bool_bfd_false_error,
+ _bfd_bool_bfd_false_error,
+ _bfd_bool_bfd_false_error,
+ _bfd_bool_bfd_false_error
},
BFD_JUMP_TABLE_GENERIC (_bfd_generic),
},
BFD_JUMP_TABLE_GENERIC (_bfd_generic),
@@
-326,5
+317,5
@@
const bfd_target trad_core_vec =
NULL,
NULL,
-
(PTR) 0
/* backend_data */
+
NULL
/* backend_data */
};
};
This page took
0.028527 seconds
and
4
git commands to generate.