aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2006-08-06 15:49:46 +0000
committerNick Clifton <nickc@redhat.com>2006-08-06 15:49:46 +0000
commitd68c385bfc389b5ba3c1cb5684febe74990b5725 (patch)
tree84133f1200209fd123721c542193166d1f2d6be9
parentf301d54cd8e7649c6d1a4473932dcf7d3161b2c1 (diff)
downloadgdb-d68c385bfc389b5ba3c1cb5684febe74990b5725.zip
gdb-d68c385bfc389b5ba3c1cb5684febe74990b5725.tar.gz
gdb-d68c385bfc389b5ba3c1cb5684febe74990b5725.tar.bz2
PR binutils/3001
* addr2line.c (process_file): Change function from void to returning an int. Return 0 upon success, 1 otherwise. (main): Use return value from process_file as the exit value. * ar.c (ranlib_only): Change function from void to returning an int. Return 0 upon success, 1 otherwise. (ranlib_touch): Likewise. (main): Use return value from ranlib functions as exit value. * objcopy.c (add_specific_symbol): Set status to 1 if get_file_size fails. (copy_file): Likewise. (strip_main): Likewise. (copy_main): Likewise. * objdump.c (display_file): Set exit_status to 1 if get_file_size fails. * size.c (display_file): Set return_code to 1 if get_file_size fails.
-rw-r--r--binutils/ChangeLog20
-rw-r--r--binutils/addr2line.c13
-rw-r--r--binutils/ar.c28
-rw-r--r--binutils/objcopy.c20
-rw-r--r--binutils/objdump.c5
-rw-r--r--binutils/size.c7
6 files changed, 63 insertions, 30 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index efe3ed5..0db8579 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,23 @@
+2006-08-06 Nick Clifton <nickc@redhat.com>
+
+ PR binutils/3001
+ * addr2line.c (process_file): Change function from void to
+ returning an int. Return 0 upon success, 1 otherwise.
+ (main): Use return value from process_file as the exit value.
+ * ar.c (ranlib_only): Change function from void to returning an
+ int. Return 0 upon success, 1 otherwise.
+ (ranlib_touch): Likewise.
+ (main): Use return value from ranlib functions as exit value.
+ * objcopy.c (add_specific_symbol): Set status to 1 if get_file_size
+ fails.
+ (copy_file): Likewise.
+ (strip_main): Likewise.
+ (copy_main): Likewise.
+ * objdump.c (display_file): Set exit_status to 1 if get_file_size
+ fails.
+ * size.c (display_file): Set return_code to 1 if get_file_size
+ fails.
+
2006-08-02 Thiemo Seufer <ths@mips.com>
Nigel Stephens <nigel@mips.com>
diff --git a/binutils/addr2line.c b/binutils/addr2line.c
index 7cd67bc..928bf12 100644
--- a/binutils/addr2line.c
+++ b/binutils/addr2line.c
@@ -68,7 +68,6 @@ static void slurp_symtab (bfd *);
static void find_address_in_section (bfd *, asection *, void *);
static void find_offset_in_section (bfd *, asection *);
static void translate_addresses (bfd *, asection *);
-static void process_file (const char *, const char *, const char *);
/* Print a usage message to STREAM and exit with STATUS. */
@@ -261,9 +260,9 @@ translate_addresses (bfd *abfd, asection *section)
}
}
-/* Process a file. */
+/* Process a file. Returns an exit value for main(). */
-static void
+static int
process_file (const char *file_name, const char *section_name,
const char *target)
{
@@ -272,7 +271,7 @@ process_file (const char *file_name, const char *section_name,
char **matching;
if (get_file_size (file_name) < 1)
- return;
+ return 1;
abfd = bfd_openr (file_name, target);
if (abfd == NULL)
@@ -312,6 +311,8 @@ process_file (const char *file_name, const char *section_name,
}
bfd_close (abfd);
+
+ return 0;
}
int
@@ -401,7 +402,5 @@ main (int argc, char **argv)
addr = argv + optind;
naddr = argc - optind;
- process_file (file_name, section_name, target);
-
- return 0;
+ return process_file (file_name, section_name, target);
}
diff --git a/binutils/ar.c b/binutils/ar.c
index fe1c640..2431448 100644
--- a/binutils/ar.c
+++ b/binutils/ar.c
@@ -1,6 +1,6 @@
/* ar.c - Archive modify and extract.
Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
- 2001, 2002, 2003, 2004, 2005
+ 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
This file is part of GNU Binutils.
@@ -68,8 +68,8 @@ static void replace_members
(bfd *, char **files_to_replace, bfd_boolean quick);
static void print_descr (bfd * abfd);
static void write_archive (bfd *);
-static void ranlib_only (const char *archname);
-static void ranlib_touch (const char *archname);
+static int ranlib_only (const char *archname);
+static int ranlib_touch (const char *archname);
static void usage (int);
/** Globals and flags */
@@ -420,6 +420,7 @@ main (int argc, char **argv)
if (is_ranlib)
{
+ int status = 0;
bfd_boolean touch = FALSE;
if (argc < 2
@@ -440,12 +441,12 @@ main (int argc, char **argv)
while (arg_index < argc)
{
if (! touch)
- ranlib_only (argv[arg_index]);
+ status |= ranlib_only (argv[arg_index]);
else
- ranlib_touch (argv[arg_index]);
+ status |= ranlib_touch (argv[arg_index]);
++arg_index;
}
- xexit (0);
+ xexit (status);
}
if (argc == 2 && strcmp (argv[1], "-M") == 0)
@@ -597,10 +598,7 @@ main (int argc, char **argv)
if ((operation == none || operation == print_table)
&& write_armap == 1)
- {
- ranlib_only (argv[arg_index]);
- xexit (0);
- }
+ xexit (ranlib_only (argv[arg_index]));
if (operation == none)
fatal (_("no operation specified"));
@@ -1193,23 +1191,24 @@ replace_members (bfd *arch, char **files_to_move, bfd_boolean quick)
output_filename = NULL;
}
-static void
+static int
ranlib_only (const char *archname)
{
bfd *arch;
if (get_file_size (archname) < 1)
- return;
+ return 1;
write_armap = 1;
arch = open_inarch (archname, (char *) NULL);
if (arch == NULL)
xexit (1);
write_archive (arch);
+ return 0;
}
/* Update the timestamp of the symbol map of an archive. */
-static void
+static int
ranlib_touch (const char *archname)
{
#ifdef __GO32__
@@ -1221,7 +1220,7 @@ ranlib_touch (const char *archname)
char **matching;
if (get_file_size (archname) < 1)
- return;
+ return 1;
f = open (archname, O_RDWR | O_BINARY, 0);
if (f < 0)
{
@@ -1252,6 +1251,7 @@ ranlib_touch (const char *archname)
if (! bfd_close (arch))
bfd_fatal (archname);
#endif
+ return 0;
}
/* Things which are interesting to map over all or some of the files: */
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index 06e500d..0d56845 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -653,7 +653,10 @@ add_specific_symbols (const char *filename, struct symlist **list)
size = get_file_size (filename);
if (size == 0)
- return;
+ {
+ status = 1;
+ return;
+ }
buffer = xmalloc (size + 2);
f = fopen (filename, FOPEN_RT);
@@ -1889,7 +1892,6 @@ copy_file (const char *input_filename, const char *output_filename,
if (get_file_size (input_filename) < 1)
{
- non_fatal (_("error: the input file '%s' is empty"), input_filename);
status = 1;
return;
}
@@ -2612,7 +2614,10 @@ strip_main (int argc, char *argv[])
char *tmpname;
if (get_file_size (argv[i]) < 1)
- continue;
+ {
+ status = 1;
+ continue;
+ }
if (preserve_dates)
/* No need to check the return value of stat().
@@ -2623,8 +2628,8 @@ strip_main (int argc, char *argv[])
tmpname = output_file;
else
tmpname = make_tempname (argv[i]);
- status = 0;
+ status = 0;
copy_file (argv[i], tmpname, input_target, output_target);
if (status == 0)
{
@@ -2640,7 +2645,7 @@ strip_main (int argc, char *argv[])
free (tmpname);
}
- return 0;
+ return status;
}
static int
@@ -2809,7 +2814,10 @@ copy_main (int argc, char *argv[])
size = get_file_size (s + 1);
if (size < 1)
- break;
+ {
+ status = 1;
+ break;
+ }
pa = xmalloc (sizeof (struct section_add));
diff --git a/binutils/objdump.c b/binutils/objdump.c
index 6e5eab5..824cc33 100644
--- a/binutils/objdump.c
+++ b/binutils/objdump.c
@@ -2902,7 +2902,10 @@ display_file (char *filename, char *target)
bfd *arfile = NULL;
if (get_file_size (filename) < 1)
- return;
+ {
+ exit_status = 1;
+ return;
+ }
file = bfd_openr (filename, target);
if (file == NULL)
diff --git a/binutils/size.c b/binutils/size.c
index b78cba0..36a9af9 100644
--- a/binutils/size.c
+++ b/binutils/size.c
@@ -1,6 +1,6 @@
/* size.c -- report size of various sections of an executable file.
Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
- 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+ 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Binutils.
@@ -346,7 +346,10 @@ display_file (char *filename)
bfd *file;
if (get_file_size (filename) < 1)
- return;
+ {
+ return_code = 1;
+ return;
+ }
file = bfd_openr (filename, target);
if (file == NULL)