GNU Binutils with patches for OS216
Revision | b16c44debcf8a446e94e161e328169f5c8d5d811 (tree) |
---|---|
Time | 2019-09-06 11:52:59 |
Author | Alan Modra <amodra@gmai...> |
Commiter | Alan Modra |
bfd_get_filename
This macro says:
/* Cast from const char * to char * so that caller can assign to
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.
@@ -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 | + | |
1 | 9 | 2019-09-05 Alan Modra <amodra@gmail.com> |
2 | 10 | |
3 | 11 | * elf64-ppc.c (ppc64_elf_check_relocs): Interpret an addend in |
@@ -180,7 +180,7 @@ MY (object_p) (bfd *abfd) | ||
180 | 180 | #ifndef S_IXUSR |
181 | 181 | #define S_IXUSR 0100 /* Execute by owner. */ |
182 | 182 | #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)) | |
184 | 184 | abfd->flags |= EXEC_P; |
185 | 185 | } |
186 | 186 | #endif /* ENTRY_CAN_BE_ZERO */ |
@@ -518,9 +518,7 @@ extern int bfd_stat (bfd *, struct stat *); | ||
518 | 518 | #endif |
519 | 519 | extern void _bfd_warn_deprecated (const char *, const char *, int, const char *); |
520 | 520 | |
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) | |
524 | 522 | #define bfd_get_cacheable(abfd) ((abfd)->cacheable) |
525 | 523 | #define bfd_get_format(abfd) ((abfd)->format) |
526 | 524 | #define bfd_get_target(abfd) ((abfd)->xvec->name) |
@@ -525,9 +525,7 @@ extern int bfd_stat (bfd *, struct stat *); | ||
525 | 525 | #endif |
526 | 526 | extern void _bfd_warn_deprecated (const char *, const char *, int, const char *); |
527 | 527 | |
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) | |
531 | 529 | #define bfd_get_cacheable(abfd) ((abfd)->cacheable) |
532 | 530 | #define bfd_get_format(abfd) ((abfd)->format) |
533 | 531 | #define bfd_get_target(abfd) ((abfd)->xvec->name) |
@@ -157,9 +157,9 @@ DESCRIPTION | ||
157 | 157 | bfd_boolean |
158 | 158 | generic_core_file_matches_executable_p (bfd *core_bfd, bfd *exec_bfd) |
159 | 159 | { |
160 | - char *exec; | |
161 | - char *core; | |
162 | - char *last_slash; | |
160 | + const char *exec; | |
161 | + const char *core; | |
162 | + const char *last_slash; | |
163 | 163 | |
164 | 164 | if (exec_bfd == NULL || core_bfd == NULL) |
165 | 165 | return TRUE; |
@@ -169,7 +169,7 @@ generic_core_file_matches_executable_p (bfd *core_bfd, bfd *exec_bfd) | ||
169 | 169 | non-const char *. In this case, the assignement does not lead to |
170 | 170 | breaking the const, as we're only reading the string. */ |
171 | 171 | |
172 | - core = (char *) bfd_core_file_failing_command (core_bfd); | |
172 | + core = bfd_core_file_failing_command (core_bfd); | |
173 | 173 | if (core == NULL) |
174 | 174 | return TRUE; |
175 | 175 |
@@ -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 | + | |
1 | 12 | 2019-08-29 Alan Modra <amodra@gmail.com> |
2 | 13 | |
3 | 14 | * dwarf.c (check_uvalue): Remove unnecessary pointer checks. |
@@ -77,15 +77,15 @@ struct extended_symbol_info | ||
77 | 77 | (sym->elfinfo ? sym->elfinfo->internal_elf_sym.st_size: sym->ssize) |
78 | 78 | |
79 | 79 | /* 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 *); | |
89 | 89 | static void print_symbol_filename_bsd (bfd *, bfd *); |
90 | 90 | static void print_symbol_filename_sysv (bfd *, bfd *); |
91 | 91 | static void print_symbol_filename_posix (bfd *, bfd *); |
@@ -98,13 +98,13 @@ static void print_symbol_info_posix (struct extended_symbol_info *, bfd *); | ||
98 | 98 | struct output_fns |
99 | 99 | { |
100 | 100 | /* 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 *); | |
102 | 102 | |
103 | 103 | /* 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 *); | |
105 | 105 | |
106 | 106 | /* 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 *); | |
108 | 108 | |
109 | 109 | /* Print the name of the file (and archive, if there is one) |
110 | 110 | containing a symbol. */ |
@@ -1357,14 +1357,14 @@ display_file (char *filename) | ||
1357 | 1357 | /* Print the name of an object file given on the command line. */ |
1358 | 1358 | |
1359 | 1359 | static void |
1360 | -print_object_filename_bsd (char *filename) | |
1360 | +print_object_filename_bsd (const char *filename) | |
1361 | 1361 | { |
1362 | 1362 | if (filename_per_file && !filename_per_symbol) |
1363 | 1363 | printf ("\n%s:\n", filename); |
1364 | 1364 | } |
1365 | 1365 | |
1366 | 1366 | static void |
1367 | -print_object_filename_sysv (char *filename) | |
1367 | +print_object_filename_sysv (const char *filename) | |
1368 | 1368 | { |
1369 | 1369 | if (undefined_only) |
1370 | 1370 | printf (_("\n\nUndefined symbols from %s:\n\n"), filename); |
@@ -1379,7 +1379,7 @@ Name Value Class Type Size | ||
1379 | 1379 | } |
1380 | 1380 | |
1381 | 1381 | static void |
1382 | -print_object_filename_posix (char *filename) | |
1382 | +print_object_filename_posix (const char *filename) | |
1383 | 1383 | { |
1384 | 1384 | if (filename_per_file && !filename_per_symbol) |
1385 | 1385 | printf ("%s:\n", filename); |
@@ -1388,26 +1388,26 @@ print_object_filename_posix (char *filename) | ||
1388 | 1388 | /* Print the name of an archive file given on the command line. */ |
1389 | 1389 | |
1390 | 1390 | static void |
1391 | -print_archive_filename_bsd (char *filename) | |
1391 | +print_archive_filename_bsd (const char *filename) | |
1392 | 1392 | { |
1393 | 1393 | if (filename_per_file) |
1394 | 1394 | printf ("\n%s:\n", filename); |
1395 | 1395 | } |
1396 | 1396 | |
1397 | 1397 | static void |
1398 | -print_archive_filename_sysv (char *filename ATTRIBUTE_UNUSED) | |
1398 | +print_archive_filename_sysv (const char *filename ATTRIBUTE_UNUSED) | |
1399 | 1399 | { |
1400 | 1400 | } |
1401 | 1401 | |
1402 | 1402 | static void |
1403 | -print_archive_filename_posix (char *filename ATTRIBUTE_UNUSED) | |
1403 | +print_archive_filename_posix (const char *filename ATTRIBUTE_UNUSED) | |
1404 | 1404 | { |
1405 | 1405 | } |
1406 | 1406 | |
1407 | 1407 | /* Print the name of an archive member file. */ |
1408 | 1408 | |
1409 | 1409 | static void |
1410 | -print_archive_member_bsd (char *archive ATTRIBUTE_UNUSED, | |
1410 | +print_archive_member_bsd (const char *archive ATTRIBUTE_UNUSED, | |
1411 | 1411 | const char *filename) |
1412 | 1412 | { |
1413 | 1413 | if (!filename_per_symbol) |
@@ -1415,7 +1415,7 @@ print_archive_member_bsd (char *archive ATTRIBUTE_UNUSED, | ||
1415 | 1415 | } |
1416 | 1416 | |
1417 | 1417 | static void |
1418 | -print_archive_member_sysv (char *archive, const char *filename) | |
1418 | +print_archive_member_sysv (const char *archive, const char *filename) | |
1419 | 1419 | { |
1420 | 1420 | if (undefined_only) |
1421 | 1421 | printf (_("\n\nUndefined symbols from %s[%s]:\n\n"), archive, filename); |
@@ -1430,7 +1430,7 @@ Name Value Class Type Size | ||
1430 | 1430 | } |
1431 | 1431 | |
1432 | 1432 | static void |
1433 | -print_archive_member_posix (char *archive, const char *filename) | |
1433 | +print_archive_member_posix (const char *archive, const char *filename) | |
1434 | 1434 | { |
1435 | 1435 | if (!filename_per_symbol) |
1436 | 1436 | printf ("%s[%s]:\n", archive, filename); |
@@ -3311,7 +3311,7 @@ copy_archive (bfd *ibfd, bfd *obfd, const char *output_target, | ||
3311 | 3311 | } |
3312 | 3312 | |
3313 | 3313 | /* 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)); | |
3315 | 3315 | if (dir == NULL) |
3316 | 3316 | fatal (_("cannot create tempdir for archive copying (error: %s)"), |
3317 | 3317 | strerror (errno)); |
@@ -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 | + | |
1 | 13 | 2019-09-03 Andrew Burgess <andrew.burgess@embecosm.com> |
2 | 14 | |
3 | 15 | * psymtab.c (print_partial_symbols): Handle missing domain_enum |
@@ -538,7 +538,7 @@ coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags) | ||
538 | 538 | struct coff_symfile_info *info; |
539 | 539 | bfd *abfd = objfile->obfd; |
540 | 540 | coff_data_type *cdata = coff_data (abfd); |
541 | - char *filename = bfd_get_filename (abfd); | |
541 | + const char *filename = bfd_get_filename (abfd); | |
542 | 542 | int val; |
543 | 543 | unsigned int num_symbols; |
544 | 544 | int symtab_offset; |
@@ -587,7 +587,7 @@ dbx_symfile_init (struct objfile *objfile) | ||
587 | 587 | { |
588 | 588 | int val; |
589 | 589 | bfd *sym_bfd = objfile->obfd; |
590 | - char *name = bfd_get_filename (sym_bfd); | |
590 | + const char *name = bfd_get_filename (sym_bfd); | |
591 | 591 | asection *text_sect; |
592 | 592 | unsigned char size_temp[DBX_STRINGTAB_SIZE_SIZE]; |
593 | 593 |
@@ -2939,7 +2939,7 @@ coffstab_build_psymtabs (struct objfile *objfile, | ||
2939 | 2939 | { |
2940 | 2940 | int val; |
2941 | 2941 | bfd *sym_bfd = objfile->obfd; |
2942 | - char *name = bfd_get_filename (sym_bfd); | |
2942 | + const char *name = bfd_get_filename (sym_bfd); | |
2943 | 2943 | unsigned int stabsize; |
2944 | 2944 | |
2945 | 2945 | /* Allocate struct to keep track of stab reading. */ |
@@ -3026,7 +3026,7 @@ elfstab_build_psymtabs (struct objfile *objfile, asection *stabsect, | ||
3026 | 3026 | { |
3027 | 3027 | int val; |
3028 | 3028 | bfd *sym_bfd = objfile->obfd; |
3029 | - char *name = bfd_get_filename (sym_bfd); | |
3029 | + const char *name = bfd_get_filename (sym_bfd); | |
3030 | 3030 | |
3031 | 3031 | stabsread_new_init (); |
3032 | 3032 |
@@ -3107,7 +3107,7 @@ stabsect_build_psymtabs (struct objfile *objfile, char *stab_name, | ||
3107 | 3107 | { |
3108 | 3108 | int val; |
3109 | 3109 | bfd *sym_bfd = objfile->obfd; |
3110 | - char *name = bfd_get_filename (sym_bfd); | |
3110 | + const char *name = bfd_get_filename (sym_bfd); | |
3111 | 3111 | asection *stabsect; |
3112 | 3112 | asection *stabstrsect; |
3113 | 3113 | asection *text_sect; |
@@ -504,7 +504,7 @@ static int | ||
504 | 504 | gdb_bfd_close_or_warn (struct bfd *abfd) |
505 | 505 | { |
506 | 506 | int ret; |
507 | - char *name = bfd_get_filename (abfd); | |
507 | + const char *name = bfd_get_filename (abfd); | |
508 | 508 | |
509 | 509 | bfd_map_over_sections (abfd, free_one_bfd_section, NULL); |
510 | 510 |
@@ -643,9 +643,9 @@ solib_aix_bfd_open (const char *pathname) | ||
643 | 643 | along with appended parenthesized member name in order to allow commands |
644 | 644 | listing all shared libraries to display. Otherwise, we would only be |
645 | 645 | 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 ())); | |
647 | 647 | object_bfd->filename = xstrprintf ("%s%s", |
648 | - bfd_get_filename (archive_bfd.get ()), | |
648 | + bfd_get_filename (archive_bfd.get ()), | |
649 | 649 | sep); |
650 | 650 | |
651 | 651 | return object_bfd; |
@@ -670,7 +670,7 @@ darwin_bfd_open (const char *pathname) | ||
670 | 670 | /* The current filename for fat-binary BFDs is a name generated |
671 | 671 | by BFD, usually a string containing the name of the architecture. |
672 | 672 | Reset its value to the actual filename. */ |
673 | - xfree (bfd_get_filename (res.get ())); | |
673 | + xfree ((char *) bfd_get_filename (res.get ())); | |
674 | 674 | res->filename = xstrdup (pathname); |
675 | 675 | |
676 | 676 | return res; |
@@ -1296,7 +1296,7 @@ reload_shared_libraries_1 (int from_tty) | ||
1296 | 1296 | |
1297 | 1297 | for (so = so_list_head; so != NULL; so = so->next) |
1298 | 1298 | { |
1299 | - char *found_pathname = NULL; | |
1299 | + const char *found_pathname = NULL; | |
1300 | 1300 | int was_loaded = so->symbols_loaded; |
1301 | 1301 | symfile_add_flags add_flags = SYMFILE_DEFER_BP_RESET; |
1302 | 1302 |
@@ -101,7 +101,7 @@ symbol_file_add_from_memory (struct bfd *templ, CORE_ADDR addr, | ||
101 | 101 | /* Manage the new reference for the duration of this function. */ |
102 | 102 | gdb_bfd_ref_ptr nbfd_holder = gdb_bfd_ref_ptr::new_reference (nbfd); |
103 | 103 | |
104 | - xfree (bfd_get_filename (nbfd)); | |
104 | + xfree ((char *) bfd_get_filename (nbfd)); | |
105 | 105 | if (name == NULL) |
106 | 106 | nbfd->filename = xstrdup ("shared object read from target memory"); |
107 | 107 | else |
@@ -2548,7 +2548,7 @@ reread_symbols (void) | ||
2548 | 2548 | /* Clean up any state BFD has sitting around. */ |
2549 | 2549 | { |
2550 | 2550 | gdb_bfd_ref_ptr obfd (objfile->obfd); |
2551 | - char *obfd_filename; | |
2551 | + const char *obfd_filename; | |
2552 | 2552 | |
2553 | 2553 | obfd_filename = bfd_get_filename (objfile->obfd); |
2554 | 2554 | /* Open the new BFD before freeing the old one, so that |
@@ -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 | + | |
1 | 8 | 2019-09-05 Eric Botcazou <ebotcazou@adacore.com> |
2 | 9 | |
3 | 10 | PR ld/24574 |
@@ -552,7 +552,7 @@ gld${EMULATION_NAME}_search_needed (const char *path, | ||
552 | 552 | FIXME: The code could be a lot cleverer about allocating space |
553 | 553 | for the processed string. */ |
554 | 554 | char * end = strchr (var, '/'); |
555 | - char * replacement = NULL; | |
555 | + const char *replacement = NULL; | |
556 | 556 | char * v = var + 1; |
557 | 557 | char * freeme = NULL; |
558 | 558 | unsigned flen = strlen (filename); |
@@ -1513,7 +1513,7 @@ gld_${EMULATION_NAME}_after_open (void) | ||
1513 | 1513 | { |
1514 | 1514 | struct bfd_symbol *s; |
1515 | 1515 | struct bfd_link_hash_entry * blhe; |
1516 | - char *other_bfd_filename; | |
1516 | + const char *other_bfd_filename; | |
1517 | 1517 | char *n; |
1518 | 1518 | |
1519 | 1519 | s = (relocs[i]->sym_ptr_ptr)[0]; |
@@ -1480,7 +1480,7 @@ gld_${EMULATION_NAME}_after_open (void) | ||
1480 | 1480 | { |
1481 | 1481 | struct bfd_symbol *s; |
1482 | 1482 | struct bfd_link_hash_entry * blhe; |
1483 | - char *other_bfd_filename; | |
1483 | + const char *other_bfd_filename; | |
1484 | 1484 | char *n; |
1485 | 1485 | |
1486 | 1486 | s = (relocs[i]->sym_ptr_ptr)[0]; |
@@ -1,3 +1,7 @@ | ||
1 | +2019-09-06 Alan Modra <amodra@gmail.com> | |
2 | + | |
3 | + * sim-if.c (sim_open): Constify filename variable. | |
4 | + | |
1 | 5 | 2018-12-06 Andrew Burgess <andrew.burgess@embecosm.com> |
2 | 6 | |
3 | 7 | * Makefile.in: Replace uses of CGEN_CPU_DIR with CPU_DIR, and |
@@ -746,7 +746,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback, struct bfd *abfd, | ||
746 | 746 | specified. */ |
747 | 747 | if (abfd != NULL && !cris_bare_iron) |
748 | 748 | { |
749 | - char *name = bfd_get_filename (abfd); | |
749 | + const char *name = bfd_get_filename (abfd); | |
750 | 750 | char **my_environ = GET_ENVIRON (); |
751 | 751 | /* We use these maps to give the same behavior as the old xsim |
752 | 752 | simulator. */ |