mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-26 13:56:22 +08:00
MIPS objcopy --rename-section fix
Some MIPS targets use a named section symbol rather than a symbol with no name as is used with most ELF targets. When renaming sections, the named section symbol needs to be renamed too. Rather than fix this bug, I'd originally intended to just correct the xfail added recently for update-1.o vs update4.o in update-section.exp, using the same set of targets for the localize-hidden-1 mips xfail. I'd extracted that target test into a new function, is_bad_symtab. It turns out to be useful in readelf.exp too. bfd/ * config.bfd: Delete mips vxworks patterns matched earlier. Combine mips*-*-none with mips*-*-elf*. binutils/ * objcopy.c (find_section_rename): Forward declare. Remove ibfd and sec_ptr param. Add old_name param. Allow for NULL returned_flags. Move read of section name and flags to.. (setup_section): ..here. Update find_section_rename call. (filter_symbols): Rename section symbols for renamed sections. (copy_object): Call filter_symbols when renamed sections. * testsuite/lib/binutils-common.exp (is_bad_symtab): New. * testsuite/binutils-all/update-section.exp: Revert 96037eb0 mips xfail. * testsuite/binutils-all/objcopy.exp (copy_executable): Use is_bad_symtab. (localize-hidden-1): xfail if is_bad_symtab. * testsuite/binutils-all/readelf.exp: Use is_bad_symtab to select between mips/tmips.
This commit is contained in:
@ -1,3 +1,8 @@
|
|||||||
|
2016-06-24 Alan Modra <amodra@gmail.com>
|
||||||
|
|
||||||
|
* config.bfd: Delete mips vxworks patterns matched earlier.
|
||||||
|
Combine mips*-*-none with mips*-*-elf*.
|
||||||
|
|
||||||
2016-06-21 Maciej W. Rozycki <macro@imgtec.com>
|
2016-06-21 Maciej W. Rozycki <macro@imgtec.com>
|
||||||
|
|
||||||
* elfxx-mips.c (mips_elf_perform_relocation): Call
|
* elfxx-mips.c (mips_elf_perform_relocation): Call
|
||||||
|
@ -1080,15 +1080,11 @@ case "${targ}" in
|
|||||||
targ_defvec=mips_elf32_trad_be_vec
|
targ_defvec=mips_elf32_trad_be_vec
|
||||||
targ_selvecs="mips_elf32_trad_le_vec mips_elf32_ntrad_be_vec mips_elf32_ntrad_le_vec mips_elf64_trad_be_vec mips_elf64_trad_le_vec"
|
targ_selvecs="mips_elf32_trad_le_vec mips_elf32_ntrad_be_vec mips_elf32_ntrad_le_vec mips_elf64_trad_be_vec mips_elf64_trad_le_vec"
|
||||||
;;
|
;;
|
||||||
mips*el-*-elf* | mips*el-*-vxworks* | mips*-*-chorus*)
|
mips*el-*-elf* | mips*-*-chorus*)
|
||||||
targ_defvec=mips_elf32_le_vec
|
targ_defvec=mips_elf32_le_vec
|
||||||
targ_selvecs="mips_elf32_be_vec mips_elf64_be_vec mips_elf64_le_vec"
|
targ_selvecs="mips_elf32_be_vec mips_elf64_be_vec mips_elf64_le_vec"
|
||||||
;;
|
;;
|
||||||
mips*-*-elf* | mips*-*-rtems* | mips*-*-vxworks | mips*-*-windiss)
|
mips*-*-elf* | mips*-*-rtems* | mips*-*-windiss | mips*-*-none)
|
||||||
targ_defvec=mips_elf32_be_vec
|
|
||||||
targ_selvecs="mips_elf32_le_vec mips_elf64_be_vec mips_elf64_le_vec"
|
|
||||||
;;
|
|
||||||
mips*-*-none)
|
|
||||||
targ_defvec=mips_elf32_be_vec
|
targ_defvec=mips_elf32_be_vec
|
||||||
targ_selvecs="mips_elf32_le_vec mips_elf64_be_vec mips_elf64_le_vec"
|
targ_selvecs="mips_elf32_le_vec mips_elf64_be_vec mips_elf64_le_vec"
|
||||||
;;
|
;;
|
||||||
|
@ -1,3 +1,20 @@
|
|||||||
|
2016-06-24 Alan Modra <amodra@gmail.com>
|
||||||
|
|
||||||
|
* objcopy.c (find_section_rename): Forward declare. Remove
|
||||||
|
ibfd and sec_ptr param. Add old_name param. Allow for NULL
|
||||||
|
returned_flags. Move read of section name and flags to..
|
||||||
|
(setup_section): ..here. Update find_section_rename call.
|
||||||
|
(filter_symbols): Rename section symbols for renamed sections.
|
||||||
|
(copy_object): Call filter_symbols when renamed sections.
|
||||||
|
* testsuite/lib/binutils-common.exp (is_bad_symtab): New.
|
||||||
|
* testsuite/binutils-all/update-section.exp: Revert 96037eb0
|
||||||
|
mips xfail.
|
||||||
|
* testsuite/binutils-all/objcopy.exp (copy_executable): Use
|
||||||
|
is_bad_symtab.
|
||||||
|
(localize-hidden-1): xfail if is_bad_symtab.
|
||||||
|
* testsuite/binutils-all/readelf.exp: Use is_bad_symtab to select
|
||||||
|
between mips/tmips.
|
||||||
|
|
||||||
2016-06-24 Alan Modra <amodra@gmail.com>
|
2016-06-24 Alan Modra <amodra@gmail.com>
|
||||||
|
|
||||||
* objdump.c (struct print_file_list): Add "max_printed".
|
* objdump.c (struct print_file_list): Add "max_printed".
|
||||||
|
@ -507,6 +507,7 @@ static int compare_section_lma (const void *, const void *);
|
|||||||
static void mark_symbols_used_in_relocations (bfd *, asection *, void *);
|
static void mark_symbols_used_in_relocations (bfd *, asection *, void *);
|
||||||
static bfd_boolean write_debugging_info (bfd *, void *, long *, asymbol ***);
|
static bfd_boolean write_debugging_info (bfd *, void *, long *, asymbol ***);
|
||||||
static const char *lookup_sym_redefinition (const char *);
|
static const char *lookup_sym_redefinition (const char *);
|
||||||
|
static const char *find_section_rename (const char *, flagword *);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
copy_usage (FILE *stream, int exit_status)
|
copy_usage (FILE *stream, int exit_status)
|
||||||
@ -1390,12 +1391,14 @@ filter_symbols (bfd *abfd, bfd *obfd, asymbol **osyms,
|
|||||||
to[dst_count++] = create_new_symbol (ptr, obfd);
|
to[dst_count++] = create_new_symbol (ptr, obfd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (redefine_sym_list)
|
if (redefine_sym_list || section_rename_list)
|
||||||
{
|
{
|
||||||
char *old_name, *new_name;
|
char *new_name;
|
||||||
|
|
||||||
old_name = (char *) bfd_asymbol_name (sym);
|
new_name = (char *) lookup_sym_redefinition (name);
|
||||||
new_name = (char *) lookup_sym_redefinition (old_name);
|
if (new_name == name
|
||||||
|
&& (flags & BSF_SECTION_SYM) != 0)
|
||||||
|
new_name = (char *) find_section_rename (name, NULL);
|
||||||
bfd_asymbol_name (sym) = new_name;
|
bfd_asymbol_name (sym) = new_name;
|
||||||
name = new_name;
|
name = new_name;
|
||||||
}
|
}
|
||||||
@ -2357,6 +2360,7 @@ copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch)
|
|||||||
|| change_leading_char
|
|| change_leading_char
|
||||||
|| remove_leading_char
|
|| remove_leading_char
|
||||||
|| redefine_sym_list
|
|| redefine_sym_list
|
||||||
|
|| section_rename_list
|
||||||
|| weaken
|
|| weaken
|
||||||
|| add_symbols)
|
|| add_symbols)
|
||||||
{
|
{
|
||||||
@ -2937,24 +2941,19 @@ add_section_rename (const char * old_name, const char * new_name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Check the section rename list for a new name of the input section
|
/* Check the section rename list for a new name of the input section
|
||||||
ISECTION. Return the new name if one is found.
|
called OLD_NAME. Returns the new name if one is found and sets
|
||||||
Also set RETURNED_FLAGS to the flags to be used for this section. */
|
RETURNED_FLAGS if non-NULL to the flags to be used for this section. */
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
find_section_rename (bfd * ibfd ATTRIBUTE_UNUSED, sec_ptr isection,
|
find_section_rename (const char *old_name, flagword *returned_flags)
|
||||||
flagword * returned_flags)
|
|
||||||
{
|
{
|
||||||
const char * old_name = bfd_section_name (ibfd, isection);
|
const section_rename *srename;
|
||||||
section_rename * srename;
|
|
||||||
|
|
||||||
/* Default to using the flags of the input section. */
|
|
||||||
* returned_flags = bfd_get_section_flags (ibfd, isection);
|
|
||||||
|
|
||||||
for (srename = section_rename_list; srename != NULL; srename = srename->next)
|
for (srename = section_rename_list; srename != NULL; srename = srename->next)
|
||||||
if (strcmp (srename->old_name, old_name) == 0)
|
if (strcmp (srename->old_name, old_name) == 0)
|
||||||
{
|
{
|
||||||
if (srename->flags != (flagword) -1)
|
if (returned_flags != NULL && srename->flags != (flagword) -1)
|
||||||
* returned_flags = srename->flags;
|
*returned_flags = srename->flags;
|
||||||
|
|
||||||
return srename->new_name;
|
return srename->new_name;
|
||||||
}
|
}
|
||||||
@ -3004,7 +3003,9 @@ setup_section (bfd *ibfd, sec_ptr isection, void *obfdarg)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
/* Get the, possibly new, name of the output section. */
|
/* Get the, possibly new, name of the output section. */
|
||||||
name = find_section_rename (ibfd, isection, & flags);
|
name = bfd_section_name (ibfd, isection);
|
||||||
|
flags = bfd_get_section_flags (ibfd, isection);
|
||||||
|
name = find_section_rename (name, &flags);
|
||||||
|
|
||||||
/* Prefix sections. */
|
/* Prefix sections. */
|
||||||
if ((prefix_alloc_sections_string)
|
if ((prefix_alloc_sections_string)
|
||||||
|
@ -652,9 +652,11 @@ proc copy_executable { prog flags test1 test2 } {
|
|||||||
setup_xfail "*-*-*"
|
setup_xfail "*-*-*"
|
||||||
}
|
}
|
||||||
|
|
||||||
# This also fails for mips*-*-elf targets. See elf32-mips.c
|
# This also fails for some mips targets. See elf32-mips.c
|
||||||
# mips_elf_sym_is_global.
|
# mips_elf_sym_is_global.
|
||||||
setup_xfail "mips*-*-elf" "tx39-*-*"
|
if { [is_bad_symtab] } then {
|
||||||
|
setup_xfail "*-*-*"
|
||||||
|
}
|
||||||
|
|
||||||
setup_xfail "arm*-*-coff"
|
setup_xfail "arm*-*-coff"
|
||||||
setup_xfail "arm*-*-pe"
|
setup_xfail "arm*-*-pe"
|
||||||
@ -1102,18 +1104,9 @@ if [is_elf_format] {
|
|||||||
|
|
||||||
# The symbol table for some MIPS targets is sorted differently than
|
# The symbol table for some MIPS targets is sorted differently than
|
||||||
# the ELF canonical order, so the regexps in localize-hidden-1.d fail
|
# the ELF canonical order, so the regexps in localize-hidden-1.d fail
|
||||||
# to match. These tests must be matched to targets for which
|
# to match.
|
||||||
# targ_defvec=mips_elf32_be_vec,
|
if { [is_bad_symtab] } then {
|
||||||
# targ_defvec=mips_elf32_le_vec,
|
setup_xfail "*-*-*"
|
||||||
# targ_defvec=mips_elf32_n_be_vec or
|
|
||||||
# targ_defvec=mips_elf32_n_le_vec in config.bfd. When syncing,
|
|
||||||
# don't forget that earlier case-matches trump later ones.
|
|
||||||
if { ![istarget "mips*-sde-elf*"] && ![istarget "mips*-mti-elf*"]
|
|
||||||
&& ![istarget "mips*-img-elf*"]
|
|
||||||
&& ![istarget "mips64*-*-openbsd*"] } {
|
|
||||||
setup_xfail "mips*-*-irix5*" "mips*-*-irix6*" "mips*-*-elf*" \
|
|
||||||
"mips*-*-rtems*" "mips*-*-windiss" "mips*-*-none" \
|
|
||||||
"mips*-*-openbsd*" "mips*-*-chorus*"
|
|
||||||
}
|
}
|
||||||
run_dump_test "localize-hidden-1"
|
run_dump_test "localize-hidden-1"
|
||||||
run_dump_test "testranges"
|
run_dump_test "testranges"
|
||||||
|
@ -100,14 +100,10 @@ proc readelf_test { options binary_file regexp_file xfails } {
|
|||||||
|
|
||||||
set target_machine ""
|
set target_machine ""
|
||||||
if [istarget "mips*-*-*"] then {
|
if [istarget "mips*-*-*"] then {
|
||||||
if { [istarget "mips*-*-*linux*"]
|
if [is_bad_symtab] then {
|
||||||
|| [istarget "mips*-sde-elf*"]
|
|
||||||
|| [istarget "mips*-mti-elf*"]
|
|
||||||
|| [istarget "mips*-img-elf*"]
|
|
||||||
|| [istarget "mips*-*freebsd*"] } then {
|
|
||||||
set target_machine tmips
|
|
||||||
} else {
|
|
||||||
set target_machine mips
|
set target_machine mips
|
||||||
|
} else {
|
||||||
|
set target_machine tmips
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,7 +99,6 @@ if { ![do_objcopy update-1.o \
|
|||||||
# Check that the updated object files are as expected.
|
# Check that the updated object files are as expected.
|
||||||
do_compare update-1.o update-2.o
|
do_compare update-1.o update-2.o
|
||||||
do_compare update-1.o update-3.o
|
do_compare update-1.o update-3.o
|
||||||
setup_xfail "mips*-*-*" "tx39-*-*"
|
|
||||||
do_compare update-1.o update-4.o
|
do_compare update-1.o update-4.o
|
||||||
|
|
||||||
# Check that --update-section on an unknown section will fail.
|
# Check that --update-section on an unknown section will fail.
|
||||||
|
@ -202,6 +202,36 @@ proc supports_gnu_unique {} {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# True for targets that do not sort .symtab as per the ELF standard.
|
||||||
|
# ie. any that have mips_elf32_be_vec, mips_elf32_le_vec,
|
||||||
|
# mips_elf32_n_be_vec or mips_elf32_n_le_vec as the primary bfd target
|
||||||
|
# vector in config.bfd. When syncing with config.bfd, don't forget that
|
||||||
|
# earlier case-matches trump later ones.
|
||||||
|
proc is_bad_symtab {} {
|
||||||
|
if { ![istarget "mips*-*-*"] } {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if { [istarget "*-*-chorus*"]
|
||||||
|
|| [istarget "*-*-irix5*"]
|
||||||
|
|| [istarget "*-*-irix6*"]
|
||||||
|
|| [istarget "*-*-none"]
|
||||||
|
|| [istarget "*-*-rtems*"]
|
||||||
|
|| [istarget "*-*-windiss"] } {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if { [istarget "*-*-elf*"]
|
||||||
|
&& ![istarget "*-sde-*"]
|
||||||
|
&& ![istarget "*-mti-*"]
|
||||||
|
&& ![istarget "*-img-*"] } {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if { [istarget "*-*-openbsd*"]
|
||||||
|
&& ![istarget "mips64*-*-*"] } {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
# Compare two files line-by-line. FILE_1 is the actual output and FILE_2
|
# Compare two files line-by-line. FILE_1 is the actual output and FILE_2
|
||||||
# is the expected output. Ignore blank lines in either file.
|
# is the expected output. Ignore blank lines in either file.
|
||||||
#
|
#
|
||||||
|
Reference in New Issue
Block a user