aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2019-09-06 12:07:05 +0930
committerAlan Modra <amodra@gmail.com>2019-09-06 12:22:59 +0930
commitb16c44debcf8a446e94e161e328169f5c8d5d811 (patch)
treef402c08e8f7fc00a404055e36c416580377f1b3a
parent6ade8373c9e689dece1057366b5adf9f8e86fa22 (diff)
downloadgdb-b16c44debcf8a446e94e161e328169f5c8d5d811.zip
gdb-b16c44debcf8a446e94e161e328169f5c8d5d811.tar.gz
gdb-b16c44debcf8a446e94e161e328169f5c8d5d811.tar.bz2
bfd_get_filename
This macro says: /* Cast from const char * to char * so that caller can assign to a char * without a warning. */ I reckon that isn't such a good idea since it can result in char* variables where const char* is appropriate. Not very many places need the char* cast. bfd/ * aout-target.h (object_p): Formatting. * bfd-in.h (bfd_get_filename): Don't cast to char*. * corefile.c (generic_core_file_matches_executable_p): Constify variables and remove cast. * bfd-in2.h: Regenerate. binutils/ * nm.c (print_object_filename_bsd, print_object_filename_sysv), (print_object_filename_posix, print_archive_filename_bsd), (print_archive_filename_sysv, print_archive_filename_posix), (print_archive_member_bsd, print_archive_member_sysv), (print_archive_member_posix): Constify parameter. (struct output_fns <print_object_filename, print_archive_filename>), (<print_archive_member>): Likewise. * objcopy.c (copy_archive): Add cast for make_tempdir. ld/ * emultempl/elf32.em (gld${EMULATION_NAME}_search_needed): Constify variable. * emultempl/pe.em (gld_${EMULATION_NAME}_after_open): Likewise. * emultempl/pep.em (gld_${EMULATION_NAME}_after_open): Likewise. gdb/ * coffread.c (coff_symfile_read): Constify filename variable. * dbxread.c (dbx_symfile_init, coffstab_build_psymtabs), (elfstab_build_psymtabs, stabsect_build_psymtabs): Likewise. * gdb_bfd.c (gdb_bfd_close_or_warn): Likewise. * solib.c (reload_shared_libraries_1): Likewise. * symfile.c (reread_symbols): Likewise. * solib-aix.c (solib_aix_bfd_open): Add cast for xfree of filename. * solib-darwin.c (darwin_bfd_open): Likewise. * symfile-mem.c (symbol_file_add_from_memory): Likewise. sim/cris/ * sim-if.c (sim_open): Constify filename variable.
-rw-r--r--bfd/ChangeLog8
-rw-r--r--bfd/aout-target.h2
-rw-r--r--bfd/bfd-in.h4
-rw-r--r--bfd/bfd-in2.h4
-rw-r--r--bfd/corefile.c8
-rw-r--r--binutils/ChangeLog11
-rw-r--r--binutils/nm.c42
-rw-r--r--binutils/objcopy.c2
-rw-r--r--gdb/ChangeLog12
-rw-r--r--gdb/coffread.c2
-rw-r--r--gdb/dbxread.c8
-rw-r--r--gdb/gdb_bfd.c2
-rw-r--r--gdb/solib-aix.c4
-rw-r--r--gdb/solib-darwin.c2
-rw-r--r--gdb/solib.c2
-rw-r--r--gdb/symfile-mem.c2
-rw-r--r--gdb/symfile.c2
-rw-r--r--ld/ChangeLog7
-rw-r--r--ld/emultempl/elf32.em2
-rw-r--r--ld/emultempl/pe.em2
-rw-r--r--ld/emultempl/pep.em2
-rw-r--r--sim/cris/ChangeLog4
-rw-r--r--sim/cris/sim-if.c2
23 files changed, 87 insertions, 49 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 8ed849d..24f5e33 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,11 @@
+2019-09-06 Alan Modra <amodra@gmail.com>
+
+ * aout-target.h (object_p): Formatting.
+ * bfd-in.h (bfd_get_filename): Don't cast to char*.
+ * corefile.c (generic_core_file_matches_executable_p): Constify
+ variables and remove cast.
+ * bfd-in2.h: Regenerate.
+
2019-09-05 Alan Modra <amodra@gmail.com>
* elf64-ppc.c (ppc64_elf_check_relocs): Interpret an addend in
diff --git a/bfd/aout-target.h b/bfd/aout-target.h
index 2f3d5ea..99a82bb 100644
--- a/bfd/aout-target.h
+++ b/bfd/aout-target.h
@@ -180,7 +180,7 @@ MY (object_p) (bfd *abfd)
#ifndef S_IXUSR
#define S_IXUSR 0100 /* Execute by owner. */
#endif
- if (stat(abfd->filename, &buf) == 0 && (buf.st_mode & S_IXUSR))
+ if (stat (abfd->filename, &buf) == 0 && (buf.st_mode & S_IXUSR))
abfd->flags |= EXEC_P;
}
#endif /* ENTRY_CAN_BE_ZERO */
diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h
index a5e95d1..6544838 100644
--- a/bfd/bfd-in.h
+++ b/bfd/bfd-in.h
@@ -518,9 +518,7 @@ extern int bfd_stat (bfd *, struct stat *);
#endif
extern void _bfd_warn_deprecated (const char *, const char *, int, const char *);
-/* Cast from const char * to char * so that caller can assign to
- a char * without a warning. */
-#define bfd_get_filename(abfd) ((char *) (abfd)->filename)
+#define bfd_get_filename(abfd) ((abfd)->filename)
#define bfd_get_cacheable(abfd) ((abfd)->cacheable)
#define bfd_get_format(abfd) ((abfd)->format)
#define bfd_get_target(abfd) ((abfd)->xvec->name)
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index 63b4792..7b1cfbc 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -525,9 +525,7 @@ extern int bfd_stat (bfd *, struct stat *);
#endif
extern void _bfd_warn_deprecated (const char *, const char *, int, const char *);
-/* Cast from const char * to char * so that caller can assign to
- a char * without a warning. */
-#define bfd_get_filename(abfd) ((char *) (abfd)->filename)
+#define bfd_get_filename(abfd) ((abfd)->filename)
#define bfd_get_cacheable(abfd) ((abfd)->cacheable)
#define bfd_get_format(abfd) ((abfd)->format)
#define bfd_get_target(abfd) ((abfd)->xvec->name)
diff --git a/bfd/corefile.c b/bfd/corefile.c
index aa43da5..b2b3d2e 100644
--- a/bfd/corefile.c
+++ b/bfd/corefile.c
@@ -157,9 +157,9 @@ DESCRIPTION
bfd_boolean
generic_core_file_matches_executable_p (bfd *core_bfd, bfd *exec_bfd)
{
- char *exec;
- char *core;
- char *last_slash;
+ const char *exec;
+ const char *core;
+ const char *last_slash;
if (exec_bfd == NULL || core_bfd == NULL)
return TRUE;
@@ -169,7 +169,7 @@ generic_core_file_matches_executable_p (bfd *core_bfd, bfd *exec_bfd)
non-const char *. In this case, the assignement does not lead to
breaking the const, as we're only reading the string. */
- core = (char *) bfd_core_file_failing_command (core_bfd);
+ core = bfd_core_file_failing_command (core_bfd);
if (core == NULL)
return TRUE;
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 98e660d..198380e 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,14 @@
+2019-09-06 Alan Modra <amodra@gmail.com>
+
+ * nm.c (print_object_filename_bsd, print_object_filename_sysv),
+ (print_object_filename_posix, print_archive_filename_bsd),
+ (print_archive_filename_sysv, print_archive_filename_posix),
+ (print_archive_member_bsd, print_archive_member_sysv),
+ (print_archive_member_posix): Constify parameter.
+ (struct output_fns <print_object_filename, print_archive_filename>),
+ (<print_archive_member>): Likewise.
+ * objcopy.c (copy_archive): Add cast for make_tempdir.
+
2019-08-29 Alan Modra <amodra@gmail.com>
* dwarf.c (check_uvalue): Remove unnecessary pointer checks.
diff --git a/binutils/nm.c b/binutils/nm.c
index 5d3d647..67b7ac7 100644
--- a/binutils/nm.c
+++ b/binutils/nm.c
@@ -77,15 +77,15 @@ struct extended_symbol_info
(sym->elfinfo ? sym->elfinfo->internal_elf_sym.st_size: sym->ssize)
/* The output formatting functions. */
-static void print_object_filename_bsd (char *);
-static void print_object_filename_sysv (char *);
-static void print_object_filename_posix (char *);
-static void print_archive_filename_bsd (char *);
-static void print_archive_filename_sysv (char *);
-static void print_archive_filename_posix (char *);
-static void print_archive_member_bsd (char *, const char *);
-static void print_archive_member_sysv (char *, const char *);
-static void print_archive_member_posix (char *, const char *);
+static void print_object_filename_bsd (const char *);
+static void print_object_filename_sysv (const char *);
+static void print_object_filename_posix (const char *);
+static void print_archive_filename_bsd (const char *);
+static void print_archive_filename_sysv (const char *);
+static void print_archive_filename_posix (const char *);
+static void print_archive_member_bsd (const char *, const char *);
+static void print_archive_member_sysv (const char *, const char *);
+static void print_archive_member_posix (const char *, const char *);
static void print_symbol_filename_bsd (bfd *, bfd *);
static void print_symbol_filename_sysv (bfd *, bfd *);
static void print_symbol_filename_posix (bfd *, bfd *);
@@ -98,13 +98,13 @@ static void print_symbol_info_posix (struct extended_symbol_info *, bfd *);
struct output_fns
{
/* Print the name of an object file given on the command line. */
- void (*print_object_filename) (char *);
+ void (*print_object_filename) (const char *);
/* Print the name of an archive file given on the command line. */
- void (*print_archive_filename) (char *);
+ void (*print_archive_filename) (const char *);
/* Print the name of an archive member file. */
- void (*print_archive_member) (char *, const char *);
+ void (*print_archive_member) (const char *, const char *);
/* Print the name of the file (and archive, if there is one)
containing a symbol. */
@@ -1357,14 +1357,14 @@ display_file (char *filename)
/* Print the name of an object file given on the command line. */
static void
-print_object_filename_bsd (char *filename)
+print_object_filename_bsd (const char *filename)
{
if (filename_per_file && !filename_per_symbol)
printf ("\n%s:\n", filename);
}
static void
-print_object_filename_sysv (char *filename)
+print_object_filename_sysv (const char *filename)
{
if (undefined_only)
printf (_("\n\nUndefined symbols from %s:\n\n"), filename);
@@ -1379,7 +1379,7 @@ Name Value Class Type Size
}
static void
-print_object_filename_posix (char *filename)
+print_object_filename_posix (const char *filename)
{
if (filename_per_file && !filename_per_symbol)
printf ("%s:\n", filename);
@@ -1388,26 +1388,26 @@ print_object_filename_posix (char *filename)
/* Print the name of an archive file given on the command line. */
static void
-print_archive_filename_bsd (char *filename)
+print_archive_filename_bsd (const char *filename)
{
if (filename_per_file)
printf ("\n%s:\n", filename);
}
static void
-print_archive_filename_sysv (char *filename ATTRIBUTE_UNUSED)
+print_archive_filename_sysv (const char *filename ATTRIBUTE_UNUSED)
{
}
static void
-print_archive_filename_posix (char *filename ATTRIBUTE_UNUSED)
+print_archive_filename_posix (const char *filename ATTRIBUTE_UNUSED)
{
}
/* Print the name of an archive member file. */
static void
-print_archive_member_bsd (char *archive ATTRIBUTE_UNUSED,
+print_archive_member_bsd (const char *archive ATTRIBUTE_UNUSED,
const char *filename)
{
if (!filename_per_symbol)
@@ -1415,7 +1415,7 @@ print_archive_member_bsd (char *archive ATTRIBUTE_UNUSED,
}
static void
-print_archive_member_sysv (char *archive, const char *filename)
+print_archive_member_sysv (const char *archive, const char *filename)
{
if (undefined_only)
printf (_("\n\nUndefined symbols from %s[%s]:\n\n"), archive, filename);
@@ -1430,7 +1430,7 @@ Name Value Class Type Size
}
static void
-print_archive_member_posix (char *archive, const char *filename)
+print_archive_member_posix (const char *archive, const char *filename)
{
if (!filename_per_symbol)
printf ("%s[%s]:\n", archive, filename);
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index ebb9933..b702e52 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -3311,7 +3311,7 @@ copy_archive (bfd *ibfd, bfd *obfd, const char *output_target,
}
/* Make a temp directory to hold the contents. */
- dir = make_tempdir (bfd_get_filename (obfd));
+ dir = make_tempdir ((char *) bfd_get_filename (obfd));
if (dir == NULL)
fatal (_("cannot create tempdir for archive copying (error: %s)"),
strerror (errno));
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index f55d1a8..40bd4d0 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,15 @@
+2019-09-06 Alan Modra <amodra@gmail.com>
+
+ * coffread.c (coff_symfile_read): Constify filename variable.
+ * dbxread.c (dbx_symfile_init, coffstab_build_psymtabs),
+ (elfstab_build_psymtabs, stabsect_build_psymtabs): Likewise.
+ * gdb_bfd.c (gdb_bfd_close_or_warn): Likewise.
+ * solib.c (reload_shared_libraries_1): Likewise.
+ * symfile.c (reread_symbols): Likewise.
+ * solib-aix.c (solib_aix_bfd_open): Add cast for xfree of filename.
+ * solib-darwin.c (darwin_bfd_open): Likewise.
+ * symfile-mem.c (symbol_file_add_from_memory): Likewise.
+
2019-09-03 Andrew Burgess <andrew.burgess@embecosm.com>
* psymtab.c (print_partial_symbols): Handle missing domain_enum
diff --git a/gdb/coffread.c b/gdb/coffread.c
index e24ab8d..a704612 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -538,7 +538,7 @@ coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
struct coff_symfile_info *info;
bfd *abfd = objfile->obfd;
coff_data_type *cdata = coff_data (abfd);
- char *filename = bfd_get_filename (abfd);
+ const char *filename = bfd_get_filename (abfd);
int val;
unsigned int num_symbols;
int symtab_offset;
diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index e339d1f..df3ae58 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -587,7 +587,7 @@ dbx_symfile_init (struct objfile *objfile)
{
int val;
bfd *sym_bfd = objfile->obfd;
- char *name = bfd_get_filename (sym_bfd);
+ const char *name = bfd_get_filename (sym_bfd);
asection *text_sect;
unsigned char size_temp[DBX_STRINGTAB_SIZE_SIZE];
@@ -2939,7 +2939,7 @@ coffstab_build_psymtabs (struct objfile *objfile,
{
int val;
bfd *sym_bfd = objfile->obfd;
- char *name = bfd_get_filename (sym_bfd);
+ const char *name = bfd_get_filename (sym_bfd);
unsigned int stabsize;
/* Allocate struct to keep track of stab reading. */
@@ -3026,7 +3026,7 @@ elfstab_build_psymtabs (struct objfile *objfile, asection *stabsect,
{
int val;
bfd *sym_bfd = objfile->obfd;
- char *name = bfd_get_filename (sym_bfd);
+ const char *name = bfd_get_filename (sym_bfd);
stabsread_new_init ();
@@ -3107,7 +3107,7 @@ stabsect_build_psymtabs (struct objfile *objfile, char *stab_name,
{
int val;
bfd *sym_bfd = objfile->obfd;
- char *name = bfd_get_filename (sym_bfd);
+ const char *name = bfd_get_filename (sym_bfd);
asection *stabsect;
asection *stabstrsect;
asection *text_sect;
diff --git a/gdb/gdb_bfd.c b/gdb/gdb_bfd.c
index 0334523..d3b4c74 100644
--- a/gdb/gdb_bfd.c
+++ b/gdb/gdb_bfd.c
@@ -504,7 +504,7 @@ static int
gdb_bfd_close_or_warn (struct bfd *abfd)
{
int ret;
- char *name = bfd_get_filename (abfd);
+ const char *name = bfd_get_filename (abfd);
bfd_map_over_sections (abfd, free_one_bfd_section, NULL);
diff --git a/gdb/solib-aix.c b/gdb/solib-aix.c
index d13b651..2b54442 100644
--- a/gdb/solib-aix.c
+++ b/gdb/solib-aix.c
@@ -643,9 +643,9 @@ solib_aix_bfd_open (const char *pathname)
along with appended parenthesized member name in order to allow commands
listing all shared libraries to display. Otherwise, we would only be
displaying the name of the archive member object. */
- xfree (bfd_get_filename (object_bfd.get ()));
+ xfree ((char *) bfd_get_filename (object_bfd.get ()));
object_bfd->filename = xstrprintf ("%s%s",
- bfd_get_filename (archive_bfd.get ()),
+ bfd_get_filename (archive_bfd.get ()),
sep);
return object_bfd;
diff --git a/gdb/solib-darwin.c b/gdb/solib-darwin.c
index 443ebb6..3dd30d2 100644
--- a/gdb/solib-darwin.c
+++ b/gdb/solib-darwin.c
@@ -670,7 +670,7 @@ darwin_bfd_open (const char *pathname)
/* The current filename for fat-binary BFDs is a name generated
by BFD, usually a string containing the name of the architecture.
Reset its value to the actual filename. */
- xfree (bfd_get_filename (res.get ()));
+ xfree ((char *) bfd_get_filename (res.get ()));
res->filename = xstrdup (pathname);
return res;
diff --git a/gdb/solib.c b/gdb/solib.c
index 29a17ad..86000f6 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -1296,7 +1296,7 @@ reload_shared_libraries_1 (int from_tty)
for (so = so_list_head; so != NULL; so = so->next)
{
- char *found_pathname = NULL;
+ const char *found_pathname = NULL;
int was_loaded = so->symbols_loaded;
symfile_add_flags add_flags = SYMFILE_DEFER_BP_RESET;
diff --git a/gdb/symfile-mem.c b/gdb/symfile-mem.c
index 51a7554..6d1deae 100644
--- a/gdb/symfile-mem.c
+++ b/gdb/symfile-mem.c
@@ -101,7 +101,7 @@ symbol_file_add_from_memory (struct bfd *templ, CORE_ADDR addr,
/* Manage the new reference for the duration of this function. */
gdb_bfd_ref_ptr nbfd_holder = gdb_bfd_ref_ptr::new_reference (nbfd);
- xfree (bfd_get_filename (nbfd));
+ xfree ((char *) bfd_get_filename (nbfd));
if (name == NULL)
nbfd->filename = xstrdup ("shared object read from target memory");
else
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 8843781..3cd5144 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -2548,7 +2548,7 @@ reread_symbols (void)
/* Clean up any state BFD has sitting around. */
{
gdb_bfd_ref_ptr obfd (objfile->obfd);
- char *obfd_filename;
+ const char *obfd_filename;
obfd_filename = bfd_get_filename (objfile->obfd);
/* Open the new BFD before freeing the old one, so that
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 37836aa..13abd72 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,10 @@
+2019-09-06 Alan Modra <amodra@gmail.com>
+
+ * emultempl/elf32.em (gld${EMULATION_NAME}_search_needed): Constify
+ variable.
+ * emultempl/pe.em (gld_${EMULATION_NAME}_after_open): Likewise.
+ * emultempl/pep.em (gld_${EMULATION_NAME}_after_open): Likewise.
+
2019-09-05 Eric Botcazou <ebotcazou@adacore.com>
PR ld/24574
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
index b3c012c..52db0fd 100644
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -552,7 +552,7 @@ gld${EMULATION_NAME}_search_needed (const char *path,
FIXME: The code could be a lot cleverer about allocating space
for the processed string. */
char * end = strchr (var, '/');
- char * replacement = NULL;
+ const char *replacement = NULL;
char * v = var + 1;
char * freeme = NULL;
unsigned flen = strlen (filename);
diff --git a/ld/emultempl/pe.em b/ld/emultempl/pe.em
index 834215a..49bb66b 100644
--- a/ld/emultempl/pe.em
+++ b/ld/emultempl/pe.em
@@ -1513,7 +1513,7 @@ gld_${EMULATION_NAME}_after_open (void)
{
struct bfd_symbol *s;
struct bfd_link_hash_entry * blhe;
- char *other_bfd_filename;
+ const char *other_bfd_filename;
char *n;
s = (relocs[i]->sym_ptr_ptr)[0];
diff --git a/ld/emultempl/pep.em b/ld/emultempl/pep.em
index 9eb7cd7..4daa32b 100644
--- a/ld/emultempl/pep.em
+++ b/ld/emultempl/pep.em
@@ -1480,7 +1480,7 @@ gld_${EMULATION_NAME}_after_open (void)
{
struct bfd_symbol *s;
struct bfd_link_hash_entry * blhe;
- char *other_bfd_filename;
+ const char *other_bfd_filename;
char *n;
s = (relocs[i]->sym_ptr_ptr)[0];
diff --git a/sim/cris/ChangeLog b/sim/cris/ChangeLog
index 5e26f3d..d37fc8f 100644
--- a/sim/cris/ChangeLog
+++ b/sim/cris/ChangeLog
@@ -1,3 +1,7 @@
+2019-09-06 Alan Modra <amodra@gmail.com>
+
+ * sim-if.c (sim_open): Constify filename variable.
+
2018-12-06 Andrew Burgess <andrew.burgess@embecosm.com>
* Makefile.in: Replace uses of CGEN_CPU_DIR with CPU_DIR, and
diff --git a/sim/cris/sim-if.c b/sim/cris/sim-if.c
index 054cce5..1a5d421 100644
--- a/sim/cris/sim-if.c
+++ b/sim/cris/sim-if.c
@@ -746,7 +746,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback, struct bfd *abfd,
specified. */
if (abfd != NULL && !cris_bare_iron)
{
- char *name = bfd_get_filename (abfd);
+ const char *name = bfd_get_filename (abfd);
char **my_environ = GET_ENVIRON ();
/* We use these maps to give the same behavior as the old xsim
simulator. */