objcopy --extract-symbol testcase

Run the test for more than just ELF.  Shows that objcopy --extract-symbol
isn't working on PE, mips, mmix and some aout targets.

	* config/default.exp (size): New global.
	* ld-elf/extract-symbol-1.s,
	* ld-elf/extract-symbol-1.ld,
	* ld-elf/extract-symbol-1sec.d,
	* ld-elf/extract-symbol-1sym.d: Delete.
	* ld-scripts/script.exp (extract_symbol_test): New.
This commit is contained in:
Alan Modra
2015-10-15 21:34:39 +10:30
parent e43fb83166
commit 7b19bec22f
7 changed files with 44 additions and 65 deletions

View File

@@ -107,6 +107,35 @@ proc check_script { } {
}
}
proc extract_symbol_test { testfile testname } {
global objcopy
global nm
global size
set copyfile tmpdir/extract
set args "--extract-symbol $testfile $copyfile"
set exec_output [run_host_cmd $objcopy $args]
if ![string equal "" $exec_output] {
fail $testname
return
}
set orig_syms [run_host_cmd $nm $testfile]
set extract_syms [run_host_cmd $nm $copyfile]
if ![string equal $orig_syms $extract_syms] {
fail $testname
return
}
set exec_output [run_host_cmd $size $copyfile]
if ![regexp ".* 0\[ \]+0\[ \]+0\[ \]+0\[ \]+0\[ \]+.*" $exec_output] {
fail $testname
return
}
pass $testname
}
# PE targets need to set the image base to 0 to avoid complications from nm.
set flags ""
if {[istarget "*-*-pe*"] \
@@ -143,8 +172,10 @@ if ![ld_simple_link $ld tmpdir/script "$flags -T $srcdir/$subdir/memory.t tmpdir
set testname "MEMORY with symbols"
if ![ld_simple_link $ld tmpdir/script "$flags -defsym DATA_ORIGIN=0x1000 -defsym DATA_LENGTH=0x10000 -T $srcdir/$subdir/memory_sym.t tmpdir/script.o"] {
fail $testname
untested "extract symbols"
} else {
check_script
extract_symbol_test tmpdir/script "extract symbols"
}
set test_script_list [lsort [glob $srcdir/$subdir/region-alias-*.t]]