* objcopy.c: Remove unnecessary prototypes and casts.

* objdump.c: Remove unnecessary casts.
	* readelf.c: Convert to C90.  Remove unnecessary prototypes and casts.
	(get_osabi_name): Move so we don't need a forward declaration.
This commit is contained in:
Alan Modra
2003-08-05 14:40:54 +00:00
parent 3d3d3d639b
commit d3ba05513b
4 changed files with 440 additions and 945 deletions

View File

@ -1,3 +1,10 @@
2003-08-05 Alan Modra <amodra@bigpond.net.au>
* objcopy.c: Remove unnecessary prototypes and casts.
* objdump.c: Remove unnecessary casts.
* readelf.c: Convert to C90. Remove unnecessary prototypes and casts.
(get_osabi_name): Move so we don't need a forward declaration.
2003-08-04 Bradley Harrington <bharring@us.ibm.com> 2003-08-04 Bradley Harrington <bharring@us.ibm.com>
Alan Modra <amodra@bigpond.net.au> Alan Modra <amodra@bigpond.net.au>

View File

@ -60,59 +60,6 @@ section_rename;
/* List of sections to be renamed. */ /* List of sections to be renamed. */
static section_rename *section_rename_list; static section_rename *section_rename_list;
static void copy_usage
(FILE *, int);
static void strip_usage
(FILE *, int);
static flagword parse_flags
(const char *);
static struct section_list *find_section_list
(const char *, bfd_boolean);
static void setup_section
(bfd *, asection *, void *);
static void copy_section
(bfd *, asection *, void *);
static void get_sections
(bfd *, asection *, void *);
static int compare_section_lma
(const void *, const void *);
static void add_specific_symbol
(const char *, struct symlist **);
static void add_specific_symbols
(const char *, struct symlist **);
static bfd_boolean is_specified_symbol
(const char *, struct symlist *);
static bfd_boolean is_strip_section
(bfd *, asection *);
static unsigned int filter_symbols
(bfd *, bfd *, asymbol **, asymbol **, long);
static void mark_symbols_used_in_relocations
(bfd *, asection *, void *);
static void filter_bytes
(char *, bfd_size_type *);
static bfd_boolean write_debugging_info
(bfd *, void *, long *, asymbol ***);
static void copy_object
(bfd *, bfd *);
static void copy_archive
(bfd *, bfd *, const char *);
static void copy_file
(const char *, const char *, const char *, const char *);
static int strip_main
(int, char **);
static int copy_main
(int, char **);
static const char *lookup_sym_redefinition
(const char *);
static void redefine_list_append
(const char *, const char *, const char *);
static const char * find_section_rename
(bfd *, sec_ptr, flagword *);
static void add_section_rename
(const char *, const char *, flagword);
static void add_redefine_syms_file
(const char *);
#define RETURN_NONFATAL(s) {bfd_nonfatal (s); status = 1; return;} #define RETURN_NONFATAL(s) {bfd_nonfatal (s); status = 1; return;}
static asymbol **isympp = NULL; /* Input symbols. */ static asymbol **isympp = NULL; /* Input symbols. */
@ -407,6 +354,14 @@ extern bfd_boolean S3Forced;
/* Defined in bfd/binary.c. Used to set architecture of input binary files. */ /* Defined in bfd/binary.c. Used to set architecture of input binary files. */
extern enum bfd_architecture bfd_external_binary_architecture; extern enum bfd_architecture bfd_external_binary_architecture;
/* Forward declarations. */
static void setup_section (bfd *, asection *, void *);
static void copy_section (bfd *, asection *, void *);
static void get_sections (bfd *, asection *, void *);
static int compare_section_lma (const void *, const void *);
static void mark_symbols_used_in_relocations (bfd *, asection *, void *);
static bfd_boolean write_debugging_info (bfd *, void *, long *, asymbol ***);
static const char *lookup_sym_redefinition (const char *);
static void static void
copy_usage (FILE *stream, int exit_status) copy_usage (FILE *stream, int exit_status)
@ -587,7 +542,7 @@ find_section_list (const char *name, bfd_boolean add)
if (! add) if (! add)
return NULL; return NULL;
p = (struct section_list *) xmalloc (sizeof (struct section_list)); p = xmalloc (sizeof (struct section_list));
p->name = name; p->name = name;
p->used = FALSE; p->used = FALSE;
p->remove = FALSE; p->remove = FALSE;
@ -612,7 +567,7 @@ add_specific_symbol (const char *name, struct symlist **list)
{ {
struct symlist *tmp_list; struct symlist *tmp_list;
tmp_list = (struct symlist *) xmalloc (sizeof (struct symlist)); tmp_list = xmalloc (sizeof (struct symlist));
tmp_list->name = name; tmp_list->name = name;
tmp_list->next = *list; tmp_list->next = *list;
*list = tmp_list; *list = tmp_list;
@ -637,7 +592,7 @@ add_specific_symbols (const char *filename, struct symlist **list)
if (st.st_size == 0) if (st.st_size == 0)
return; return;
buffer = (char *) xmalloc (st.st_size + 2); buffer = xmalloc (st.st_size + 2);
f = fopen (filename, FOPEN_RT); f = fopen (filename, FOPEN_RT);
if (f == NULL) if (f == NULL)
fatal (_("cannot open: %s: %s"), filename, strerror (errno)); fatal (_("cannot open: %s: %s"), filename, strerror (errno));
@ -965,7 +920,7 @@ redefine_list_append (const char *cause, const char *source, const char *target)
cause, target); cause, target);
} }
new_node = (struct redefine_node *) xmalloc (sizeof (struct redefine_node)); new_node = xmalloc (sizeof (struct redefine_node));
new_node->source = strdup (source); new_node->source = strdup (source);
new_node->target = strdup (target); new_node->target = strdup (target);
@ -988,12 +943,12 @@ add_redefine_syms_file (const char *filename)
int c, lineno; int c, lineno;
file = fopen (filename, "r"); file = fopen (filename, "r");
if (file == (FILE *) NULL) if (file == NULL)
fatal (_("couldn't open symbol redefinition file %s (error: %s)"), fatal (_("couldn't open symbol redefinition file %s (error: %s)"),
filename, strerror (errno)); filename, strerror (errno));
bufsize = 100; bufsize = 100;
buf = (char *) xmalloc (bufsize); buf = xmalloc (bufsize);
lineno = 1; lineno = 1;
c = getc (file); c = getc (file);
@ -1172,7 +1127,7 @@ copy_object (bfd *ibfd, bfd *obfd)
/* BFD mandates that all output sections be created and sizes set before /* BFD mandates that all output sections be created and sizes set before
any output is done. Thus, we traverse all sections multiple times. */ any output is done. Thus, we traverse all sections multiple times. */
bfd_map_over_sections (ibfd, setup_section, (void *) obfd); bfd_map_over_sections (ibfd, setup_section, obfd);
if (add_sections != NULL) if (add_sections != NULL)
{ {
@ -1248,13 +1203,13 @@ copy_object (bfd *ibfd, bfd *obfd)
We write out the gap contents below. */ We write out the gap contents below. */
c = bfd_count_sections (obfd); c = bfd_count_sections (obfd);
osections = (asection **) xmalloc (c * sizeof (asection *)); osections = xmalloc (c * sizeof (asection *));
set = osections; set = osections;
bfd_map_over_sections (obfd, get_sections, (void *) &set); bfd_map_over_sections (obfd, get_sections, &set);
qsort (osections, c, sizeof (asection *), compare_section_lma); qsort (osections, c, sizeof (asection *), compare_section_lma);
gaps = (bfd_size_type *) xmalloc (c * sizeof (bfd_size_type)); gaps = xmalloc (c * sizeof (bfd_size_type));
memset (gaps, 0, c * sizeof (bfd_size_type)); memset (gaps, 0, c * sizeof (bfd_size_type));
if (gap_fill_set) if (gap_fill_set)
@ -1325,7 +1280,7 @@ copy_object (bfd *ibfd, bfd *obfd)
if (symsize < 0) if (symsize < 0)
RETURN_NONFATAL (bfd_get_filename (ibfd)); RETURN_NONFATAL (bfd_get_filename (ibfd));
osympp = isympp = (asymbol **) xmalloc (symsize); osympp = isympp = xmalloc (symsize);
symcount = bfd_canonicalize_symtab (ibfd, isympp); symcount = bfd_canonicalize_symtab (ibfd, isympp);
if (symcount < 0) if (symcount < 0)
RETURN_NONFATAL (bfd_get_filename (ibfd)); RETURN_NONFATAL (bfd_get_filename (ibfd));
@ -1363,8 +1318,8 @@ copy_object (bfd *ibfd, bfd *obfd)
if (strip_symbols != STRIP_ALL) if (strip_symbols != STRIP_ALL)
bfd_map_over_sections (ibfd, bfd_map_over_sections (ibfd,
mark_symbols_used_in_relocations, mark_symbols_used_in_relocations,
(void *) isympp); isympp);
osympp = (asymbol **) xmalloc ((symcount + 1) * sizeof (asymbol *)); osympp = xmalloc ((symcount + 1) * sizeof (asymbol *));
symcount = filter_symbols (ibfd, obfd, osympp, isympp, symcount); symcount = filter_symbols (ibfd, obfd, osympp, isympp, symcount);
} }
@ -1380,7 +1335,7 @@ copy_object (bfd *ibfd, bfd *obfd)
bfd_set_symtab (obfd, osympp, symcount); bfd_set_symtab (obfd, osympp, symcount);
/* This has to happen after the symbol table has been set. */ /* This has to happen after the symbol table has been set. */
bfd_map_over_sections (ibfd, copy_section, (void *) obfd); bfd_map_over_sections (ibfd, copy_section, obfd);
if (add_sections != NULL) if (add_sections != NULL)
{ {
@ -1388,10 +1343,8 @@ copy_object (bfd *ibfd, bfd *obfd)
for (padd = add_sections; padd != NULL; padd = padd->next) for (padd = add_sections; padd != NULL; padd = padd->next)
{ {
if (! bfd_set_section_contents (obfd, padd->section, if (! bfd_set_section_contents (obfd, padd->section, padd->contents,
(void *) padd->contents, 0, padd->size))
(file_ptr) 0,
(bfd_size_type) padd->size))
RETURN_NONFATAL (bfd_get_filename (obfd)); RETURN_NONFATAL (bfd_get_filename (obfd));
} }
} }
@ -1411,8 +1364,8 @@ copy_object (bfd *ibfd, bfd *obfd)
/* Fill in the gaps. */ /* Fill in the gaps. */
if (max_gap > 8192) if (max_gap > 8192)
max_gap = 8192; max_gap = 8192;
buf = (bfd_byte *) xmalloc (max_gap); buf = xmalloc (max_gap);
memset (buf, gap_fill, (size_t) max_gap); memset (buf, gap_fill, max_gap);
c = bfd_count_sections (obfd); c = bfd_count_sections (obfd);
for (i = 0; i < c; i++) for (i = 0; i < c; i++)
@ -1510,7 +1463,7 @@ copy_archive (bfd *ibfd, bfd *obfd, const char *output_target)
if (!bfd_set_format (obfd, bfd_get_format (ibfd))) if (!bfd_set_format (obfd, bfd_get_format (ibfd)))
RETURN_NONFATAL (bfd_get_filename (obfd)); RETURN_NONFATAL (bfd_get_filename (obfd));
while (!status && this_element != (bfd *) NULL) while (!status && this_element != NULL)
{ {
char *output_name; char *output_name;
bfd *output_bfd; bfd *output_bfd;
@ -1530,7 +1483,7 @@ copy_archive (bfd *ibfd, bfd *obfd, const char *output_target)
fatal (_("cannot mkdir %s for archive copying (error: %s)"), fatal (_("cannot mkdir %s for archive copying (error: %s)"),
output_name, strerror (errno)); output_name, strerror (errno));
l = (struct name_list *) xmalloc (sizeof (struct name_list)); l = xmalloc (sizeof (struct name_list));
l->name = output_name; l->name = output_name;
l->next = list; l->next = list;
l->obfd = NULL; l->obfd = NULL;
@ -1549,12 +1502,12 @@ copy_archive (bfd *ibfd, bfd *obfd, const char *output_target)
bfd_get_filename (this_element)); bfd_get_filename (this_element));
} }
l = (struct name_list *) xmalloc (sizeof (struct name_list)); l = xmalloc (sizeof (struct name_list));
l->name = output_name; l->name = output_name;
l->next = list; l->next = list;
list = l; list = l;
if (output_bfd == (bfd *) NULL) if (output_bfd == NULL)
RETURN_NONFATAL (output_name); RETURN_NONFATAL (output_name);
if (bfd_check_format (this_element, bfd_object)) if (bfd_check_format (this_element, bfd_object))
@ -1584,7 +1537,7 @@ copy_archive (bfd *ibfd, bfd *obfd, const char *output_target)
bfd_close (last_element); bfd_close (last_element);
} }
*ptr = (bfd *) NULL; *ptr = NULL;
if (!bfd_close (obfd)) if (!bfd_close (obfd))
RETURN_NONFATAL (bfd_get_filename (obfd)); RETURN_NONFATAL (bfd_get_filename (obfd));
@ -1713,7 +1666,7 @@ add_section_rename (const char * old_name, const char * new_name,
fatal (_("Multiple renames of section %s"), old_name); fatal (_("Multiple renames of section %s"), old_name);
} }
rename = (section_rename *) xmalloc (sizeof (* rename)); rename = xmalloc (sizeof (* rename));
rename->old_name = old_name; rename->old_name = old_name;
rename->new_name = new_name; rename->new_name = new_name;
@ -1755,7 +1708,7 @@ find_section_rename (bfd * ibfd ATTRIBUTE_UNUSED, sec_ptr isection,
static void static void
setup_section (bfd *ibfd, sec_ptr isection, void *obfdarg) setup_section (bfd *ibfd, sec_ptr isection, void *obfdarg)
{ {
bfd *obfd = (bfd *) obfdarg; bfd *obfd = obfdarg;
struct section_list *p; struct section_list *p;
sec_ptr osection; sec_ptr osection;
bfd_size_type size; bfd_size_type size;
@ -1897,7 +1850,7 @@ loser:
static void static void
copy_section (bfd *ibfd, sec_ptr isection, void *obfdarg) copy_section (bfd *ibfd, sec_ptr isection, void *obfdarg)
{ {
bfd *obfd = (bfd *) obfdarg; bfd *obfd = obfdarg;
struct section_list *p; struct section_list *p;
arelent **relpp; arelent **relpp;
long relcount; long relcount;
@ -1936,10 +1889,10 @@ copy_section (bfd *ibfd, sec_ptr isection, void *obfdarg)
RETURN_NONFATAL (bfd_get_filename (ibfd)); RETURN_NONFATAL (bfd_get_filename (ibfd));
if (relsize == 0) if (relsize == 0)
bfd_set_reloc (obfd, osection, (arelent **) NULL, 0); bfd_set_reloc (obfd, osection, NULL, 0);
else else
{ {
relpp = (arelent **) xmalloc (relsize); relpp = xmalloc (relsize);
relcount = bfd_canonicalize_reloc (ibfd, isection, relpp, isympp); relcount = bfd_canonicalize_reloc (ibfd, isection, relpp, isympp);
if (relcount < 0) if (relcount < 0)
RETURN_NONFATAL (bfd_get_filename (ibfd)); RETURN_NONFATAL (bfd_get_filename (ibfd));
@ -1952,19 +1905,17 @@ copy_section (bfd *ibfd, sec_ptr isection, void *obfdarg)
long temp_relcount = 0; long temp_relcount = 0;
long i; long i;
temp_relpp = (arelent **) xmalloc (relsize); temp_relpp = xmalloc (relsize);
for (i = 0; i < relcount; i++) for (i = 0; i < relcount; i++)
if (is_specified_symbol if (is_specified_symbol (bfd_asymbol_name (*relpp[i]->sym_ptr_ptr),
(bfd_asymbol_name (*relpp [i]->sym_ptr_ptr), keep_specific_list))
keep_specific_list))
temp_relpp [temp_relcount++] = relpp [i]; temp_relpp [temp_relcount++] = relpp [i];
relcount = temp_relcount; relcount = temp_relcount;
free (relpp); free (relpp);
relpp = temp_relpp; relpp = temp_relpp;
} }
bfd_set_reloc (obfd, osection, bfd_set_reloc (obfd, osection, relcount == 0 ? NULL : relpp, relcount);
(relcount == 0 ? (arelent **) NULL : relpp), relcount);
} }
isection->_cooked_size = isection->_raw_size; isection->_cooked_size = isection->_raw_size;
@ -1973,24 +1924,22 @@ copy_section (bfd *ibfd, sec_ptr isection, void *obfdarg)
if (bfd_get_section_flags (ibfd, isection) & SEC_HAS_CONTENTS if (bfd_get_section_flags (ibfd, isection) & SEC_HAS_CONTENTS
&& bfd_get_section_flags (obfd, osection) & SEC_HAS_CONTENTS) && bfd_get_section_flags (obfd, osection) & SEC_HAS_CONTENTS)
{ {
void *memhunk = (void *) xmalloc ((unsigned) size); void *memhunk = xmalloc (size);
if (!bfd_get_section_contents (ibfd, isection, memhunk, (file_ptr) 0, if (!bfd_get_section_contents (ibfd, isection, memhunk, 0, size))
size))
RETURN_NONFATAL (bfd_get_filename (ibfd)); RETURN_NONFATAL (bfd_get_filename (ibfd));
if (copy_byte >= 0) if (copy_byte >= 0)
filter_bytes (memhunk, &size); filter_bytes (memhunk, &size);
if (!bfd_set_section_contents (obfd, osection, memhunk, (file_ptr) 0, if (!bfd_set_section_contents (obfd, osection, memhunk, 0, size))
size))
RETURN_NONFATAL (bfd_get_filename (obfd)); RETURN_NONFATAL (bfd_get_filename (obfd));
free (memhunk); free (memhunk);
} }
else if (p != NULL && p->set_flags && (p->flags & SEC_HAS_CONTENTS) != 0) else if (p != NULL && p->set_flags && (p->flags & SEC_HAS_CONTENTS) != 0)
{ {
void * memhunk = (void *) xmalloc ((unsigned) size); void *memhunk = xmalloc (size);
/* We don't permit the user to turn off the SEC_HAS_CONTENTS /* We don't permit the user to turn off the SEC_HAS_CONTENTS
flag--they can just remove the section entirely and add it flag--they can just remove the section entirely and add it
@ -1999,8 +1948,7 @@ copy_section (bfd *ibfd, sec_ptr isection, void *obfdarg)
contents should be zeroed out. */ contents should be zeroed out. */
memset (memhunk, 0, size); memset (memhunk, 0, size);
if (! bfd_set_section_contents (obfd, osection, memhunk, (file_ptr) 0, if (! bfd_set_section_contents (obfd, osection, memhunk, 0, size))
size))
RETURN_NONFATAL (bfd_get_filename (obfd)); RETURN_NONFATAL (bfd_get_filename (obfd));
free (memhunk); free (memhunk);
} }
@ -2012,7 +1960,7 @@ copy_section (bfd *ibfd, sec_ptr isection, void *obfdarg)
static void static void
get_sections (bfd *obfd ATTRIBUTE_UNUSED, asection *osection, void *secppparg) get_sections (bfd *obfd ATTRIBUTE_UNUSED, asection *osection, void *secppparg)
{ {
asection ***secppp = (asection ***) secppparg; asection ***secppp = secppparg;
**secppp = osection; **secppp = osection;
++(*secppp); ++(*secppp);
@ -2025,8 +1973,8 @@ get_sections (bfd *obfd ATTRIBUTE_UNUSED, asection *osection, void *secppparg)
static int static int
compare_section_lma (const void *arg1, const void *arg2) compare_section_lma (const void *arg1, const void *arg2)
{ {
const asection **sec1 = (const asection **) arg1; const asection *const *sec1 = arg1;
const asection **sec2 = (const asection **) arg2; const asection *const *sec2 = arg2;
flagword flags1, flags2; flagword flags1, flags2;
/* Sort non loadable sections to the front. */ /* Sort non loadable sections to the front. */
@ -2069,7 +2017,7 @@ compare_section_lma (const void *arg1, const void *arg2)
static void static void
mark_symbols_used_in_relocations (bfd *ibfd, sec_ptr isection, void *symbolsarg) mark_symbols_used_in_relocations (bfd *ibfd, sec_ptr isection, void *symbolsarg)
{ {
asymbol **symbols = (asymbol **) symbolsarg; asymbol **symbols = symbolsarg;
long relsize; long relsize;
arelent **relpp; arelent **relpp;
long relcount, i; long relcount, i;
@ -2085,7 +2033,7 @@ mark_symbols_used_in_relocations (bfd *ibfd, sec_ptr isection, void *symbolsarg)
if (relsize == 0) if (relsize == 0)
return; return;
relpp = (arelent **) xmalloc (relsize); relpp = xmalloc (relsize);
relcount = bfd_canonicalize_reloc (ibfd, isection, relpp, symbols); relcount = bfd_canonicalize_reloc (ibfd, isection, relpp, symbols);
if (relcount < 0) if (relcount < 0)
bfd_fatal (bfd_get_filename (ibfd)); bfd_fatal (bfd_get_filename (ibfd));
@ -2153,10 +2101,9 @@ write_debugging_info (bfd *obfd, void *dhandle,
the next thing the caller is going to do is copy over the the next thing the caller is going to do is copy over the
real sections. We may someday have to split the contents real sections. We may someday have to split the contents
setting out of this function. */ setting out of this function. */
if (! bfd_set_section_contents (obfd, stabsec, syms, (file_ptr) 0, if (! bfd_set_section_contents (obfd, stabsec, syms, 0, symsize)
symsize) || ! bfd_set_section_contents (obfd, stabstrsec, strings, 0,
|| ! bfd_set_section_contents (obfd, stabstrsec, strings, stringsize))
(file_ptr) 0, stringsize))
{ {
non_fatal (_("%s: can't set debugging section contents: %s"), non_fatal (_("%s: can't set debugging section contents: %s"),
bfd_get_filename (obfd), bfd_get_filename (obfd),
@ -2270,7 +2217,7 @@ strip_main (int argc, char *argv[])
&& strip_specific_list == NULL) && strip_specific_list == NULL)
strip_symbols = STRIP_ALL; strip_symbols = STRIP_ALL;
if (output_target == (char *) NULL) if (output_target == NULL)
output_target = input_target; output_target = input_target;
i = optind; i = optind;
@ -2468,10 +2415,10 @@ copy_main (int argc, char *argv[])
if (stat (s + 1, & st) < 0) if (stat (s + 1, & st) < 0)
fatal (_("cannot stat: %s: %s"), s + 1, strerror (errno)); fatal (_("cannot stat: %s: %s"), s + 1, strerror (errno));
pa = (struct section_add *) xmalloc (sizeof (struct section_add)); pa = xmalloc (sizeof (struct section_add));
len = s - optarg; len = s - optarg;
name = (char *) xmalloc (len + 1); name = xmalloc (len + 1);
strncpy (name, optarg, len); strncpy (name, optarg, len);
name[len] = '\0'; name[len] = '\0';
pa->name = name; pa->name = name;
@ -2480,7 +2427,7 @@ copy_main (int argc, char *argv[])
pa->size = st.st_size; pa->size = st.st_size;
pa->contents = (bfd_byte *) xmalloc (pa->size); pa->contents = xmalloc (pa->size);
f = fopen (pa->filename, FOPEN_RB); f = fopen (pa->filename, FOPEN_RB);
if (f == NULL) if (f == NULL)
@ -2539,7 +2486,7 @@ copy_main (int argc, char *argv[])
} }
len = s - optarg; len = s - optarg;
name = (char *) xmalloc (len + 1); name = xmalloc (len + 1);
strncpy (name, optarg, len); strncpy (name, optarg, len);
name[len] = '\0'; name[len] = '\0';
@ -2637,13 +2584,13 @@ copy_main (int argc, char *argv[])
fatal (_("bad format for %s"), "--redefine-sym"); fatal (_("bad format for %s"), "--redefine-sym");
len = s - optarg; len = s - optarg;
source = (char *) xmalloc (len + 1); source = xmalloc (len + 1);
strncpy (source, optarg, len); strncpy (source, optarg, len);
source[len] = '\0'; source[len] = '\0';
nextarg = s + 1; nextarg = s + 1;
len = strlen (nextarg); len = strlen (nextarg);
target = (char *) xmalloc (len + 1); target = xmalloc (len + 1);
strcpy (target, nextarg); strcpy (target, nextarg);
redefine_list_append ("--redefine-sym", source, target); redefine_list_append ("--redefine-sym", source, target);
@ -2668,7 +2615,7 @@ copy_main (int argc, char *argv[])
fatal (_("bad format for %s"), "--set-section-flags"); fatal (_("bad format for %s"), "--set-section-flags");
len = s - optarg; len = s - optarg;
name = (char *) xmalloc (len + 1); name = xmalloc (len + 1);
strncpy (name, optarg, len); strncpy (name, optarg, len);
name[len] = '\0'; name[len] = '\0';
@ -2695,7 +2642,7 @@ copy_main (int argc, char *argv[])
if (len == 0) if (len == 0)
fatal (_("bad format for %s"), "--rename-section"); fatal (_("bad format for %s"), "--rename-section");
old_name = (char *) xmalloc (len + 1); old_name = xmalloc (len + 1);
strncpy (old_name, optarg, len); strncpy (old_name, optarg, len);
old_name[len] = 0; old_name[len] = 0;
@ -2715,7 +2662,7 @@ copy_main (int argc, char *argv[])
if (len == 0) if (len == 0)
fatal (_("bad format for %s"), "--rename-section"); fatal (_("bad format for %s"), "--rename-section");
new_name = (char *) xmalloc (len + 1); new_name = xmalloc (len + 1);
strncpy (new_name, eq, len); strncpy (new_name, eq, len);
new_name[len] = 0; new_name[len] = 0;
@ -2810,10 +2757,10 @@ copy_main (int argc, char *argv[])
if (strip_symbols == STRIP_UNDEF && discard_locals == LOCALS_UNDEF) if (strip_symbols == STRIP_UNDEF && discard_locals == LOCALS_UNDEF)
strip_symbols = STRIP_NONE; strip_symbols = STRIP_NONE;
if (output_target == (char *) NULL) if (output_target == NULL)
output_target = input_target; output_target = input_target;
if (binary_architecture != (char *) NULL) if (binary_architecture != NULL)
{ {
if (input_target && strcmp (input_target, "binary") == 0) if (input_target && strcmp (input_target, "binary") == 0)
{ {
@ -2838,9 +2785,8 @@ copy_main (int argc, char *argv[])
fatal (_("Cannot stat: %s: %s"), input_filename, strerror (errno)); fatal (_("Cannot stat: %s: %s"), input_filename, strerror (errno));
/* If there is no destination file, or the source and destination files /* If there is no destination file, or the source and destination files
are the same, then create a temp and rename the result into the input. */ are the same, then create a temp and rename the result into the input. */
if ((output_filename == (char *) NULL) || if (output_filename == NULL || strcmp (input_filename, output_filename) == 0)
(strcmp (input_filename, output_filename) == 0))
{ {
char *tmpname = make_tempname (input_filename); char *tmpname = make_tempname (input_filename);

View File

@ -90,10 +90,10 @@ struct objdump_disasm_info
}; };
/* Architecture to disassemble for, or default if NULL. */ /* Architecture to disassemble for, or default if NULL. */
static char *machine = (char *) NULL; static char *machine = NULL;
/* Target specific options to the disassembler. */ /* Target specific options to the disassembler. */
static char *disassembler_options = (char *) NULL; static char *disassembler_options = NULL;
/* Endianness to disassemble for, or default if BFD_ENDIAN_UNKNOWN. */ /* Endianness to disassemble for, or default if BFD_ENDIAN_UNKNOWN. */
static enum bfd_endian endian = BFD_ENDIAN_UNKNOWN; static enum bfd_endian endian = BFD_ENDIAN_UNKNOWN;
@ -354,7 +354,7 @@ dump_headers (bfd *abfd)
static asymbol ** static asymbol **
slurp_symtab (bfd *abfd) slurp_symtab (bfd *abfd)
{ {
asymbol **sy = (asymbol **) NULL; asymbol **sy = NULL;
long storage; long storage;
if (!(bfd_get_file_flags (abfd) & HAS_SYMS)) if (!(bfd_get_file_flags (abfd) & HAS_SYMS))
@ -367,7 +367,7 @@ slurp_symtab (bfd *abfd)
if (storage < 0) if (storage < 0)
bfd_fatal (bfd_get_filename (abfd)); bfd_fatal (bfd_get_filename (abfd));
if (storage) if (storage)
sy = (asymbol **) xmalloc (storage); sy = xmalloc (storage);
symcount = bfd_canonicalize_symtab (abfd, sy); symcount = bfd_canonicalize_symtab (abfd, sy);
if (symcount < 0) if (symcount < 0)
@ -380,7 +380,7 @@ slurp_symtab (bfd *abfd)
static asymbol ** static asymbol **
slurp_dynamic_symtab (bfd *abfd) slurp_dynamic_symtab (bfd *abfd)
{ {
asymbol **sy = (asymbol **) NULL; asymbol **sy = NULL;
long storage; long storage;
storage = bfd_get_dynamic_symtab_upper_bound (abfd); storage = bfd_get_dynamic_symtab_upper_bound (abfd);
@ -396,7 +396,7 @@ slurp_dynamic_symtab (bfd *abfd)
bfd_fatal (bfd_get_filename (abfd)); bfd_fatal (bfd_get_filename (abfd));
} }
if (storage) if (storage)
sy = (asymbol **) xmalloc (storage); sy = xmalloc (storage);
dynsymcount = bfd_canonicalize_dynamic_symtab (abfd, sy); dynsymcount = bfd_canonicalize_dynamic_symtab (abfd, sy);
if (dynsymcount < 0) if (dynsymcount < 0)
@ -801,7 +801,7 @@ objdump_print_addr (bfd_vma vma, struct disassemble_info *info,
aux = (struct objdump_disasm_info *) info->application_data; aux = (struct objdump_disasm_info *) info->application_data;
sym = find_symbol_for_address (aux->abfd, aux->sec, vma, aux->require_sec, sym = find_symbol_for_address (aux->abfd, aux->sec, vma, aux->require_sec,
(long *) NULL); NULL);
objdump_print_addr_with_sym (aux->abfd, aux->sec, sym, vma, info, objdump_print_addr_with_sym (aux->abfd, aux->sec, sym, vma, info,
skip_zeroes); skip_zeroes);
} }
@ -829,7 +829,7 @@ objdump_symbol_at_address (bfd_vma vma, struct disassemble_info * info)
aux = (struct objdump_disasm_info *) info->application_data; aux = (struct objdump_disasm_info *) info->application_data;
sym = find_symbol_for_address (aux->abfd, aux->sec, vma, aux->require_sec, sym = find_symbol_for_address (aux->abfd, aux->sec, vma, aux->require_sec,
(long *) NULL); NULL);
return (sym != NULL && (bfd_asymbol_value (sym) == vma)); return (sym != NULL && (bfd_asymbol_value (sym) == vma));
} }
@ -1520,7 +1520,7 @@ disassemble_data (bfd *abfd)
/* We make a copy of syms to sort. We don't want to sort syms /* We make a copy of syms to sort. We don't want to sort syms
because that will screw up the relocs. */ because that will screw up the relocs. */
sorted_syms = (asymbol **) xmalloc (symcount * sizeof (asymbol *)); sorted_syms = xmalloc (symcount * sizeof (asymbol *));
memcpy (sorted_syms, syms, symcount * sizeof (asymbol *)); memcpy (sorted_syms, syms, symcount * sizeof (asymbol *));
sorted_symcount = remove_useless_symbols (sorted_syms, symcount); sorted_symcount = remove_useless_symbols (sorted_syms, symcount);
@ -1536,7 +1536,7 @@ disassemble_data (bfd *abfd)
disasm_info.print_address_func = objdump_print_address; disasm_info.print_address_func = objdump_print_address;
disasm_info.symbol_at_address_func = objdump_symbol_at_address; disasm_info.symbol_at_address_func = objdump_symbol_at_address;
if (machine != (char *) NULL) if (machine != NULL)
{ {
const bfd_arch_info_type *info = bfd_scan_arch (machine); const bfd_arch_info_type *info = bfd_scan_arch (machine);
@ -1550,7 +1550,7 @@ disassemble_data (bfd *abfd)
{ {
struct bfd_target *xvec; struct bfd_target *xvec;
xvec = (struct bfd_target *) xmalloc (sizeof (struct bfd_target)); xvec = xmalloc (sizeof (struct bfd_target));
memcpy (xvec, abfd->xvec, sizeof (struct bfd_target)); memcpy (xvec, abfd->xvec, sizeof (struct bfd_target));
xvec->byteorder = endian; xvec->byteorder = endian;
abfd->xvec = xvec; abfd->xvec = xvec;
@ -1591,7 +1591,7 @@ disassemble_data (bfd *abfd)
if (relsize > 0) if (relsize > 0)
{ {
dynrelbuf = (arelent **) xmalloc (relsize); dynrelbuf = xmalloc (relsize);
relcount = bfd_canonicalize_dynamic_reloc (abfd, dynrelbuf, dynsyms); relcount = bfd_canonicalize_dynamic_reloc (abfd, dynrelbuf, dynsyms);
if (relcount < 0) if (relcount < 0)
bfd_fatal (bfd_get_filename (abfd)); bfd_fatal (bfd_get_filename (abfd));
@ -1602,7 +1602,7 @@ disassemble_data (bfd *abfd)
} }
for (section = abfd->sections; for (section = abfd->sections;
section != (asection *) NULL; section != NULL;
section = section->next) section = section->next)
{ {
bfd_byte *data = NULL; bfd_byte *data = NULL;
@ -1649,7 +1649,7 @@ disassemble_data (bfd *abfd)
if (relsize > 0) if (relsize > 0)
{ {
relbuf = (arelent **) xmalloc (relsize); relbuf = xmalloc (relsize);
relcount = bfd_canonicalize_reloc (abfd, section, relbuf, syms); relcount = bfd_canonicalize_reloc (abfd, section, relbuf, syms);
if (relcount < 0) if (relcount < 0)
bfd_fatal (bfd_get_filename (abfd)); bfd_fatal (bfd_get_filename (abfd));
@ -1665,7 +1665,7 @@ disassemble_data (bfd *abfd)
printf (_("Disassembly of section %s:\n"), section->name); printf (_("Disassembly of section %s:\n"), section->name);
data = (bfd_byte *) xmalloc ((size_t) datasize); data = xmalloc (datasize);
bfd_get_section_contents (abfd, section, data, 0, datasize); bfd_get_section_contents (abfd, section, data, 0, datasize);
@ -1866,10 +1866,10 @@ read_section_stabs (bfd *abfd, const char *stabsect_name,
stab_size = bfd_section_size (abfd, stabsect); stab_size = bfd_section_size (abfd, stabsect);
stabstr_size = bfd_section_size (abfd, stabstrsect); stabstr_size = bfd_section_size (abfd, stabstrsect);
stabs = (bfd_byte *) xmalloc (stab_size); stabs = xmalloc (stab_size);
strtab = (char *) xmalloc (stabstr_size); strtab = xmalloc (stabstr_size);
if (! bfd_get_section_contents (abfd, stabsect, (void *) stabs, 0, stab_size)) if (! bfd_get_section_contents (abfd, stabsect, stabs, 0, stab_size))
{ {
non_fatal (_("Reading %s section of %s failed: %s"), non_fatal (_("Reading %s section of %s failed: %s"),
stabsect_name, bfd_get_filename (abfd), stabsect_name, bfd_get_filename (abfd),
@ -2173,7 +2173,7 @@ display_bfd (bfd *abfd)
static void static void
display_file (char *filename, char *target) display_file (char *filename, char *target)
{ {
bfd *file, *arfile = (bfd *) NULL; bfd *file, *arfile = NULL;
file = bfd_openr (filename, target); file = bfd_openr (filename, target);
if (file == NULL) if (file == NULL)
@ -2248,12 +2248,11 @@ dump_data (bfd *abfd)
if (bfd_section_size (abfd, section) == 0) if (bfd_section_size (abfd, section) == 0)
continue; continue;
data = (bfd_byte *) xmalloc ((size_t) bfd_section_size data = xmalloc (bfd_section_size (abfd, section));
(abfd, section));
datasize = bfd_section_size (abfd, section); datasize = bfd_section_size (abfd, section);
bfd_get_section_contents (abfd, section, (void *) data, 0, bfd_get_section_contents (abfd, section, data, 0,
bfd_section_size (abfd, section)); bfd_section_size (abfd, section));
if (start_address == (bfd_vma) -1 if (start_address == (bfd_vma) -1
@ -2411,7 +2410,7 @@ dump_relocs (bfd *abfd)
long relcount; long relcount;
asection *a; asection *a;
for (a = abfd->sections; a != (asection *) NULL; a = a->next) for (a = abfd->sections; a != NULL; a = a->next)
{ {
long relsize; long relsize;
@ -2448,7 +2447,7 @@ dump_relocs (bfd *abfd)
} }
else else
{ {
relpp = (arelent **) xmalloc (relsize); relpp = xmalloc (relsize);
relcount = bfd_canonicalize_reloc (abfd, a, relpp, syms); relcount = bfd_canonicalize_reloc (abfd, a, relpp, syms);
if (relcount < 0) if (relcount < 0)
@ -2483,7 +2482,7 @@ dump_dynamic_relocs (bfd *abfd)
printf (" (none)\n\n"); printf (" (none)\n\n");
else else
{ {
relpp = (arelent **) xmalloc (relsize); relpp = xmalloc (relsize);
relcount = bfd_canonicalize_dynamic_reloc (abfd, relpp, dynsyms); relcount = bfd_canonicalize_dynamic_reloc (abfd, relpp, dynsyms);
if (relcount < 0) if (relcount < 0)
@ -2493,7 +2492,7 @@ dump_dynamic_relocs (bfd *abfd)
else else
{ {
printf ("\n"); printf ("\n");
dump_reloc_set (abfd, (asection *) NULL, relpp, relcount); dump_reloc_set (abfd, NULL, relpp, relcount);
printf ("\n\n"); printf ("\n\n");
} }
free (relpp); free (relpp);
@ -2524,7 +2523,7 @@ dump_reloc_set (bfd *abfd, asection *sec, arelent **relpp, long relcount)
last_functionname = NULL; last_functionname = NULL;
last_line = 0; last_line = 0;
for (p = relpp; relcount && *p != (arelent *) NULL; p++, relcount--) for (p = relpp; relcount && *p != NULL; p++, relcount--)
{ {
arelent *q = *p; arelent *q = *p;
const char *filename, *functionname; const char *filename, *functionname;
@ -2589,12 +2588,11 @@ dump_reloc_set (bfd *abfd, asection *sec, arelent **relpp, long relcount)
printf (" %-16s ", q->howto->name); printf (" %-16s ", q->howto->name);
else else
printf (" %-16d ", q->howto->type); printf (" %-16d ", q->howto->type);
objdump_print_symname (abfd, (struct disassemble_info *) NULL, objdump_print_symname (abfd, NULL, *q->sym_ptr_ptr);
*q->sym_ptr_ptr);
} }
else else
{ {
if (section_name == (const char *) NULL) if (section_name == NULL)
section_name = "*unknown*"; section_name = "*unknown*";
bfd_printf_vma (abfd, q->address); bfd_printf_vma (abfd, q->address);
printf (" %-16s [%s]", printf (" %-16s [%s]",

File diff suppressed because it is too large Load Diff