• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

Revisionb16c44debcf8a446e94e161e328169f5c8d5d811 (tree)
Time2019-09-06 11:52:59
AuthorAlan Modra <amodra@gmai...>
CommiterAlan Modra

Log Message

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.

Change Summary

Incremental Difference

--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,11 @@
1+2019-09-06 Alan Modra <amodra@gmail.com>
2+
3+ * aout-target.h (object_p): Formatting.
4+ * bfd-in.h (bfd_get_filename): Don't cast to char*.
5+ * corefile.c (generic_core_file_matches_executable_p): Constify
6+ variables and remove cast.
7+ * bfd-in2.h: Regenerate.
8+
19 2019-09-05 Alan Modra <amodra@gmail.com>
210
311 * elf64-ppc.c (ppc64_elf_check_relocs): Interpret an addend in
--- a/bfd/aout-target.h
+++ b/bfd/aout-target.h
@@ -180,7 +180,7 @@ MY (object_p) (bfd *abfd)
180180 #ifndef S_IXUSR
181181 #define S_IXUSR 0100 /* Execute by owner. */
182182 #endif
183- if (stat(abfd->filename, &buf) == 0 && (buf.st_mode & S_IXUSR))
183+ if (stat (abfd->filename, &buf) == 0 && (buf.st_mode & S_IXUSR))
184184 abfd->flags |= EXEC_P;
185185 }
186186 #endif /* ENTRY_CAN_BE_ZERO */
--- a/bfd/bfd-in.h
+++ b/bfd/bfd-in.h
@@ -518,9 +518,7 @@ extern int bfd_stat (bfd *, struct stat *);
518518 #endif
519519 extern void _bfd_warn_deprecated (const char *, const char *, int, const char *);
520520
521-/* Cast from const char * to char * so that caller can assign to
522- a char * without a warning. */
523-#define bfd_get_filename(abfd) ((char *) (abfd)->filename)
521+#define bfd_get_filename(abfd) ((abfd)->filename)
524522 #define bfd_get_cacheable(abfd) ((abfd)->cacheable)
525523 #define bfd_get_format(abfd) ((abfd)->format)
526524 #define bfd_get_target(abfd) ((abfd)->xvec->name)
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -525,9 +525,7 @@ extern int bfd_stat (bfd *, struct stat *);
525525 #endif
526526 extern void _bfd_warn_deprecated (const char *, const char *, int, const char *);
527527
528-/* Cast from const char * to char * so that caller can assign to
529- a char * without a warning. */
530-#define bfd_get_filename(abfd) ((char *) (abfd)->filename)
528+#define bfd_get_filename(abfd) ((abfd)->filename)
531529 #define bfd_get_cacheable(abfd) ((abfd)->cacheable)
532530 #define bfd_get_format(abfd) ((abfd)->format)
533531 #define bfd_get_target(abfd) ((abfd)->xvec->name)
--- a/bfd/corefile.c
+++ b/bfd/corefile.c
@@ -157,9 +157,9 @@ DESCRIPTION
157157 bfd_boolean
158158 generic_core_file_matches_executable_p (bfd *core_bfd, bfd *exec_bfd)
159159 {
160- char *exec;
161- char *core;
162- char *last_slash;
160+ const char *exec;
161+ const char *core;
162+ const char *last_slash;
163163
164164 if (exec_bfd == NULL || core_bfd == NULL)
165165 return TRUE;
@@ -169,7 +169,7 @@ generic_core_file_matches_executable_p (bfd *core_bfd, bfd *exec_bfd)
169169 non-const char *. In this case, the assignement does not lead to
170170 breaking the const, as we're only reading the string. */
171171
172- core = (char *) bfd_core_file_failing_command (core_bfd);
172+ core = bfd_core_file_failing_command (core_bfd);
173173 if (core == NULL)
174174 return TRUE;
175175
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,14 @@
1+2019-09-06 Alan Modra <amodra@gmail.com>
2+
3+ * nm.c (print_object_filename_bsd, print_object_filename_sysv),
4+ (print_object_filename_posix, print_archive_filename_bsd),
5+ (print_archive_filename_sysv, print_archive_filename_posix),
6+ (print_archive_member_bsd, print_archive_member_sysv),
7+ (print_archive_member_posix): Constify parameter.
8+ (struct output_fns <print_object_filename, print_archive_filename>),
9+ (<print_archive_member>): Likewise.
10+ * objcopy.c (copy_archive): Add cast for make_tempdir.
11+
112 2019-08-29 Alan Modra <amodra@gmail.com>
213
314 * dwarf.c (check_uvalue): Remove unnecessary pointer checks.
--- a/binutils/nm.c
+++ b/binutils/nm.c
@@ -77,15 +77,15 @@ struct extended_symbol_info
7777 (sym->elfinfo ? sym->elfinfo->internal_elf_sym.st_size: sym->ssize)
7878
7979 /* The output formatting functions. */
80-static void print_object_filename_bsd (char *);
81-static void print_object_filename_sysv (char *);
82-static void print_object_filename_posix (char *);
83-static void print_archive_filename_bsd (char *);
84-static void print_archive_filename_sysv (char *);
85-static void print_archive_filename_posix (char *);
86-static void print_archive_member_bsd (char *, const char *);
87-static void print_archive_member_sysv (char *, const char *);
88-static void print_archive_member_posix (char *, const char *);
80+static void print_object_filename_bsd (const char *);
81+static void print_object_filename_sysv (const char *);
82+static void print_object_filename_posix (const char *);
83+static void print_archive_filename_bsd (const char *);
84+static void print_archive_filename_sysv (const char *);
85+static void print_archive_filename_posix (const char *);
86+static void print_archive_member_bsd (const char *, const char *);
87+static void print_archive_member_sysv (const char *, const char *);
88+static void print_archive_member_posix (const char *, const char *);
8989 static void print_symbol_filename_bsd (bfd *, bfd *);
9090 static void print_symbol_filename_sysv (bfd *, bfd *);
9191 static void print_symbol_filename_posix (bfd *, bfd *);
@@ -98,13 +98,13 @@ static void print_symbol_info_posix (struct extended_symbol_info *, bfd *);
9898 struct output_fns
9999 {
100100 /* Print the name of an object file given on the command line. */
101- void (*print_object_filename) (char *);
101+ void (*print_object_filename) (const char *);
102102
103103 /* Print the name of an archive file given on the command line. */
104- void (*print_archive_filename) (char *);
104+ void (*print_archive_filename) (const char *);
105105
106106 /* Print the name of an archive member file. */
107- void (*print_archive_member) (char *, const char *);
107+ void (*print_archive_member) (const char *, const char *);
108108
109109 /* Print the name of the file (and archive, if there is one)
110110 containing a symbol. */
@@ -1357,14 +1357,14 @@ display_file (char *filename)
13571357 /* Print the name of an object file given on the command line. */
13581358
13591359 static void
1360-print_object_filename_bsd (char *filename)
1360+print_object_filename_bsd (const char *filename)
13611361 {
13621362 if (filename_per_file && !filename_per_symbol)
13631363 printf ("\n%s:\n", filename);
13641364 }
13651365
13661366 static void
1367-print_object_filename_sysv (char *filename)
1367+print_object_filename_sysv (const char *filename)
13681368 {
13691369 if (undefined_only)
13701370 printf (_("\n\nUndefined symbols from %s:\n\n"), filename);
@@ -1379,7 +1379,7 @@ Name Value Class Type Size
13791379 }
13801380
13811381 static void
1382-print_object_filename_posix (char *filename)
1382+print_object_filename_posix (const char *filename)
13831383 {
13841384 if (filename_per_file && !filename_per_symbol)
13851385 printf ("%s:\n", filename);
@@ -1388,26 +1388,26 @@ print_object_filename_posix (char *filename)
13881388 /* Print the name of an archive file given on the command line. */
13891389
13901390 static void
1391-print_archive_filename_bsd (char *filename)
1391+print_archive_filename_bsd (const char *filename)
13921392 {
13931393 if (filename_per_file)
13941394 printf ("\n%s:\n", filename);
13951395 }
13961396
13971397 static void
1398-print_archive_filename_sysv (char *filename ATTRIBUTE_UNUSED)
1398+print_archive_filename_sysv (const char *filename ATTRIBUTE_UNUSED)
13991399 {
14001400 }
14011401
14021402 static void
1403-print_archive_filename_posix (char *filename ATTRIBUTE_UNUSED)
1403+print_archive_filename_posix (const char *filename ATTRIBUTE_UNUSED)
14041404 {
14051405 }
14061406
14071407 /* Print the name of an archive member file. */
14081408
14091409 static void
1410-print_archive_member_bsd (char *archive ATTRIBUTE_UNUSED,
1410+print_archive_member_bsd (const char *archive ATTRIBUTE_UNUSED,
14111411 const char *filename)
14121412 {
14131413 if (!filename_per_symbol)
@@ -1415,7 +1415,7 @@ print_archive_member_bsd (char *archive ATTRIBUTE_UNUSED,
14151415 }
14161416
14171417 static void
1418-print_archive_member_sysv (char *archive, const char *filename)
1418+print_archive_member_sysv (const char *archive, const char *filename)
14191419 {
14201420 if (undefined_only)
14211421 printf (_("\n\nUndefined symbols from %s[%s]:\n\n"), archive, filename);
@@ -1430,7 +1430,7 @@ Name Value Class Type Size
14301430 }
14311431
14321432 static void
1433-print_archive_member_posix (char *archive, const char *filename)
1433+print_archive_member_posix (const char *archive, const char *filename)
14341434 {
14351435 if (!filename_per_symbol)
14361436 printf ("%s[%s]:\n", archive, filename);
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -3311,7 +3311,7 @@ copy_archive (bfd *ibfd, bfd *obfd, const char *output_target,
33113311 }
33123312
33133313 /* Make a temp directory to hold the contents. */
3314- dir = make_tempdir (bfd_get_filename (obfd));
3314+ dir = make_tempdir ((char *) bfd_get_filename (obfd));
33153315 if (dir == NULL)
33163316 fatal (_("cannot create tempdir for archive copying (error: %s)"),
33173317 strerror (errno));
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,15 @@
1+2019-09-06 Alan Modra <amodra@gmail.com>
2+
3+ * coffread.c (coff_symfile_read): Constify filename variable.
4+ * dbxread.c (dbx_symfile_init, coffstab_build_psymtabs),
5+ (elfstab_build_psymtabs, stabsect_build_psymtabs): Likewise.
6+ * gdb_bfd.c (gdb_bfd_close_or_warn): Likewise.
7+ * solib.c (reload_shared_libraries_1): Likewise.
8+ * symfile.c (reread_symbols): Likewise.
9+ * solib-aix.c (solib_aix_bfd_open): Add cast for xfree of filename.
10+ * solib-darwin.c (darwin_bfd_open): Likewise.
11+ * symfile-mem.c (symbol_file_add_from_memory): Likewise.
12+
113 2019-09-03 Andrew Burgess <andrew.burgess@embecosm.com>
214
315 * psymtab.c (print_partial_symbols): Handle missing domain_enum
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -538,7 +538,7 @@ coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
538538 struct coff_symfile_info *info;
539539 bfd *abfd = objfile->obfd;
540540 coff_data_type *cdata = coff_data (abfd);
541- char *filename = bfd_get_filename (abfd);
541+ const char *filename = bfd_get_filename (abfd);
542542 int val;
543543 unsigned int num_symbols;
544544 int symtab_offset;
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -587,7 +587,7 @@ dbx_symfile_init (struct objfile *objfile)
587587 {
588588 int val;
589589 bfd *sym_bfd = objfile->obfd;
590- char *name = bfd_get_filename (sym_bfd);
590+ const char *name = bfd_get_filename (sym_bfd);
591591 asection *text_sect;
592592 unsigned char size_temp[DBX_STRINGTAB_SIZE_SIZE];
593593
@@ -2939,7 +2939,7 @@ coffstab_build_psymtabs (struct objfile *objfile,
29392939 {
29402940 int val;
29412941 bfd *sym_bfd = objfile->obfd;
2942- char *name = bfd_get_filename (sym_bfd);
2942+ const char *name = bfd_get_filename (sym_bfd);
29432943 unsigned int stabsize;
29442944
29452945 /* Allocate struct to keep track of stab reading. */
@@ -3026,7 +3026,7 @@ elfstab_build_psymtabs (struct objfile *objfile, asection *stabsect,
30263026 {
30273027 int val;
30283028 bfd *sym_bfd = objfile->obfd;
3029- char *name = bfd_get_filename (sym_bfd);
3029+ const char *name = bfd_get_filename (sym_bfd);
30303030
30313031 stabsread_new_init ();
30323032
@@ -3107,7 +3107,7 @@ stabsect_build_psymtabs (struct objfile *objfile, char *stab_name,
31073107 {
31083108 int val;
31093109 bfd *sym_bfd = objfile->obfd;
3110- char *name = bfd_get_filename (sym_bfd);
3110+ const char *name = bfd_get_filename (sym_bfd);
31113111 asection *stabsect;
31123112 asection *stabstrsect;
31133113 asection *text_sect;
--- a/gdb/gdb_bfd.c
+++ b/gdb/gdb_bfd.c
@@ -504,7 +504,7 @@ static int
504504 gdb_bfd_close_or_warn (struct bfd *abfd)
505505 {
506506 int ret;
507- char *name = bfd_get_filename (abfd);
507+ const char *name = bfd_get_filename (abfd);
508508
509509 bfd_map_over_sections (abfd, free_one_bfd_section, NULL);
510510
--- a/gdb/solib-aix.c
+++ b/gdb/solib-aix.c
@@ -643,9 +643,9 @@ solib_aix_bfd_open (const char *pathname)
643643 along with appended parenthesized member name in order to allow commands
644644 listing all shared libraries to display. Otherwise, we would only be
645645 displaying the name of the archive member object. */
646- xfree (bfd_get_filename (object_bfd.get ()));
646+ xfree ((char *) bfd_get_filename (object_bfd.get ()));
647647 object_bfd->filename = xstrprintf ("%s%s",
648- bfd_get_filename (archive_bfd.get ()),
648+ bfd_get_filename (archive_bfd.get ()),
649649 sep);
650650
651651 return object_bfd;
--- a/gdb/solib-darwin.c
+++ b/gdb/solib-darwin.c
@@ -670,7 +670,7 @@ darwin_bfd_open (const char *pathname)
670670 /* The current filename for fat-binary BFDs is a name generated
671671 by BFD, usually a string containing the name of the architecture.
672672 Reset its value to the actual filename. */
673- xfree (bfd_get_filename (res.get ()));
673+ xfree ((char *) bfd_get_filename (res.get ()));
674674 res->filename = xstrdup (pathname);
675675
676676 return res;
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -1296,7 +1296,7 @@ reload_shared_libraries_1 (int from_tty)
12961296
12971297 for (so = so_list_head; so != NULL; so = so->next)
12981298 {
1299- char *found_pathname = NULL;
1299+ const char *found_pathname = NULL;
13001300 int was_loaded = so->symbols_loaded;
13011301 symfile_add_flags add_flags = SYMFILE_DEFER_BP_RESET;
13021302
--- 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,
101101 /* Manage the new reference for the duration of this function. */
102102 gdb_bfd_ref_ptr nbfd_holder = gdb_bfd_ref_ptr::new_reference (nbfd);
103103
104- xfree (bfd_get_filename (nbfd));
104+ xfree ((char *) bfd_get_filename (nbfd));
105105 if (name == NULL)
106106 nbfd->filename = xstrdup ("shared object read from target memory");
107107 else
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -2548,7 +2548,7 @@ reread_symbols (void)
25482548 /* Clean up any state BFD has sitting around. */
25492549 {
25502550 gdb_bfd_ref_ptr obfd (objfile->obfd);
2551- char *obfd_filename;
2551+ const char *obfd_filename;
25522552
25532553 obfd_filename = bfd_get_filename (objfile->obfd);
25542554 /* Open the new BFD before freeing the old one, so that
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,10 @@
1+2019-09-06 Alan Modra <amodra@gmail.com>
2+
3+ * emultempl/elf32.em (gld${EMULATION_NAME}_search_needed): Constify
4+ variable.
5+ * emultempl/pe.em (gld_${EMULATION_NAME}_after_open): Likewise.
6+ * emultempl/pep.em (gld_${EMULATION_NAME}_after_open): Likewise.
7+
18 2019-09-05 Eric Botcazou <ebotcazou@adacore.com>
29
310 PR ld/24574
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -552,7 +552,7 @@ gld${EMULATION_NAME}_search_needed (const char *path,
552552 FIXME: The code could be a lot cleverer about allocating space
553553 for the processed string. */
554554 char * end = strchr (var, '/');
555- char * replacement = NULL;
555+ const char *replacement = NULL;
556556 char * v = var + 1;
557557 char * freeme = NULL;
558558 unsigned flen = strlen (filename);
--- a/ld/emultempl/pe.em
+++ b/ld/emultempl/pe.em
@@ -1513,7 +1513,7 @@ gld_${EMULATION_NAME}_after_open (void)
15131513 {
15141514 struct bfd_symbol *s;
15151515 struct bfd_link_hash_entry * blhe;
1516- char *other_bfd_filename;
1516+ const char *other_bfd_filename;
15171517 char *n;
15181518
15191519 s = (relocs[i]->sym_ptr_ptr)[0];
--- a/ld/emultempl/pep.em
+++ b/ld/emultempl/pep.em
@@ -1480,7 +1480,7 @@ gld_${EMULATION_NAME}_after_open (void)
14801480 {
14811481 struct bfd_symbol *s;
14821482 struct bfd_link_hash_entry * blhe;
1483- char *other_bfd_filename;
1483+ const char *other_bfd_filename;
14841484 char *n;
14851485
14861486 s = (relocs[i]->sym_ptr_ptr)[0];
--- a/sim/cris/ChangeLog
+++ b/sim/cris/ChangeLog
@@ -1,3 +1,7 @@
1+2019-09-06 Alan Modra <amodra@gmail.com>
2+
3+ * sim-if.c (sim_open): Constify filename variable.
4+
15 2018-12-06 Andrew Burgess <andrew.burgess@embecosm.com>
26
37 * Makefile.in: Replace uses of CGEN_CPU_DIR with CPU_DIR, and
--- 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,
746746 specified. */
747747 if (abfd != NULL && !cris_bare_iron)
748748 {
749- char *name = bfd_get_filename (abfd);
749+ const char *name = bfd_get_filename (abfd);
750750 char **my_environ = GET_ENVIRON ();
751751 /* We use these maps to give the same behavior as the old xsim
752752 simulator. */