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:
Alan Modra
2016-06-23 22:11:57 +09:30
parent 78da3bc1ee
commit 9cc0123fea
8 changed files with 81 additions and 44 deletions

View File

@@ -652,9 +652,11 @@ proc copy_executable { prog flags test1 test2 } {
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.
setup_xfail "mips*-*-elf" "tx39-*-*"
if { [is_bad_symtab] } then {
setup_xfail "*-*-*"
}
setup_xfail "arm*-*-coff"
setup_xfail "arm*-*-pe"
@@ -1102,18 +1104,9 @@ if [is_elf_format] {
# The symbol table for some MIPS targets is sorted differently than
# the ELF canonical order, so the regexps in localize-hidden-1.d fail
# to match. These tests must be matched to targets for which
# targ_defvec=mips_elf32_be_vec,
# targ_defvec=mips_elf32_le_vec,
# 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*"
# to match.
if { [is_bad_symtab] } then {
setup_xfail "*-*-*"
}
run_dump_test "localize-hidden-1"
run_dump_test "testranges"

View File

@@ -100,14 +100,10 @@ proc readelf_test { options binary_file regexp_file xfails } {
set target_machine ""
if [istarget "mips*-*-*"] then {
if { [istarget "mips*-*-*linux*"]
|| [istarget "mips*-sde-elf*"]
|| [istarget "mips*-mti-elf*"]
|| [istarget "mips*-img-elf*"]
|| [istarget "mips*-*freebsd*"] } then {
set target_machine tmips
} else {
if [is_bad_symtab] then {
set target_machine mips
} else {
set target_machine tmips
}
}

View File

@@ -99,7 +99,6 @@ if { ![do_objcopy update-1.o \
# Check that the updated object files are as expected.
do_compare update-1.o update-2.o
do_compare update-1.o update-3.o
setup_xfail "mips*-*-*" "tx39-*-*"
do_compare update-1.o update-4.o
# Check that --update-section on an unknown section will fail.