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

@ -1,3 +1,12 @@
2015-10-15 Alan Modra <amodra@gmail.com>
* 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.
2015-10-12 H.J. Lu <hongjiu.lu@intel.com>
PR ld/19073

View File

@ -49,6 +49,10 @@ if ![info exists strip] then {
set strip [findfile $base_dir/../binutils/strip-new $base_dir/../binutils/strip-new [transform strip]]
}
if ![info exists size] then {
set size [findfile $base_dir/../binutils/size]
}
remote_exec host "mkdir -p tmpdir"
# Make symlinks from tmpdir/ld to the linker and assembler in the

View File

@ -1,18 +0,0 @@
ENTRY(_entry)
PHDRS
{
data PT_LOAD AT (0);
}
SECTIONS
{
. = 0x10000;
.foo : { *(.foo) } :data
. = 0x20000;
.bar : { *(.bar) } :data
/DISCARD/ : { *(*) }
_entry = 0x30000;
linker_symbol = 0x40000;
}

View File

@ -1,15 +0,0 @@
.globl B
.globl C
.section .foo,"awx",%progbits
.4byte 1,2,3,4
B:
.4byte 5,6,7
.section .bar,"ax",%nobits
.space 0x123
C:
.space 0x302
.globl D
.equ D,0x12345678

View File

@ -1,15 +0,0 @@
#name: --extract-symbol test 1 (sections)
#source: extract-symbol-1.s
#ld: -Textract-symbol-1.ld
#objcopy_linked_file: --extract-symbol
#objdump: --headers
#xfail: "hppa*-*-*" "rx-*-*" "v850*-*-*"
# FAILS on the RX because the linker has to set LMA == VMA for the Renesas loader.
# FAILS on the V850 because an extra section - .note.renesas - is created.
#...
Sections:
*Idx +Name +Size +VMA +LMA .*
*0 +\.foo +0+ +0+10000 +0+10000 .*
*CONTENTS, ALLOC, LOAD, CODE
*1 +\.bar +0+ +0+20000 +0+10000 .*
*ALLOC, READONLY, CODE

View File

@ -1,17 +0,0 @@
#name: --extract-symbol test 1 (symbols)
#source: extract-symbol-1.s
#ld: -Textract-symbol-1.ld
#objcopy_linked_file: --extract-symbol
#nm: -n
#xfail: "hppa*-*-*"
#...
0*00010010 T B
#...
0*00020123 T C
#...
0*00030000 A _entry
#...
0*00040000 A linker_symbol
#...
0*12345678 A D
#pass

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]]