binutils-gdb/binutils/testsuite/binutils-all/objcopy.exp

1442 lines
40 KiB
Plaintext
Raw Normal View History

# Copyright (C) 1994-2022 Free Software Foundation, Inc.
1999-05-03 15:29:11 +08:00
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
2007-07-06 00:54:46 +08:00
# the Free Software Foundation; either version 3 of the License, or
1999-05-03 15:29:11 +08:00
# (at your option) any later version.
#
1999-05-03 15:29:11 +08:00
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
1999-05-03 15:29:11 +08:00
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
2005-05-08 22:17:41 +08:00
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
1999-05-03 15:29:11 +08:00
# Please email any bugs, comments, and/or additions to this file to:
# bug-dejagnu@prep.ai.mit.edu
# Written by Ian Lance Taylor <ian@cygnus.com>
if ![is_remote host] {
if {[which $OBJCOPY] == 0} then {
perror "$OBJCOPY does not exist"
return
}
}
send_user "Version [binutil_version $OBJCOPY]"
if ![is_remote host] {
set tempfile tmpdir/bintest.o
set copyfile tmpdir/copy
1999-05-03 15:29:11 +08:00
} else {
set tempfile [remote_download host tmpdir/bintest.o]
set copyfile copy
}
# Test that objcopy does not modify a file when copying it.
# "object" or "executable" values for type are supported.
1999-05-03 15:29:11 +08:00
proc objcopy_test {testname srcfile type asflags ldflags} {
global OBJCOPY
global OBJCOPYFLAGS
global srcdir
global subdir
global tempfile
global copyfile
set t_tempfile $tempfile
set t_copyfile ${copyfile}.o
1999-05-03 15:29:11 +08:00
if { $type != "object" && $type != "executable" } {
error "objcopy_test accepts only \"object\" or \"executable\" values for type"
}
if {![binutils_assemble_flags $srcdir/$subdir/${srcfile} $t_tempfile "$asflags"]} then {
unsupported "objcopy $type ($testname)"
remote_file host delete $t_tempfile
return
1999-05-03 15:29:11 +08:00
}
set xflags ""
if { $type == "executable" } {
global LD
# Check that LD exists
if {[which $LD] == 0} then {
untested "objcopy $type ($testname)"
return
}
# Use tempfile and copyfile without the .o extension for executable files
set t_tempfile [string range $tempfile 0 end-2]
set t_copyfile $copyfile
set got [binutils_run $LD "$tempfile -o $t_tempfile $ldflags"]
if { ![string equal "" $got] } then {
unsupported "objcopy $type ($testname)"
return
}
set xflags "--preserve-dates"
sleep 1
}
set got [binutils_run $OBJCOPY "$OBJCOPYFLAGS $xflags $t_tempfile $t_copyfile"]
if ![string equal "" $got] then {
send_log "$got\n"
fail "objcopy $type ($testname)"
1999-05-03 15:29:11 +08:00
} else {
send_log "cmp $t_tempfile $t_copyfile\n"
verbose "cmp $t_tempfile $t_copyfile"
if [is_remote host] {
set src1 tmpdir/bintest
set src2 tmpdir/copy
remote_upload host $t_tempfile $src1
remote_upload host $t_copyfile $src2
} else {
set src1 $t_tempfile
set src2 $t_copyfile
}
set status [remote_exec build cmp "${src1} ${src2}"]
set exec_output [lindex $status 1]
set exec_output [prune_warnings $exec_output]
if [string equal "" $exec_output] then {
pass "objcopy $type ($testname)"
if { $type == "executable" } {
set dir [file dirname $t_copyfile]
set f2 [file tail $t_copyfile]
set status [remote_exec host find "$dir -name $f2 -newer $t_tempfile -print"]
set exec_output [lindex $status 1]
if [string equal "" $exec_output] then {
pass "objcopy $type ($testname) timestamp"
} else {
fail "objcopy $type ($testname) timestamp"
}
}
} else {
send_log "$exec_output\n"
verbose "$exec_output" 1
1999-05-03 15:29:11 +08:00
# On OSF/1, this succeeds with gas and fails with /bin/as.
setup_xfail "alpha*-*-osf*"
1999-05-03 15:29:11 +08:00
fail "objcopy $type ($testname)"
}
1999-05-03 15:29:11 +08:00
}
}
setup_xfail "hppa*-*-*"
setup_xfail "sh-*-coff*"
setup_xfail "tic54x-*-*"
clear_xfail "hppa*64*-*-hpux*" "hppa*-*-linux*" "hppa*-*-lites*"
clear_xfail "hppa*-*-*n*bsd*" "hppa*-*-rtems*" "hppa*-*-*elf*"
objcopy_test "simple copy" bintest.s object "" ""
# Test verilog data width
proc objcopy_test_verilog {testname} {
global OBJCOPY
global OBJCOPYFLAGS
global srcdir
global subdir
global copyfile
set binfile tmpdir/verilogtest.o
set verilog tmpdir/verilog
set got [binutils_assemble $srcdir/$subdir/verilogtest.s $binfile]
if {![binutils_assemble $srcdir/$subdir/verilogtest.s $binfile]} then {
unsupported "objcopy ($testname)"
return
}
set got [binutils_run $OBJCOPY "-O verilog $binfile $verilog"]
if ![string equal "" $got] then {
fail "objcopy ($testname)"
}
set got [binutils_run $OBJCOPY "-O verilog --verilog-data-width 0 $binfile $verilog-0.hex"]
if ![regexp "verilog data width must be at least 1 byte" $got] then {
fail "objcopy ($testname 0) {$got}"
} else {
pass "objcopy ($testname 0)"
}
foreach width {1 2 4 8} {
set got [binutils_run $OBJCOPY "-O verilog --verilog-data-width $width $binfile $verilog-$width.hex"]
if ![string equal "" $got] then {
fail "objcopy ($testname $width)"
}
send_log "regexp_diff $verilog-$width.hex $srcdir/$subdir/verilog-$width.hex\n"
if {! [regexp_diff "$verilog-$width.hex" "$srcdir/$subdir/verilog-$width.hex"]} {
pass "objcopy ($testname $width)"
} else {
fail "objcopy ($testname $width)"
}
}
}
objcopy_test_verilog "verilog data width"
if { [file exists $tempfile] } {
# Test reversing bytes in a section.
set reversed ${tempfile}-reversed
set sect_names [get_standard_section_names]
if { $sect_names != "" } {
if { [istarget hppa*-*-hpux*] } {
set got [binutils_run $OBJCOPY "$OBJCOPYFLAGS -j \$PRIVATE\$ -j [lindex $sect_names 1] --reverse-bytes=4 $tempfile $reversed"]
} else {
set got [binutils_run $OBJCOPY "$OBJCOPYFLAGS -j [lindex $sect_names 1] --reverse-bytes=4 $tempfile $reversed"]
}
} else {
set got [binutils_run $OBJCOPY "$OBJCOPYFLAGS -j .data --reverse-bytes=4 $tempfile $reversed"]
}
if ![string equal "" $got] then {
fail "objcopy --reverse-bytes"
} else {
if [is_remote host] {
remote_upload host ${reversed} tmpdir/copy-reversed.o
set reversed tmpdir/copy-reversed.o
}
set origdata [binutils_run $OBJDUMP "$OBJDUMPFLAGS -s -j .data $tempfile"]
set revdata [binutils_run $OBJDUMP "$OBJDUMPFLAGS -s -j .data $reversed"]
set want "^ \[0-9\]+ (\[0-9\]+)"
set found_orig [regexp -lineanchor $want $origdata -> origdata]
set found_rev [regexp -lineanchor $want $revdata -> revdata]
if {$found_orig == 0 || $found_rev == 0} then {
fail "objcopy --reverse-bytes"
} else {
scan $origdata "%2x%2x%2x%2x" b1 b2 b3 b4
scan $revdata "%2x%2x%2x%2x" c4 c3 c2 c1
if {$b1 == $c1 && $b2 == $c2 && $b3 == $c3 && $b4 == $c4} then {
pass "objcopy --reverse-bytes"
} else {
fail "objcopy --reverse-bytes"
}
}
}
}
# Test interleaved copy of multiple byte width
set sequence_file sequence_file
set file [open ${sequence_file} w]
puts ${file} "12345678"
close ${file}
if [is_remote host] {
remote_upload host ${sequence_file} tmpdir/sequence_file
set sequence_file tmpdir/sequence_file
}
set got [binutils_run $OBJCOPY "-I binary -i 4 -b 0 --interleave-width 2 ${sequence_file} ${copyfile}"]
if ![string equal "" $got] then {
fail "objcopy -i --interleave-width"
} else {
if [is_remote host] {
remote_upload host ${copyfile} tmpdir/interleave_output
set interleave_output tmpdir/interleave_output
} else {
set interleave_output ${copyfile}
}
set file [open ${interleave_output} r]
gets $file line
send_log "$line\n"
verbose $line
if ![string equal "1256" $line] then {
fail "objcopy -i --interleave-width"
}
pass "objcopy -i --interleave-width"
close $file
}
1999-05-03 15:29:11 +08:00
# Test generating S records.
if { [file exists $tempfile] } {
# We make the srec filename 8.3 compatible. Note that the header string
# matched against depends on the name of the file. Ugh.
1999-05-03 15:29:11 +08:00
if [is_remote host] {
set srecfile copy.sre
set header_string S00B0000636F70792E737265C1
} else {
set srecfile ${copyfile}.srec
set header_string S0130000746D706469722F636F70792E7372656397
1999-05-03 15:29:11 +08:00
}
set got [binutils_run $OBJCOPY "$OBJCOPYFLAGS -O srec $tempfile ${srecfile}"]
if ![string equal "" $got] then {
1999-05-03 15:29:11 +08:00
fail "objcopy -O srec"
} else {
if [is_remote host] {
remote_upload host ${srecfile} tmpdir/copy.srec
set srecfile tmpdir/copy.srec
1999-05-03 15:29:11 +08:00
}
set file [open ${srecfile} r]
# The first S record is fixed by the file name we are using.
gets $file line
1999-05-03 15:29:11 +08:00
send_log "$line\n"
verbose $line
if ![regexp "$header_string.*" $line] {
send_log "bad header\n"
1999-05-03 15:29:11 +08:00
fail "objcopy -O srec"
} else {
while {[gets $file line] != -1 \
&& [regexp "^S\[123\]\[0-9a-fA-F\]+\[\r\n\]*$" $line]} {
1999-05-03 15:29:11 +08:00
send_log "$line\n"
verbose $line
set line "**EOF**"
}
send_log "$line\n"
verbose $line
if ![regexp "^S\[789\]\[0-9a-fA-F\]+\[\r\n\]*$" $line] then {
send_log "bad trailer\n"
1999-05-03 15:29:11 +08:00
fail "objcopy -O srec"
} else {
if {[gets $file line] != -1} then {
send_log "garbage at end\n"
send_log "$line\n"
verbose $line
1999-05-03 15:29:11 +08:00
fail "objcopy -O srec"
} else {
set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -f ${srecfile}"]
if ![regexp "file format srec" $got] then {
send_log "objdump failed\n"
fail "objcopy -O srec"
} else {
pass "objcopy -O srec"
}
1999-05-03 15:29:11 +08:00
}
}
}
close $file
}
1999-05-03 15:29:11 +08:00
}
# Test setting and adjusting the start address. We only test this
# while generating S records, because we may not be able to set the
# start address for other object file formats, and the S record case
# is the only useful one anyhow.
set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -f $tempfile"]
if ![regexp "start address (\[0-9a-fA-FxX\]+)" $got all origstart] then {
perror "objdump can not recognize bintest.o"
set origstart ""
} else {
set got [binutils_run $OBJCOPY "$OBJCOPYFLAGS -O srec --set-start 0x7654 $tempfile ${copyfile}.srec"]
if ![string equal "" $got] then {
1999-05-03 15:29:11 +08:00
fail "objcopy --set-start"
} else {
set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -f ${copyfile}.srec"]
if ![regexp "file format srec.*start address (\[0-9a-fA-FxX\]+)" $got all srecstart] then {
fail "objcopy --set-start"
} else {
if {$srecstart != 0x7654} then {
send_log "$srecstart != 0x7654\n"
fail "objcopy --set-start"
} else {
pass "objcopy --set-start"
}
}
}
set got [binutils_run $OBJCOPY "$OBJCOPYFLAGS -O srec --adjust-start 0x123 $tempfile ${copyfile}.srec"]
if ![string equal "" $got] then {
1999-05-03 15:29:11 +08:00
fail "objcopy --adjust-start"
} else {
set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -f ${copyfile}.srec"]
if ![regexp "file format srec.*start address (\[0-9a-fA-FxX\]+)" $got all srecstart] then {
fail "objcopy --adjust-start"
} else {
if {$srecstart != $origstart + 0x123} then {
send_log "$srecstart != $origstart + 0x123\n"
fail "objcopy --adjust-start"
} else {
pass "objcopy --adjust-start"
}
}
}
}
# Test adjusting the overall VMA, and adjusting the VMA of a
# particular section. We again only test this when generating S
# records.
set low ""
set lowname ""
set headers [binutils_run $OBJDUMP "$OBJDUMPFLAGS -h $tempfile"]
set headers_regexp "\[ 0-9\]+(\[^ \]+)\[ \]*(\[0-9a-fA-F\]+)\[ \]+\[0-9a-fA-F\]+\[ \]+(\[0-9a-fA-F\]+)\[ \]+\[0-9a-fA-F\]+\[ \]+2\[*\]\[*\]\[0-9\]+(.*)"
set got $headers
while {[regexp $headers_regexp $got all name size vma rest]} {
set vma 0x$vma
set size 0x$size
if {$size != 0} {
if {$low == "" || $vma < $low} {
set low $vma
set lowname $name
}
}
set got $rest
}
if {$low == "" || $origstart == ""} then {
perror "objdump can not recognize bintest.o"
} else {
set got [binutils_run $OBJCOPY "$OBJCOPYFLAGS -O srec --adjust-vma 0x123 $tempfile ${copyfile}.srec"]
if ![string equal "" $got] then {
1999-05-03 15:29:11 +08:00
fail "objcopy --adjust-vma"
} else {
set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -fh ${copyfile}.srec"]
set want "file format srec.*start address\[ \]*(\[0-9a-fA-FxX\]+).*sec1\[ \]+\[0-9a-fA-F\]+\[ \]+(\[0-9a-fA-F\]+)"
if ![regexp $want $got all start vma] then {
fail "objcopy --adjust-vma"
} else {
set vma 0x$vma
if {$vma != $low + 0x123} then {
send_log "$vma != $low + 0x123\n"
fail "objcopy --adjust-vma"
} else {
if {$start != $origstart + 0x123} then {
send_log "$start != $origstart + 0x123\n"
fail "objcopy --adjust-vma"
} else {
pass "objcopy --adjust-vma"
}
}
}
}
set arg ""
set got $headers
while {[regexp $headers_regexp $got all name size vma rest]} {
set vma 0x$vma
if {$vma == $low} then {
set arg "$arg --adjust-section-vma $name+4"
}
set got $rest
}
set got [binutils_run $OBJCOPY "$OBJCOPYFLAGS -O srec $arg $tempfile ${copyfile}.srec"]
if ![string equal "" $got] then {
1999-05-03 15:29:11 +08:00
fail "objcopy --adjust-section-vma +"
} else {
set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -h ${copyfile}.srec"]
set want "file format srec.*sec1\[ \]+\[0-9a-fA-F\]+\[ \]+(\[0-9a-fA-F\]+)"
if ![regexp $want $got all vma] then {
fail "objcopy --adjust-section-vma +"
} else {
set vma 0x$vma
if {$vma != $low + 4} then {
send_log "$vma != $low + 4\n"
fail "objcopy --adjust-section-vma +"
} else {
pass "objcopy --adjust-section-vma +"
}
}
}
regsub -all "\\+4" $arg "=[expr $low + 4]" argeq
set got [binutils_run $OBJCOPY "$OBJCOPYFLAGS -O srec $argeq $tempfile ${copyfile}.srec"]
if ![string equal "" $got] then {
1999-05-03 15:29:11 +08:00
fail "objcopy --adjust-section-vma ="
} else {
set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -h ${copyfile}.srec"]
set want "file format srec.*sec1\[ \]+\[0-9a-fA-F\]+\[ \]+(\[0-9a-fA-F\]+)"
if ![regexp $want $got all vma] then {
fail "objcopy --adjust-section-vma ="
} else {
set vma 0x$vma
if {$vma != $low + 4} then {
send_log "$vma != $low + 4\n"
fail "objcopy --adjust-section-vma ="
} else {
pass "objcopy --adjust-section-vma ="
}
}
}
}
# Test stripping an object.
proc strip_test { } {
global AR
1999-05-03 15:29:11 +08:00
global CC
global STRIP
global STRIPFLAGS
global NM
global NMFLAGS
global srcdir
global subdir
global READELF
1999-05-03 15:29:11 +08:00
set test "strip"
if { [target_compile $srcdir/$subdir/testprog.c tmpdir/testprog.o object debug] != "" } {
untested $test
return
}
set osabi_fail "false"
if [is_elf_format] {
verbose -log "$READELF -a tmpdir/testprog.o > tmpdir/osabi.in"
set exec_output [remote_exec host "$READELF -h tmpdir/testprog.o" "" "/dev/null" "tmpdir/osabi.in"]
if { [lindex $exec_output 0] != 0 } then {
fail "$test preserving OS/ABI"
set osabi_fail "true"
} else {
verbose -log "grep OS/ABI tmpdir/osabi.in"
catch "exec grep OS/ABI tmpdir/osabi.in" osabi_in
}
}
1999-05-03 15:29:11 +08:00
if [is_remote host] {
set archive libstrip.a
set objfile [remote_download host tmpdir/testprog.o]
remote_file host delete $archive
} else {
set archive tmpdir/libstrip.a
set objfile tmpdir/testprog.o
}
remote_file build delete tmpdir/libstrip.a
set exec_output [binutils_run $AR "rc $archive ${objfile}"]
2018-08-23 21:12:37 +08:00
set exec_output [prune_warnings $exec_output]
if ![string equal "" $exec_output] {
fail $test
unresolved "$test preserving OS/ABI"
return
}
set exec_output [binutils_run $STRIP "-g $archive"]
2018-08-23 21:12:37 +08:00
set exec_output [prune_warnings $exec_output]
if ![string equal "" $exec_output] {
fail $test
unresolved "$test preserving OS/ABI"
return
}
set exec_output [binutils_run $STRIP "$STRIPFLAGS $archive"]
2018-08-23 21:12:37 +08:00
set exec_output [prune_warnings $exec_output]
if ![string equal "" $exec_output] {
fail $test
unresolved "$test preserving OS/ABI"
return
}
if { $osabi_fail != "true" && [is_elf_format] } {
verbose -log "$READELF -a tmpdir/testprog.o > tmpdir/osabi.out"
set exec_output [remote_exec host "$READELF -h tmpdir/testprog.o" "" "/dev/null" "tmpdir/osabi.out"]
if { [lindex $exec_output 0] != 0 } then {
fail "$test preserving OS/ABI"
} else {
verbose -log "grep OS/ABI tmpdir/osabi.out"
catch "exec grep OS/ABI tmpdir/osabi.out" osabi_out
if { "$osabi_in" == "$osabi_out" } {
pass "$test preserving OS/ABI"
} else {
fail "$test preserving OS/ABI"
}
}
}
if { [target_compile $srcdir/$subdir/testprog.c tmpdir/testprog.o object debug] != "" } {
untested $test
return
}
if [is_remote host] {
set objfile [remote_download host tmpdir/testprog.o]
1999-05-03 15:29:11 +08:00
} else {
set objfile tmpdir/testprog.o
}
set exec_output [binutils_run $STRIP "$STRIPFLAGS $objfile"]
2018-08-23 21:12:37 +08:00
set exec_output [prune_warnings $exec_output]
if ![string equal "" $exec_output] {
1999-05-03 15:29:11 +08:00
fail $test
return
}
set exec_output [binutils_run $NM "-a $NMFLAGS $objfile"]
2018-08-23 21:12:37 +08:00
set exec_output [prune_warnings $exec_output]
2002-08-27 07:15:48 +08:00
if ![string match "*: no symbols*" $exec_output] {
1999-05-03 15:29:11 +08:00
fail $test
return
}
pass $test
}
strip_test
# Test stripping an object file with saving a symbol
proc strip_test_with_saving_a_symbol { } {
global CC
global STRIP
global STRIPFLAGS
global NM
global NMFLAGS
global srcdir
global subdir
set test "strip with saving a symbol"
if { [target_compile $srcdir/$subdir/testprog.c tmpdir/testprog.o object debug] != "" } {
untested $test
return
}
if [is_remote host] {
set objfile [remote_download host tmpdir/testprog.o]
1999-05-03 15:29:11 +08:00
} else {
set objfile tmpdir/testprog.o
}
set exec_output [binutils_run $STRIP "$STRIPFLAGS -K main -K _main $objfile"]
2018-08-23 21:12:37 +08:00
set exec_output [prune_warnings $exec_output]
if ![string equal "" $exec_output] {
1999-05-03 15:29:11 +08:00
fail $test
return
}
set exec_output [binutils_run $NM "$NMFLAGS $objfile"]
2018-08-23 21:12:37 +08:00
set exec_output [prune_warnings $exec_output]
if {![regexp {^([0-9a-fA-F]+)?[ ]+[TD] main} $exec_output] \
1999-05-03 15:29:11 +08:00
&& ![regexp {^([0-9a-fA-F]+)?[ ]+T _main} $exec_output]} {
fail $test
return
}
pass $test
}
strip_test_with_saving_a_symbol
# Build a final executable.
set exe [exeext]
set test_prog "testprog${exe}"
1999-05-03 15:29:11 +08:00
proc copy_setup { } {
global srcdir
global subdir
global gcc_gas_flag
global test_prog
global host_triplet
set res [build_wrapper testglue.o]
set flags { debug }
[ARM] FDPIC: Update testsuite so that many tests pass with arm*-uclinuxfdpiceabi. 2018-04-25 Christophe Lyon <christophe.lyon@st.com> binutils/ * testsuite/binutils-all/elfedit-2.d: Accept arm*-*-uclinuxfdpiceabi. * testsuite/binutils-all/elfedit-3.d: Likewise. * testsuite/binutils-all/objcopy.exp: Likewise. * testsuite/binutils-all/strip-3.d: Likewise. * testsuite/lib/binutils-common.exp: Likewise. ld/ * testsuite/ld-arm/export-class.exp: Accept arm*-*-uclinuxfdpiceabi. * testsuite/ld-discard/discard.exp: Likewise. * testsuite/ld-elf/binutils.exp: Likewise. * testsuite/ld-elf/commonpage1.d: Likewise. * testsuite/ld-elf/compress1c.d: Likewise. * testsuite/ld-elf/compressed1b.d: Likewise. * testsuite/ld-elf/compressed1c.d: Likewise. * testsuite/ld-elf/compressed1e.d: Likewise. * testsuite/ld-elf/dynamic1.d: Likewise. * testsuite/ld-elf/dynsym1.d: Likewise. * testsuite/ld-elf/ehdr_start-missing.d: Likewise. * testsuite/ld-elf/ehdr_start-shared.d: Likewise. * testsuite/ld-elf/ehdr_start-userdef.d: Likewise. * testsuite/ld-elf/ehdr_start-weak.d: Likewise. * testsuite/ld-elf/ehdr_start.d: Likewise. * testsuite/ld-elf/exclude3b.d: Likewise. * testsuite/ld-elf/export-class.exp: Likewise. * testsuite/ld-elf/global1.d: Likewise. * testsuite/ld-elf/hash.d: Likewise. * testsuite/ld-elf/header.d: Likewise. * testsuite/ld-elf/loadaddr1.d: Likewise. * testsuite/ld-elf/loadaddr2.d: Likewise. * testsuite/ld-elf/loadaddr3a.d: Likewise. * testsuite/ld-elf/loadaddr3b.d: Likewise. * testsuite/ld-elf/local1.d: Likewise. * testsuite/ld-elf/maxpage1.d: Likewise. * testsuite/ld-elf/maxpage2.d: Likewise. * testsuite/ld-elf/maxpage3a.d: Likewise. * testsuite/ld-elf/mbind1a.d: Likewise. * testsuite/ld-elf/mbind1b.d: Likewise. * testsuite/ld-elf/mbind1c.d: Likewise. * testsuite/ld-elf/multibss1.d: Likewise. * testsuite/ld-elf/noload-2.d: Likewise. * testsuite/ld-elf/now-1.d: Likewise. * testsuite/ld-elf/now-2.d: Likewise. * testsuite/ld-elf/now-3.d: Likewise. * testsuite/ld-elf/now-4.d: Likewise. * testsuite/ld-elf/pie.d: Likewise. * testsuite/ld-elf/pr12975.d: Likewise. * testsuite/ld-elf/pr13177.d: Likewise. * testsuite/ld-elf/pr13195.d: Likewise. * testsuite/ld-elf/pr16322.d: Likewise. * testsuite/ld-elf/pr16498a.d: Likewise. * testsuite/ld-elf/pr16498b.d: Likewise. * testsuite/ld-elf/pr17615.d: Likewise. * testsuite/ld-elf/pr19162.d: Likewise. * testsuite/ld-elf/pr19539.d: Likewise. * testsuite/ld-elf/pr19617a.d: Likewise. * testsuite/ld-elf/pr19617b.d: Likewise. * testsuite/ld-elf/pr19617c.d: Likewise. * testsuite/ld-elf/pr19698.d: Likewise. * testsuite/ld-elf/pr19789.d: Likewise. * testsuite/ld-elf/pr20513c.d: Likewise. * testsuite/ld-elf/pr20513d.d: Likewise. * testsuite/ld-elf/pr21384.d: Likewise. * testsuite/ld-elf/pr21389a.d: Likewise. * testsuite/ld-elf/pr21389b.d: Likewise. * testsuite/ld-elf/pr21389c.d: Likewise. * testsuite/ld-elf/pr21562a.d: Likewise. * testsuite/ld-elf/pr21562b.d: Likewise. * testsuite/ld-elf/pr21562c.d: Likewise. * testsuite/ld-elf/pr21562d.d: Likewise. * testsuite/ld-elf/pr21562e.d: Likewise. * testsuite/ld-elf/pr21562f.d: Likewise. * testsuite/ld-elf/pr21562g.d: Likewise. * testsuite/ld-elf/pr21562h.d: Likewise. * testsuite/ld-elf/pr21562i.d: Likewise. * testsuite/ld-elf/pr21562j.d: Likewise. * testsuite/ld-elf/pr21562k.d: Likewise. * testsuite/ld-elf/pr21562l.d: Likewise. * testsuite/ld-elf/pr21562m.d: Likewise. * testsuite/ld-elf/pr21562n.d: Likewise. * testsuite/ld-elf/pr21903a.d: Likewise. * testsuite/ld-elf/pr21903b.d: Likewise. * testsuite/ld-elf/pr21903d.d: Likewise. * testsuite/ld-elf/pr22269a.d: Likewise. * testsuite/ld-elf/pr22269b.d: Likewise. * testsuite/ld-elf/pr22393-1a.d: Likewise. * testsuite/ld-elf/pr22393-1b.d: Likewise. * testsuite/ld-elf/pr22393-1c.d: Likewise. * testsuite/ld-elf/pr22393-1d.d: Likewise. * testsuite/ld-elf/pr22393-1e.d: Likewise. * testsuite/ld-elf/pr22393-1f.d: Likewise. * testsuite/ld-elf/pr22423.d: Likewise. * testsuite/ld-elf/rpath-1.d: Likewise. * testsuite/ld-elf/rpath-2.d: Likewise. * testsuite/ld-elf/runpath-1.d: Likewise. * testsuite/ld-elf/runpath-2.d: Likewise. * testsuite/ld-elf/seg.d: Likewise. * testsuite/ld-elf/sizeofb.d: Likewise. * testsuite/ld-elf/startofb.d: Likewise. * testsuite/ld-elf/strtab.d: Likewise. * testsuite/ld-elf/textaddr1.d: Likewise. * testsuite/ld-elf/textaddr2.d: Likewise. * testsuite/ld-elf/textaddr3.d: Likewise. * testsuite/ld-elf/textaddr4.d: Likewise. * testsuite/ld-elf/textaddr5.d: Likewise. * testsuite/ld-elf/textaddr6.d: Likewise. * testsuite/ld-elf/textaddr7.d: Likewise. * testsuite/ld-elf/tls.exp: Likewise. * testsuite/ld-elf/tls_common.exp: Likewise. * testsuite/ld-elf/unknown2.d: Likewise. * testsuite/ld-gc/abi-note.d: Likewise. * testsuite/ld-gc/pr11218.d: Likewise. * testsuite/ld-gc/pr19167.d: Likewise. * testsuite/ld-gc/pr20022.d: Likewise. * testsuite/ld-gc/start.d: Likewise. * testsuite/ld-gc/stop.d: Likewise. * testsuite/ld-scripts/phdrs2.exp: Likewise. * testsuite/ld-scripts/rgn-at5.d: Likewise. * testsuite/ld-undefined/entry-3.d: Likewise. * testsuite/ld-undefined/entry-4.d: Likewise.
2018-04-19 04:55:29 +08:00
if { [istarget *-*-uclinux*] && ![istarget tic6x-*-*] && ![istarget arm*-*-uclinuxfdpiceabi] } {
return 1
}
1999-05-03 15:29:11 +08:00
if { $res != "" } {
lappend flags "additional_flags=[lindex $res 1]"
set add_libs "testglue.o"
1999-05-03 15:29:11 +08:00
} else {
set add_libs ""
1999-05-03 15:29:11 +08:00
}
Improve binutils testsuite coverage for GNU/Hurd. binutils/testsuite/ * lib/utils-lib.exp (is_elf_format): Consider for *-*-gnu*, too. * binutils-all/elfedit-2.d (target): Likewise. * binutils-all/elfedit-3.d (target): Likewise. * binutils-all/i386/i386.exp: Likewise. * binutils-all/objcopy.exp: Likewise. * binutils-all/strip-3.d (target): Likewise. gas/testsuite/ * lib/gas-defs.exp (is_elf_format): Consider for *-*-gnu*, too. * gas/elf/elf.exp: Likewise. * gas/symver/symver.exp: Likewise. ld/ * configure.host: Add stanza for *-*-gnu*. ld/testsuite/ * lib/ld-lib.exp (is_elf_format): Consider for *-*-gnu*, too. * ld-discard/discard.exp: Likewise. * ld-elf/binutils.exp: Likewise. * ld-elf/commonpage1.d (target): Likewise. * ld-elf/compress1c.d (target): Likewise. * ld-elf/discard1.d (target): Likewise. * ld-elf/discard2.d (target): Likewise. * ld-elf/discard3.d (target): Likewise. * ld-elf/dynsym1.d (target): Likewise. * ld-elf/eh6.d (target): Likewise. * ld-elf/elf.exp: Likewise. (array_tests): Move -static tests to... (array_tests_static): ... here, and handle it accordingly. * ld-elf/hash.d (target): Likewise. * ld-elf/header.d (target): Likewise. * ld-elf/loadaddr1.d (target): Likewise. * ld-elf/loadaddr2.d (target): Likewise. * ld-elf/loadaddr3a.d (target): Likewise. * ld-elf/loadaddr3b.d (target): Likewise. * ld-elf/local1.d (target): Likewise. * ld-elf/maxpage1.d (target): Likewise. * ld-elf/maxpage2.d (target): Likewise. * ld-elf/maxpage3a.d (target): Likewise. * ld-elf/multibss1.d (target): Likewise. * ld-elf/noload-2.d (target): Likewise. * ld-elf/seg.d (target): Likewise. * ld-elf/textaddr1.d (target): Likewise. * ld-elf/textaddr2.d (target): Likewise. * ld-elf/textaddr3.d (target): Likewise. * ld-elf/textaddr4.d (target): Likewise. * ld-elf/textaddr5.d (target): Likewise. * ld-elf/textaddr6.d (target): Likewise. * ld-elf/textaddr7.d (target): Likewise. * ld-elf/tls_common.exp: Likewise. * ld-elf/unknown2.d (target): Likewise. * ld-elfvers/vers.exp: Likewise. * ld-elfvsb/elfvsb.exp: Likewise. * ld-elfweak/elfweak.exp: Likewise. (setup_xfail_gnu_hurd): New function. Use it where appropriate. * ld-gc/abi-note.d (target): Likewise. * ld-gc/gc.exp: Likewise. * ld-gc/pr11218.d (target): Likewise. * ld-gc/start.d (target): Likewise. * ld-i386/i386.exp: Likewise. * ld-ifunc/binutils.exp: Likewise. * ld-ifunc/ifunc.exp: Likewise. * ld-linkonce/linkonce.exp: Likewise. * ld-linkonce/zeroehl32.d (target): Likewise. * ld-pie/pie.exp: Likewise. * ld-scripts/phdrs2.exp: Likewise. * ld-scripts/rgn-at5.d (target): Likewise. * ld-shared/shared.exp: Likewise. * ld-undefined/entry-3.d (target): Likewise. * ld-undefined/entry-4.d (target): Likewise. * ld-undefined/weak-undef.exp: Likewise.
2010-11-08 14:43:40 +08:00
if { [istarget *-*-linux*]
|| [istarget *-*-gnu*] } {
foreach i $gcc_gas_flag {
set flags "additional_flags=$i $flags"
}
}
if { [target_compile "$srcdir/$subdir/testprog.c $add_libs" tmpdir/$test_prog executable $flags] != "" } {
1999-05-03 15:29:11 +08:00
return 2
}
set result [remote_load target tmpdir/$test_prog]
set status [lindex $result 0]
1999-05-03 15:29:11 +08:00
if { $status != "pass" } {
send_log "cannot run executable, status = ${status} on ${host_triplet}\n"
return 3
1999-05-03 15:29:11 +08:00
}
return 0
}
# Test copying an executable.
proc copy_executable { prog flags test1 test2 } {
global test_prog
1999-05-03 15:29:11 +08:00
if [is_remote host] {
set testfile [remote_download host tmpdir/$test_prog]
1999-05-03 15:29:11 +08:00
set testcopy copyprog
} else {
set testfile tmpdir/$test_prog
1999-05-03 15:29:11 +08:00
set testcopy tmpdir/copyprog
}
remote_file host delete $testcopy
1999-05-03 15:29:11 +08:00
set exec_output [binutils_run $prog "$flags $testfile $testcopy"]
if ![string equal "" $exec_output] {
1999-05-03 15:29:11 +08:00
fail $test1
if [string equal "" $test2] {
return
}
1999-05-03 15:29:11 +08:00
fail $test2
return
}
if [is_remote host] {
remote_upload host $testcopy tmpdir/copyprog
}
set status [remote_exec build "cmp" "tmpdir/$test_prog tmpdir/copyprog"]
set exec_output [lindex $status 1]
1999-05-03 15:29:11 +08:00
if [string equal "" $exec_output] then {
1999-05-03 15:29:11 +08:00
pass $test1
} else {
send_log "$exec_output\n"
verbose "$exec_output"
# This will fail for many reasons. For example, it will most
# likely fail if a non-GNU linker is used. Therefore, we do
# not insist that it pass. If you are using an assembler and
# linker based on the same BFD as objcopy, it is worth
# investigating to see why this failure occurs. If we are
# cross compiling, we assume that a GNU linker is being used,
# and expect it to succeed.
if {[isnative]} then {
setup_xfail "*-*-*"
}
# This also fails for some mips targets. See elf32-mips.c
1999-05-03 15:29:11 +08:00
# mips_elf_sym_is_global.
if { [is_bad_symtab] } then {
setup_xfail "*-*-*"
}
1999-05-03 15:29:11 +08:00
setup_xfail "arm*-*-pe"
setup_xfail "*-*-mingw*"
setup_xfail "*-*-cygwin*"
1999-05-03 15:29:11 +08:00
fail $test1
}
if [string equal "" $test2] {
return
}
1999-05-03 15:29:11 +08:00
set output [remote_load target tmpdir/copyprog]
set status [lindex $output 0]
1999-05-03 15:29:11 +08:00
if { $status != "pass" } {
fail $test2
} else {
pass $test2
}
}
# Test stripping an executable
proc strip_executable { prog flags test1 test2 } {
1999-05-03 15:29:11 +08:00
global NM
global NMFLAGS
global READELF
1999-05-03 15:29:11 +08:00
remote_file build delete tmpdir/striprog
1999-05-03 15:29:11 +08:00
remote_download build tmpdir/copyprog tmpdir/striprog
if [is_remote host] {
set copyfile [remote_download host tmpdir/striprog]
1999-05-03 15:29:11 +08:00
} else {
set copyfile tmpdir/striprog
}
set osabi_fail "false"
if [is_elf_format] {
verbose -log "$READELF -a ${copyfile} > tmpdir/osabi.in"
set exec_output [remote_exec host "$READELF -h ${copyfile}" "" "/dev/null" "tmpdir/osabi.in"]
if { [lindex $exec_output 0] != 0 } then {
fail "$test1 preserving OS/ABI"
set osabi_fail "true"
} else {
verbose -log "grep OS/ABI tmpdir/osabi.in"
catch "exec grep OS/ABI tmpdir/osabi.in" osabi_in
}
}
1999-05-03 15:29:11 +08:00
set exec_output [binutils_run $prog "$flags ${copyfile}"]
if ![string equal "" $exec_output] {
fail $test1
if [string equal "" $test2] {
return
}
fail $test2
1999-05-03 15:29:11 +08:00
return
}
if [is_remote host] {
remote_upload host ${copyfile} tmpdir/striprog
1999-05-03 15:29:11 +08:00
}
if { $osabi_fail != "true" && [is_elf_format] } {
verbose -log "$READELF -a ${copyfile} > tmpdir/osabi.out"
set exec_output [remote_exec host "$READELF -h ${copyfile}" "" "/dev/null" "tmpdir/osabi.out"]
if { [lindex $exec_output 0] != 0 } then {
fail "$test1 preserving OS/ABI"
} else {
verbose -log "grep OS/ABI tmpdir/osabi.out"
catch "exec grep OS/ABI tmpdir/osabi.out" osabi_out
if { "$osabi_in" == "$osabi_out" } {
pass "$test1 preserving OS/ABI"
} else {
fail "$test1 preserving OS/ABI"
}
}
}
1999-05-03 15:29:11 +08:00
set exec_output [binutils_run $NM "$NMFLAGS ${copyfile}"]
2002-08-27 07:15:48 +08:00
if ![string match "*: no symbols*" $exec_output] {
fail $test1
1999-05-03 15:29:11 +08:00
return
}
if [string equal "" $test2] {
return
}
set result [remote_load target tmpdir/striprog]
set status [lindex $result 0]
if { $status != "pass" } {
fail $test2
return
}
pass $test2
1999-05-03 15:29:11 +08:00
}
# Test stripping an executable with saving a symbol
proc strip_executable_with_saving_a_symbol { prog flags test1 test2 } {
1999-05-03 15:29:11 +08:00
global NM
global NMFLAGS
remote_file build delete tmpdir/striprog
1999-05-03 15:29:11 +08:00
remote_download build tmpdir/copyprog tmpdir/striprog
if [is_remote host] {
set copyfile [remote_download host tmpdir/striprog]
1999-05-03 15:29:11 +08:00
} else {
set copyfile tmpdir/striprog
}
set exec_output [binutils_run $prog "$flags ${copyfile}"]
if ![string equal "" $exec_output] {
fail $test1
if [string equal "" $test2] {
return
}
fail $test2
1999-05-03 15:29:11 +08:00
return
}
set exec_output [binutils_run $NM "$NMFLAGS ${copyfile}"]
if { [istarget mmix-knuth-mmixware] } {
# Whenever there's a symbol in the mmo format, there's the symbol
# Main, so remove it manually from the expected output for sake of
# this test.
# Using "" not {} to get the \n and \r translated.
regsub "^\[0-9a-fA-F\]+\[ \]+T Main\[\n\r\]+" $exec_output "" exec_output
}
if {![regexp {^([0-9a-fA-F]+)?[ ]+[TD] main} $exec_output] \
&& ![regexp {^([0-9a-fA-F]+)?[ ]+[TD] _main} $exec_output]} {
fail $test1
1999-05-03 15:29:11 +08:00
return
}
if [string equal "" $test2] {
return
}
if [is_remote host] {
remote_upload host ${copyfile} tmpdir/striprog
}
set result [remote_load target tmpdir/striprog]
set status [lindex $result 0]
if { $status != "pass" } {
fail $test2
return
}
pass $test2
1999-05-03 15:29:11 +08:00
}
# Test keeping only debug symbols of an executable
proc keep_debug_symbols_and_test_copy { prog1 flags1 test1 prog2 flags2 test2 } {
remote_file build delete tmpdir/striprog
remote_download build tmpdir/copyprog tmpdir/striprog
if [is_remote host] {
set copyfile [remote_download host tmpdir/striprog]
} else {
set copyfile tmpdir/striprog
}
set exec_output [binutils_run $prog1 "$flags1 ${copyfile}"]
if ![string equal "" $exec_output] {
fail $test1
return
}
pass $test1
set exec_output [binutils_run $prog2 "$flags2 ${copyfile}"]
if ![string equal "" $exec_output] {
fail $test2
return
}
pass $test2
}
# Tests that in a debug only copy of a file the sections
2017-07-18 23:58:14 +08:00
# headers whose types have been changed to NOBITS still
# retain their sh_link fields.
proc keep_debug_symbols_and_check_links { prog flags test } {
global READELF
remote_file build delete tmpdir/striprog
remote_download build tmpdir/copyprog tmpdir/striprog
if [is_remote host] {
set copyfile [remote_download host tmpdir/striprog]
} else {
set copyfile tmpdir/striprog
}
set exec_output [binutils_run $prog "$flags ${copyfile}"]
if ![string equal "" $exec_output] {
fail $test
return
}
set got [binutils_run $READELF "-S --wide ${copyfile}"]
set fails 0
# Regexp to match a section with NOBITS type and extract its name and sh_link fields
while {[regexp \
{[^a-zA-Z]+([a-zA-Z0-9_\.]+)[ ]+NOBITS[ ]+[0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9]+[ A]+([0-9]+)(.*)} \
$got all name link rest]} {
set sh_link 0x$link
if {$sh_link == 0} {
# Only some NOBITS sections should have a non-zero sh_link field.
# Look for them by name.
verbose "NOBITS section .$name has a 0 sh_link field\n"
switch $name {
"rela.*" { set fails 1 ; send_log "Expected non-zero sh_link for .$name\n" }
"rel.*" { set fails 1 ; send_log "Expected non-zero sh_link for .$name\n" }
"hash" { set fails 1 ; send_log "Expected non-zero sh_link for .$name\n" }
"gnu_version" { set fails 1 ; send_log "Expected non-zero sh_link for .$name\n" }
"dynsym" { set fails 1 ; send_log "Expected non-zero sh_link for .$name\n" }
"gnu.version_r" { set fails 1 ; send_log "Expected non-zero sh_link for .$name\n" }
"dynamic" { set fails 1 ; send_log "Expected non-zero sh_link for .$name\n" }
"symtab" { set fails 1 ; send_log "Expected non-zero sh_link for .$name\n" }
}
}
set got $rest
}
if {$fails == 0} {
pass $test
} else {
fail $test
}
}
# For ELF relocatables, test that --only-keep-debug
# marks non-debug output sections as NOBITS.
proc keep_debug_symbols_for_elf_relocatable { prog flags test } {
global srcdir
global subdir
global READELF
if { [target_compile $srcdir/$subdir/testprog.c tmpdir/testprog.o object debug] != "" } {
untested $test
return
}
if [is_remote host] {
set relocatable [remote_download host tmpdir/testprog.o]
} else {
set relocatable tmpdir/testprog.o
}
set non_debug_sections {}
set got [binutils_run $READELF "-S --wide ${relocatable}"]
while { [regexp \
{[^a-zA-Z]+([a-zA-Z0-9_\.]+)[ \t]+([A-Z]+)[ \t]+[0-9a-f]+ [0-9a-f]+ [0-9a-f]+ [0-9]+[ \t]+([A-Z]*)[ \t]+[0-9]+(.*)} \
$got all name type flag rest] } {
if { $type != "NOTE" && [regexp {[AG]} $flag] } {
lappend non_debug_sections $name
}
set got $rest
}
set exec_output [binutils_run $prog "$flags ${relocatable}"]
if ![string equal "" $exec_output] {
fail $test
return
}
set fails 0
set got [binutils_run $READELF "-S --wide ${relocatable}"]
while { [regexp \
{[^a-zA-Z]+([a-zA-Z0-9_\.]+)[ \t]+([A-Z]+)[ \t]+[0-9a-f]+ [0-9a-f]+ [0-9a-f]+ [0-9]+[ \t]+[A-Z]*[ \t]+[0-9]+(.*)} \
$got all name type rest] } {
if { [lsearch -exact $non_debug_sections $name] >= 0 && $type != "NOBITS" } {
set fails 1
send_log "Expected SHT_NOBITS type for .$name\n"
}
set got $rest
}
if { $fails == 1 } {
fail $test
return
}
pass $test
}
1999-05-03 15:29:11 +08:00
set test1 "simple objcopy of executable"
set test1r "run objcopy of executable"
set test2 "strip executable"
set test2r "run stripped executable"
set test3 "strip executable with saving a symbol"
set test3r "run stripped executable with saving a symbol"
set test4 "keep only debug data"
set test5 "simple objcopy of debug data"
if [is_elf_format] {
set test6 "NOBITS sections retain sh_link field"
set test7 "--only-keep-debug for ELF relocatables"
}
1999-05-03 15:29:11 +08:00
switch [copy_setup] {
"1" {
# do nothing
}
"2" {
untested $test1
untested $test1r
1999-05-03 15:29:11 +08:00
untested $test2
untested $test2r
1999-05-03 15:29:11 +08:00
untested $test3
untested $test3r
1999-05-03 15:29:11 +08:00
untested $test4
untested $test5
if [is_elf_format] {
untested $test6
}
1999-05-03 15:29:11 +08:00
}
"3" {
copy_executable "$OBJCOPY" "$OBJCOPYFLAGS" "$test1" ""
unsupported $test1r
strip_executable "$STRIP" "$STRIPFLAGS" "$test2" ""
unsupported $test2r
strip_executable_with_saving_a_symbol "$STRIP" "-K main -K _main $STRIPFLAGS" "$test3" ""
unsupported $test3r
keep_debug_symbols_and_test_copy "$STRIP" "--only-keep-debug $STRIPFLAGS" "$test4" \
"$OBJCOPY" "$OBJCOPYFLAGS" "$test5"
if [is_elf_format] {
keep_debug_symbols_and_check_links "$STRIP" "--only-keep-debug $STRIPFLAGS" "$test6"
keep_debug_symbols_for_elf_relocatable "$STRIP" "--only-keep-debug $STRIPFLAGS" "$test7"
}
1999-05-03 15:29:11 +08:00
}
"0" {
copy_executable "$OBJCOPY" "$OBJCOPYFLAGS" "$test1" "$test1r"
strip_executable "$STRIP" "$STRIPFLAGS" "$test2" "$test2r"
strip_executable_with_saving_a_symbol "$STRIP" "-K main -K _main $STRIPFLAGS" "$test3" "$test3r"
keep_debug_symbols_and_test_copy "$STRIP" "--only-keep-debug $STRIPFLAGS" "$test4" \
"$OBJCOPY" "$OBJCOPYFLAGS" "$test5"
if [is_elf_format] {
keep_debug_symbols_and_check_links "$STRIP" "--only-keep-debug $STRIPFLAGS" "$test6"
keep_debug_symbols_for_elf_relocatable "$STRIP" "--only-keep-debug $STRIPFLAGS" "$test7"
}
1999-05-03 15:29:11 +08:00
}
}
proc objcopy_test_readelf {testname srcfile} {
global OBJCOPY
global OBJCOPYFLAGS
global READELF
global srcdir
global subdir
if {![binutils_assemble $srcdir/$subdir/${srcfile} tmpdir/bintest.o]} then {
unsupported "objcopy ($testname)"
return
}
verbose -log "$OBJCOPY $OBJCOPYFLAGS tmpdir/bintest.o tmpdir/copy.o"
bfd: 2007-08-28 Mark Shinwell <shinwell@codesourcery.com> Joseph Myers <joseph@codesourcery.com> * elf32-arm.c (elf32_arm_compare_mapping): Compare first on vma, then on type. binutils/testsuite: 2007-08-28 Mark Shinwell <shinwell@codesourcery.com> Joseph Myers <joseph@codesourcery.com> * binutils-all/ar.exp (long_filenames): Delete temporary files on the host. * binutils-all/arm/objdump.exp: Only check "which $OBJDUMP" if host is local. * binutils-all/objcopy.exp: Use ${srecfile} to get the name of the srec file to be passed to binutils_run. (objcopy_test_readelf): Use remote_exec. * binutils-all/readelf.exp (readelf_find_size): Use remote_exec. (readelf_test): Likewise. (readelf_wi_test): Likewise. * lib/utils-lib.exp (run_dump_test): Only check "which $binary" if host is local. Use remote_exec. Use $tempfile not tmpdir/bintest.o. gas: 2007-08-28 Mark Shinwell <shinwell@codesourcery.com> Joseph Myers <joseph@codesourcery.com> * as.c (main): Flush stderr before printing listings to ensure consistent output order across platforms. gas/testsuite: 2007-08-28 Mark Shinwell <shinwell@codesourcery.com> Joseph Myers <joseph@codesourcery.com> * lib/gas-defs.exp (gas_version): Use remote_* functions instead of exec. (gas_host_run): New. (gas_run): Use gas_host_run. (gas_start): Likewise. (run_dump_test): Likewise. (objdump): Use gas_host_run. (objdump_start_no_subdir): Likewise. * lib/gas-dg.exp (gas-dg-test): Use "remote_file host delete". * lib/run: Remove. * gas/macros/macros.exp: Download app4b.s to host. * gas/i386/i386.exp (gas_64_check): Use gas_host_run. (gas_32_check): Likewise. * gas/maxq10/maxq10.exp (gas_64_check): Likewise (gas_32_check): Likewise. * gas/maxq20/maxq20.exp (gas_64_check): Likewise (gas_32_check): Likewise. * gas/sparc/sparc.exp (gas_64_check): Likewise. * gas/cfi/cfi.exp: Likewise. * gas/elf/elf.exp (run_list_test): Likewise. Use temporary file for readelf output in place of pipe. * gas/all/gas.exp: Download incbin.dat to host. (do_comment): Allow \r\r\n. ld: 2007-08-28 Mark Shinwell <shinwell@codesourcery.com> Joseph Myers <joseph@codesourcery.com> * ldlang.c (sort_sections_by_lma): Sort by internal id after lma for stable sort. ld/testsuite: 2007-08-28 Mark Shinwell <shinwell@codesourcery.com> Joseph Myers <joseph@codesourcery.com> * ld-elfcomm/elfcomm.exp: Use run_host_cmd. Only check "which $CC" if host is local. * ld-checks/checks.exp: Use run_host_cmd. * ld-elf/exclude.exp: Likewise. * ld-elf/elf.exp: Download merge.ld if host is remote. * ld-elf/binutils.exp (binutils_test): Use remote_exec. * ld-elf/tls_common.exp: Use run_host_cmd. * lib/ld-lib.exp (ld_version): Only check "which $ld" if host is local. Use remote_exec. (run_host_cmd): New. (run_host_cmd_yesno): New. (default_ld_relocate): Use run_host_cmd_yesno. (default_ld_link): Likewise. (default_ld_simple_link): Use run_host_cmd. (default_ld_compile): Only check "which $ccprog" if host is local. Use remote_file and remote_exec. (default_ld_assemble): Only check "which $as" if host is local. Use run_host_cmd. (default_ld_nm): Use remote_exec, remote_upload and remote_file. (run_dump_test): Use remote_exec, remote_upload and remote_file. Only check "which $binary" if host is local. (run_ld_link_tests): Use remote_exec, remote_upload and remote_file. * ld-selective/selective.exp: Only check "which $CXX" if host is local. Use remote_exec. * ld-scripts/phdrs.exp: Only check "which $objdump" if host is local. Use run_host_cmd. * ld-scripts/phdrs2.exp: Likewise. * ld-scripts/weak.exp: Likewise. * ld-undefined/weak-undef.exp: Likewise. * ld-scripts/crossref.exp: Only check "which $CC" if host is local. Use run_host_cmd. * ld-scripts/map-address.exp: Upload map_address.map if host is remote. * ld-srec/srec.exp (run_srec_tests): Use run_host_cmd. Only check "which $CC" and "which $CXX" if host is local. * ld-undefined/undefined.exp: Only check "which $CC" if host is local. Use remote_file and run_host_cmd. * config/default.exp: Use remote_exec to create tmpdir.
2007-08-28 21:21:58 +08:00
set exec_output [remote_exec host "$OBJCOPY $OBJCOPYFLAGS tmpdir/bintest.o tmpdir/copy.o"]
if { [lindex $exec_output 0] != 0
|| ![string equal "" [lindex $exec_output 1]] } then {
fail "objcopy ($testname)"
return
}
verbose -log "$READELF -a tmpdir/bintest.o > tmpdir/bintest.o.out"
bfd: 2007-08-28 Mark Shinwell <shinwell@codesourcery.com> Joseph Myers <joseph@codesourcery.com> * elf32-arm.c (elf32_arm_compare_mapping): Compare first on vma, then on type. binutils/testsuite: 2007-08-28 Mark Shinwell <shinwell@codesourcery.com> Joseph Myers <joseph@codesourcery.com> * binutils-all/ar.exp (long_filenames): Delete temporary files on the host. * binutils-all/arm/objdump.exp: Only check "which $OBJDUMP" if host is local. * binutils-all/objcopy.exp: Use ${srecfile} to get the name of the srec file to be passed to binutils_run. (objcopy_test_readelf): Use remote_exec. * binutils-all/readelf.exp (readelf_find_size): Use remote_exec. (readelf_test): Likewise. (readelf_wi_test): Likewise. * lib/utils-lib.exp (run_dump_test): Only check "which $binary" if host is local. Use remote_exec. Use $tempfile not tmpdir/bintest.o. gas: 2007-08-28 Mark Shinwell <shinwell@codesourcery.com> Joseph Myers <joseph@codesourcery.com> * as.c (main): Flush stderr before printing listings to ensure consistent output order across platforms. gas/testsuite: 2007-08-28 Mark Shinwell <shinwell@codesourcery.com> Joseph Myers <joseph@codesourcery.com> * lib/gas-defs.exp (gas_version): Use remote_* functions instead of exec. (gas_host_run): New. (gas_run): Use gas_host_run. (gas_start): Likewise. (run_dump_test): Likewise. (objdump): Use gas_host_run. (objdump_start_no_subdir): Likewise. * lib/gas-dg.exp (gas-dg-test): Use "remote_file host delete". * lib/run: Remove. * gas/macros/macros.exp: Download app4b.s to host. * gas/i386/i386.exp (gas_64_check): Use gas_host_run. (gas_32_check): Likewise. * gas/maxq10/maxq10.exp (gas_64_check): Likewise (gas_32_check): Likewise. * gas/maxq20/maxq20.exp (gas_64_check): Likewise (gas_32_check): Likewise. * gas/sparc/sparc.exp (gas_64_check): Likewise. * gas/cfi/cfi.exp: Likewise. * gas/elf/elf.exp (run_list_test): Likewise. Use temporary file for readelf output in place of pipe. * gas/all/gas.exp: Download incbin.dat to host. (do_comment): Allow \r\r\n. ld: 2007-08-28 Mark Shinwell <shinwell@codesourcery.com> Joseph Myers <joseph@codesourcery.com> * ldlang.c (sort_sections_by_lma): Sort by internal id after lma for stable sort. ld/testsuite: 2007-08-28 Mark Shinwell <shinwell@codesourcery.com> Joseph Myers <joseph@codesourcery.com> * ld-elfcomm/elfcomm.exp: Use run_host_cmd. Only check "which $CC" if host is local. * ld-checks/checks.exp: Use run_host_cmd. * ld-elf/exclude.exp: Likewise. * ld-elf/elf.exp: Download merge.ld if host is remote. * ld-elf/binutils.exp (binutils_test): Use remote_exec. * ld-elf/tls_common.exp: Use run_host_cmd. * lib/ld-lib.exp (ld_version): Only check "which $ld" if host is local. Use remote_exec. (run_host_cmd): New. (run_host_cmd_yesno): New. (default_ld_relocate): Use run_host_cmd_yesno. (default_ld_link): Likewise. (default_ld_simple_link): Use run_host_cmd. (default_ld_compile): Only check "which $ccprog" if host is local. Use remote_file and remote_exec. (default_ld_assemble): Only check "which $as" if host is local. Use run_host_cmd. (default_ld_nm): Use remote_exec, remote_upload and remote_file. (run_dump_test): Use remote_exec, remote_upload and remote_file. Only check "which $binary" if host is local. (run_ld_link_tests): Use remote_exec, remote_upload and remote_file. * ld-selective/selective.exp: Only check "which $CXX" if host is local. Use remote_exec. * ld-scripts/phdrs.exp: Only check "which $objdump" if host is local. Use run_host_cmd. * ld-scripts/phdrs2.exp: Likewise. * ld-scripts/weak.exp: Likewise. * ld-undefined/weak-undef.exp: Likewise. * ld-scripts/crossref.exp: Only check "which $CC" if host is local. Use run_host_cmd. * ld-scripts/map-address.exp: Upload map_address.map if host is remote. * ld-srec/srec.exp (run_srec_tests): Use run_host_cmd. Only check "which $CC" and "which $CXX" if host is local. * ld-undefined/undefined.exp: Only check "which $CC" if host is local. Use remote_file and run_host_cmd. * config/default.exp: Use remote_exec to create tmpdir.
2007-08-28 21:21:58 +08:00
set exec_output [remote_exec host "$READELF -a tmpdir/bintest.o" "" "/dev/null" "tmpdir/bintest.o.out"]
if { [lindex $exec_output 0] != 0 } then {
fail "objcopy ($testname)"
bfd: 2007-08-28 Mark Shinwell <shinwell@codesourcery.com> Joseph Myers <joseph@codesourcery.com> * elf32-arm.c (elf32_arm_compare_mapping): Compare first on vma, then on type. binutils/testsuite: 2007-08-28 Mark Shinwell <shinwell@codesourcery.com> Joseph Myers <joseph@codesourcery.com> * binutils-all/ar.exp (long_filenames): Delete temporary files on the host. * binutils-all/arm/objdump.exp: Only check "which $OBJDUMP" if host is local. * binutils-all/objcopy.exp: Use ${srecfile} to get the name of the srec file to be passed to binutils_run. (objcopy_test_readelf): Use remote_exec. * binutils-all/readelf.exp (readelf_find_size): Use remote_exec. (readelf_test): Likewise. (readelf_wi_test): Likewise. * lib/utils-lib.exp (run_dump_test): Only check "which $binary" if host is local. Use remote_exec. Use $tempfile not tmpdir/bintest.o. gas: 2007-08-28 Mark Shinwell <shinwell@codesourcery.com> Joseph Myers <joseph@codesourcery.com> * as.c (main): Flush stderr before printing listings to ensure consistent output order across platforms. gas/testsuite: 2007-08-28 Mark Shinwell <shinwell@codesourcery.com> Joseph Myers <joseph@codesourcery.com> * lib/gas-defs.exp (gas_version): Use remote_* functions instead of exec. (gas_host_run): New. (gas_run): Use gas_host_run. (gas_start): Likewise. (run_dump_test): Likewise. (objdump): Use gas_host_run. (objdump_start_no_subdir): Likewise. * lib/gas-dg.exp (gas-dg-test): Use "remote_file host delete". * lib/run: Remove. * gas/macros/macros.exp: Download app4b.s to host. * gas/i386/i386.exp (gas_64_check): Use gas_host_run. (gas_32_check): Likewise. * gas/maxq10/maxq10.exp (gas_64_check): Likewise (gas_32_check): Likewise. * gas/maxq20/maxq20.exp (gas_64_check): Likewise (gas_32_check): Likewise. * gas/sparc/sparc.exp (gas_64_check): Likewise. * gas/cfi/cfi.exp: Likewise. * gas/elf/elf.exp (run_list_test): Likewise. Use temporary file for readelf output in place of pipe. * gas/all/gas.exp: Download incbin.dat to host. (do_comment): Allow \r\r\n. ld: 2007-08-28 Mark Shinwell <shinwell@codesourcery.com> Joseph Myers <joseph@codesourcery.com> * ldlang.c (sort_sections_by_lma): Sort by internal id after lma for stable sort. ld/testsuite: 2007-08-28 Mark Shinwell <shinwell@codesourcery.com> Joseph Myers <joseph@codesourcery.com> * ld-elfcomm/elfcomm.exp: Use run_host_cmd. Only check "which $CC" if host is local. * ld-checks/checks.exp: Use run_host_cmd. * ld-elf/exclude.exp: Likewise. * ld-elf/elf.exp: Download merge.ld if host is remote. * ld-elf/binutils.exp (binutils_test): Use remote_exec. * ld-elf/tls_common.exp: Use run_host_cmd. * lib/ld-lib.exp (ld_version): Only check "which $ld" if host is local. Use remote_exec. (run_host_cmd): New. (run_host_cmd_yesno): New. (default_ld_relocate): Use run_host_cmd_yesno. (default_ld_link): Likewise. (default_ld_simple_link): Use run_host_cmd. (default_ld_compile): Only check "which $ccprog" if host is local. Use remote_file and remote_exec. (default_ld_assemble): Only check "which $as" if host is local. Use run_host_cmd. (default_ld_nm): Use remote_exec, remote_upload and remote_file. (run_dump_test): Use remote_exec, remote_upload and remote_file. Only check "which $binary" if host is local. (run_ld_link_tests): Use remote_exec, remote_upload and remote_file. * ld-selective/selective.exp: Only check "which $CXX" if host is local. Use remote_exec. * ld-scripts/phdrs.exp: Only check "which $objdump" if host is local. Use run_host_cmd. * ld-scripts/phdrs2.exp: Likewise. * ld-scripts/weak.exp: Likewise. * ld-undefined/weak-undef.exp: Likewise. * ld-scripts/crossref.exp: Only check "which $CC" if host is local. Use run_host_cmd. * ld-scripts/map-address.exp: Upload map_address.map if host is remote. * ld-srec/srec.exp (run_srec_tests): Use run_host_cmd. Only check "which $CC" and "which $CXX" if host is local. * ld-undefined/undefined.exp: Only check "which $CC" if host is local. Use remote_file and run_host_cmd. * config/default.exp: Use remote_exec to create tmpdir.
2007-08-28 21:21:58 +08:00
return
}
set exec_output [prune_warnings [lindex $exec_output 1]]
if ![string equal "" $exec_output] then {
unresolved "objcopy ($testname)"
return
}
verbose -log "$READELF -a tmpdir/copy.o > tmpdir/copy.o.out"
bfd: 2007-08-28 Mark Shinwell <shinwell@codesourcery.com> Joseph Myers <joseph@codesourcery.com> * elf32-arm.c (elf32_arm_compare_mapping): Compare first on vma, then on type. binutils/testsuite: 2007-08-28 Mark Shinwell <shinwell@codesourcery.com> Joseph Myers <joseph@codesourcery.com> * binutils-all/ar.exp (long_filenames): Delete temporary files on the host. * binutils-all/arm/objdump.exp: Only check "which $OBJDUMP" if host is local. * binutils-all/objcopy.exp: Use ${srecfile} to get the name of the srec file to be passed to binutils_run. (objcopy_test_readelf): Use remote_exec. * binutils-all/readelf.exp (readelf_find_size): Use remote_exec. (readelf_test): Likewise. (readelf_wi_test): Likewise. * lib/utils-lib.exp (run_dump_test): Only check "which $binary" if host is local. Use remote_exec. Use $tempfile not tmpdir/bintest.o. gas: 2007-08-28 Mark Shinwell <shinwell@codesourcery.com> Joseph Myers <joseph@codesourcery.com> * as.c (main): Flush stderr before printing listings to ensure consistent output order across platforms. gas/testsuite: 2007-08-28 Mark Shinwell <shinwell@codesourcery.com> Joseph Myers <joseph@codesourcery.com> * lib/gas-defs.exp (gas_version): Use remote_* functions instead of exec. (gas_host_run): New. (gas_run): Use gas_host_run. (gas_start): Likewise. (run_dump_test): Likewise. (objdump): Use gas_host_run. (objdump_start_no_subdir): Likewise. * lib/gas-dg.exp (gas-dg-test): Use "remote_file host delete". * lib/run: Remove. * gas/macros/macros.exp: Download app4b.s to host. * gas/i386/i386.exp (gas_64_check): Use gas_host_run. (gas_32_check): Likewise. * gas/maxq10/maxq10.exp (gas_64_check): Likewise (gas_32_check): Likewise. * gas/maxq20/maxq20.exp (gas_64_check): Likewise (gas_32_check): Likewise. * gas/sparc/sparc.exp (gas_64_check): Likewise. * gas/cfi/cfi.exp: Likewise. * gas/elf/elf.exp (run_list_test): Likewise. Use temporary file for readelf output in place of pipe. * gas/all/gas.exp: Download incbin.dat to host. (do_comment): Allow \r\r\n. ld: 2007-08-28 Mark Shinwell <shinwell@codesourcery.com> Joseph Myers <joseph@codesourcery.com> * ldlang.c (sort_sections_by_lma): Sort by internal id after lma for stable sort. ld/testsuite: 2007-08-28 Mark Shinwell <shinwell@codesourcery.com> Joseph Myers <joseph@codesourcery.com> * ld-elfcomm/elfcomm.exp: Use run_host_cmd. Only check "which $CC" if host is local. * ld-checks/checks.exp: Use run_host_cmd. * ld-elf/exclude.exp: Likewise. * ld-elf/elf.exp: Download merge.ld if host is remote. * ld-elf/binutils.exp (binutils_test): Use remote_exec. * ld-elf/tls_common.exp: Use run_host_cmd. * lib/ld-lib.exp (ld_version): Only check "which $ld" if host is local. Use remote_exec. (run_host_cmd): New. (run_host_cmd_yesno): New. (default_ld_relocate): Use run_host_cmd_yesno. (default_ld_link): Likewise. (default_ld_simple_link): Use run_host_cmd. (default_ld_compile): Only check "which $ccprog" if host is local. Use remote_file and remote_exec. (default_ld_assemble): Only check "which $as" if host is local. Use run_host_cmd. (default_ld_nm): Use remote_exec, remote_upload and remote_file. (run_dump_test): Use remote_exec, remote_upload and remote_file. Only check "which $binary" if host is local. (run_ld_link_tests): Use remote_exec, remote_upload and remote_file. * ld-selective/selective.exp: Only check "which $CXX" if host is local. Use remote_exec. * ld-scripts/phdrs.exp: Only check "which $objdump" if host is local. Use run_host_cmd. * ld-scripts/phdrs2.exp: Likewise. * ld-scripts/weak.exp: Likewise. * ld-undefined/weak-undef.exp: Likewise. * ld-scripts/crossref.exp: Only check "which $CC" if host is local. Use run_host_cmd. * ld-scripts/map-address.exp: Upload map_address.map if host is remote. * ld-srec/srec.exp (run_srec_tests): Use run_host_cmd. Only check "which $CC" and "which $CXX" if host is local. * ld-undefined/undefined.exp: Only check "which $CC" if host is local. Use remote_file and run_host_cmd. * config/default.exp: Use remote_exec to create tmpdir.
2007-08-28 21:21:58 +08:00
set exec_output [remote_exec host "$READELF -a tmpdir/copy.o" "" "/dev/null" "tmpdir/copy.o.out"]
if { [lindex $exec_output 0] != 0 } then {
fail "objcopy ($testname)"
bfd: 2007-08-28 Mark Shinwell <shinwell@codesourcery.com> Joseph Myers <joseph@codesourcery.com> * elf32-arm.c (elf32_arm_compare_mapping): Compare first on vma, then on type. binutils/testsuite: 2007-08-28 Mark Shinwell <shinwell@codesourcery.com> Joseph Myers <joseph@codesourcery.com> * binutils-all/ar.exp (long_filenames): Delete temporary files on the host. * binutils-all/arm/objdump.exp: Only check "which $OBJDUMP" if host is local. * binutils-all/objcopy.exp: Use ${srecfile} to get the name of the srec file to be passed to binutils_run. (objcopy_test_readelf): Use remote_exec. * binutils-all/readelf.exp (readelf_find_size): Use remote_exec. (readelf_test): Likewise. (readelf_wi_test): Likewise. * lib/utils-lib.exp (run_dump_test): Only check "which $binary" if host is local. Use remote_exec. Use $tempfile not tmpdir/bintest.o. gas: 2007-08-28 Mark Shinwell <shinwell@codesourcery.com> Joseph Myers <joseph@codesourcery.com> * as.c (main): Flush stderr before printing listings to ensure consistent output order across platforms. gas/testsuite: 2007-08-28 Mark Shinwell <shinwell@codesourcery.com> Joseph Myers <joseph@codesourcery.com> * lib/gas-defs.exp (gas_version): Use remote_* functions instead of exec. (gas_host_run): New. (gas_run): Use gas_host_run. (gas_start): Likewise. (run_dump_test): Likewise. (objdump): Use gas_host_run. (objdump_start_no_subdir): Likewise. * lib/gas-dg.exp (gas-dg-test): Use "remote_file host delete". * lib/run: Remove. * gas/macros/macros.exp: Download app4b.s to host. * gas/i386/i386.exp (gas_64_check): Use gas_host_run. (gas_32_check): Likewise. * gas/maxq10/maxq10.exp (gas_64_check): Likewise (gas_32_check): Likewise. * gas/maxq20/maxq20.exp (gas_64_check): Likewise (gas_32_check): Likewise. * gas/sparc/sparc.exp (gas_64_check): Likewise. * gas/cfi/cfi.exp: Likewise. * gas/elf/elf.exp (run_list_test): Likewise. Use temporary file for readelf output in place of pipe. * gas/all/gas.exp: Download incbin.dat to host. (do_comment): Allow \r\r\n. ld: 2007-08-28 Mark Shinwell <shinwell@codesourcery.com> Joseph Myers <joseph@codesourcery.com> * ldlang.c (sort_sections_by_lma): Sort by internal id after lma for stable sort. ld/testsuite: 2007-08-28 Mark Shinwell <shinwell@codesourcery.com> Joseph Myers <joseph@codesourcery.com> * ld-elfcomm/elfcomm.exp: Use run_host_cmd. Only check "which $CC" if host is local. * ld-checks/checks.exp: Use run_host_cmd. * ld-elf/exclude.exp: Likewise. * ld-elf/elf.exp: Download merge.ld if host is remote. * ld-elf/binutils.exp (binutils_test): Use remote_exec. * ld-elf/tls_common.exp: Use run_host_cmd. * lib/ld-lib.exp (ld_version): Only check "which $ld" if host is local. Use remote_exec. (run_host_cmd): New. (run_host_cmd_yesno): New. (default_ld_relocate): Use run_host_cmd_yesno. (default_ld_link): Likewise. (default_ld_simple_link): Use run_host_cmd. (default_ld_compile): Only check "which $ccprog" if host is local. Use remote_file and remote_exec. (default_ld_assemble): Only check "which $as" if host is local. Use run_host_cmd. (default_ld_nm): Use remote_exec, remote_upload and remote_file. (run_dump_test): Use remote_exec, remote_upload and remote_file. Only check "which $binary" if host is local. (run_ld_link_tests): Use remote_exec, remote_upload and remote_file. * ld-selective/selective.exp: Only check "which $CXX" if host is local. Use remote_exec. * ld-scripts/phdrs.exp: Only check "which $objdump" if host is local. Use run_host_cmd. * ld-scripts/phdrs2.exp: Likewise. * ld-scripts/weak.exp: Likewise. * ld-undefined/weak-undef.exp: Likewise. * ld-scripts/crossref.exp: Only check "which $CC" if host is local. Use run_host_cmd. * ld-scripts/map-address.exp: Upload map_address.map if host is remote. * ld-srec/srec.exp (run_srec_tests): Use run_host_cmd. Only check "which $CC" and "which $CXX" if host is local. * ld-undefined/undefined.exp: Only check "which $CC" if host is local. Use remote_file and run_host_cmd. * config/default.exp: Use remote_exec to create tmpdir.
2007-08-28 21:21:58 +08:00
return
}
set exec_output [prune_warnings [lindex $exec_output 1]]
if ![string equal "" $exec_output] then {
unresolved "objcopy ($testname)"
return
}
verbose -log "diff tmpdir/bintest.o.out tmpdir/copy.o.out"
catch "exec diff tmpdir/bintest.o.out tmpdir/copy.o.out" exec_output
set exec_output [prune_warnings $exec_output]
if [string equal "" $exec_output] then {
pass "objcopy ($testname)"
} else {
fail "objcopy ($testname)"
}
}
objcopy: Improve wildcard matching for symbols with '!' prefix. When using options such as --localize-symbol, --globalize-symbol, etc, along with the --wildcard option, prefixing a symbol name with '!' should provide non-matching behaviour, as example the following example is given in the manual: --wildcard --weaken-symbol !foo --weaken-symbol fo* which should weaken all symbols matching the pattern 'fo*', but not the symbol 'foo'. However, this currently does not work, the current logic will waken all symbols matching the pattern 'fo*' AND all symbols that are not 'foo'. The symbol 'foo' is covered by the first condition, and so is weakened, while, other symbols, for example 'bar' will match the second condition, and so be weakened. This patch adjusts the logic so that a pattern prefixed with '!' specifically DOES NOT apply the relevant change to any matching symbols, instead of applying the change to all non-matching symbols. So this: --weaken-symbol !foo will ensure that the symbol 'foo' is not weakened, but says nothing about symbols that are not 'foo'. As a result, a pattern prefixed with '!' now only makes sense when used alongside a more wide ranging wildcard pattern. This change should make the wildcard matching feature more useful, with no overall loss of functionality. The example given in the manual, weaken all symbols matching 'fo*' except 'foo' can now be achieved, but so too can more complex examples, such as weaken all symbols matching 'fo*' except 'foo', 'foa', and 'fob', like this: --wildcard --weaken-symbol !foo \ --weaken-symbol !foa \ --weaken-symbol !fob \ --weaken-symbol fo* Under the previous scheme, something as symbols as, weaken all symbols except 'foo' could have been achieved with this: --weaken-symbol !foo however, this will no longer work. To achieve the same result under the new scheme this is now required: --weaken-symbol !foo --weaken-symbol * binutils/ChangeLog: * objcopy.c (is_specified_symbol_predicate): Don't stop at first match. Non-match rules set found to FALSE. binutils/testsuite/ChangeLog: * binutils-all/objcopy.exp: Run new symbol tests. (objcopy_test_symbol_manipulation): New function. * binutils-all/symbols-1.d: New file. * binutils-all/symbols-2.d: New file. * binutils-all/symbols-3.d: New file. * binutils-all/symbols-4.d: New file. * binutils-all/symbols.s: New file.
2015-07-31 20:48:22 +08:00
proc objcopy_test_symbol_manipulation {} {
global srcdir
global subdir
set test_list [lsort [glob -nocomplain $srcdir/$subdir/symbols-*.d]]
foreach t $test_list {
# We need to strip the ".d", but can leave the dirname.
verbose [file rootname $t]
run_dump_test [file rootname $t]
}
}
Properly implement STT_COMMON The BFD configure option, --enable-elf-stt-common, can't be to used to verify STT_COMMON implementation with the normal binutils build. Instead, this patch removes it from BFD. It adds --elf-stt-common=[no|yes] to ELF assembler/objcopy and adds -z common/-z nocommon to ld. A configure option, --enable-elf-stt-common, is added to gas to specify whether ELF assembler should generate common symbols with the STT_COMMON type by default. Since BSF_KEEP_G is never used, it is renamed to BSF_ELF_COMMON for ELF common symbols. bfd/ PR ld/19645 * bfd.c (bfd): Change flags to 20 bits. (BFD_CONVERT_ELF_COMMON): New. (BFD_USE_ELF_STT_COMMON): Likewise. (BFD_FLAGS_SAVED): Add BFD_CONVERT_ELF_COMMON and BFD_USE_ELF_STT_COMMON. (BFD_FLAGS_FOR_BFD_USE_MASK): Likewise. * configure.ac: Remove --enable-elf-stt-common. * elf.c (swap_out_syms): Choose STT_COMMON or STT_OBJECT for common symbol depending on BFD_CONVERT_ELF_COMMON and BFD_USE_ELF_STT_COMMON. * elfcode.h (elf_slurp_symbol_table): Set BSF_ELF_COMMON for STT_COMMON. * elflink.c (bfd_elf_link_mark_dynamic_symbol): Also check STT_COMMON. (elf_link_convert_common_type): New function. (elf_link_output_extsym): Choose STT_COMMON or STT_OBJECT for common symbol depending on BFD_CONVERT_ELF_COMMON and BFD_USE_ELF_STT_COMMON. Set sym.st_info after sym.st_shndx. * elfxx-target.h (TARGET_BIG_SYM): Add BFD_CONVERT_ELF_COMMON and BFD_USE_ELF_STT_COMMON to object_flags. (TARGET_LITTLE_SYM): Likewise. * syms.c (BSF_KEEP_G): Renamed to ... (BSF_ELF_COMMON): This. * bfd-in2.h: Regenerated. * config.in: Likewise. * configure: Likewise. binutils/ PR ld/19645 * NEWS: Mention --elf-stt-common= for objcopy. * doc/binutils.texi: Document --elf-stt-common= for objcopy. * objcopy.c (do_elf_stt_common): New. (command_line_switch): Add OPTION_ELF_STT_COMMON. (copy_options): Add --elf-stt-common=. (copy_usage): Add --elf-stt-common=. (copy_object): Also check do_elf_stt_common for ELF targets. (copy_file): Handle do_elf_stt_common. (copy_main): Handle OPTION_ELF_STT_COMMON. * readelf.c (apply_relocations): Support STT_COMMON. * testsuite/binutils-all/common-1.s: New file. * testsuite/binutils-all/common-1a.d: Likewise. * testsuite/binutils-all/common-1b.d: Likewise. * testsuite/binutils-all/common-1c.d: Likewise. * testsuite/binutils-all/common-1d.d: Likewise. * testsuite/binutils-all/common-1e.d: Likewise. * testsuite/binutils-all/common-1f.d: Likewise. * testsuite/binutils-all/common-2.s: Likewise. * testsuite/binutils-all/common-2a.d: Likewise. * testsuite/binutils-all/common-2b.d: Likewise. * testsuite/binutils-all/common-2c.d: Likewise. * testsuite/binutils-all/common-2d.d: Likewise. * testsuite/binutils-all/common-2e.d: Likewise. * testsuite/binutils-all/common-2f.d: Likewise. * testsuite/binutils-all/objcopy.exp (objcopy_test_elf_common_symbols): New proc. Run objcopy_test_elf_common_symbols for ELF targets gas/ PR ld/19645 * NEWS: Mention --enable-elf-stt-common and --elf-stt-common= for ELF assemblers. * as.c (flag_use_elf_stt_common): New. (show_usage): Add --elf-stt-common=. (option_values): Add OPTION_ELF_STT_COMMON. (std_longopts): Add --elf-stt-common=. (parse_args): Handle --elf-stt-common=. * as.h (flag_use_elf_stt_common): New. * config.in: Regenerated. * configure: Likewise. * configure.ac: Add --enable-elf-stt-common and define DEFAULT_GENERATE_ELF_STT_COMMON. * gas/write.c (write_object_file): Set BFD_CONVERT_ELF_COMMON and BFD_USE_ELF_STT_COMMON if flag_use_elf_stt_common is set. * doc/as.texinfo: Document --elf-stt-common=. * testsuite/gas/elf/common3.s: New file. * testsuite/gas/elf/common3a.d: Likewise. * testsuite/gas/elf/common3b.d: Likewise. * testsuite/gas/elf/common4.s: Likewise. * testsuite/gas/elf/common4a.d: Likewise. * testsuite/gas/elf/common4b.d: Likewise. * testsuite/gas/i386/dw2-compress-3b.d: Likewise. * testsuite/gas/i386/dw2-compressed-3b.d: Likewise. * testsuite/gas/elf/elf.exp: Run common3a, common3b, common4a and common4b. * testsuite/gas/i386/dw2-compress-3.d: Renamed to ... * testsuite/gas/i386/dw2-compress-3a.d: This. Pass --elf-stt-common=no to as. * testsuite/gas/i386/dw2-compressed-3.d: Renamed to ... * testsuite/gas/i386/dw2-compressed-3a.d: This. Pass --elf-stt-common=no to as. * testsuite/gas/i386/i386.exp: Run dw2-compress-3a, dw2-compress-3b, dw2-compressed-3a and dw2-compressed-3b instead of dw2-compress-3 and dw2-compressed-3. include/ PR ld/19645 * bfdlink.h (bfd_link_elf_stt_common): New enum. (bfd_link_info): Add elf_stt_common. ld/ PR ld/19645 * NEWS: Mention -z common/-z nocommon for ELF targets. * emultempl/elf32.em (gld${EMULATION_NAME}_handle_option): Handle -z common and -z nocommon. * ld.texinfo: Document -z common/-z nocommon. * lexsup.c (elf_shlib_list_options): Add -z common/-z nocommon. * testsuite/ld-elf/tls_common.exp: Test --elf-stt-common=no and --elf-stt-common=yes with assembler. * testsuite/ld-elfcomm/common-1.s: New file. * testsuite/ld-elfcomm/common-1a.d: Likewise. * testsuite/ld-elfcomm/common-1b.d: Likewise. * testsuite/ld-elfcomm/common-1c.d: Likewise. * testsuite/ld-elfcomm/common-1d.d: Likewise. * testsuite/ld-elfcomm/common-1e.d: Likewise. * testsuite/ld-elfcomm/common-1f.d: Likewise. * testsuite/ld-elfcomm/common-2.s: Likewise. * testsuite/ld-elfcomm/common-2a.d: Likewise. * testsuite/ld-elfcomm/common-2b.d: Likewise. * testsuite/ld-elfcomm/common-2c.d: Likewise. * testsuite/ld-elfcomm/common-2d.d: Likewise. * testsuite/ld-elfcomm/common-2e.d: Likewise. * testsuite/ld-elfcomm/common-2f.d: Likewise. * testsuite/ld-elfcomm/common-3a.rd: Likewise. * testsuite/ld-elfcomm/common-3b.rd: Likewise. * testsuite/ld-i386/pr19645.d: Likewise. * testsuite/ld-i386/pr19645.s: Likewise. * testsuite/ld-x86-64/largecomm-1.s: Likewise. * testsuite/ld-x86-64/largecomm-1a.d: Likewise. * testsuite/ld-x86-64/largecomm-1b.d: Likewise. * testsuite/ld-x86-64/largecomm-1c.d: Likewise. * testsuite/ld-x86-64/largecomm-1d.d: Likewise. * testsuite/ld-x86-64/largecomm-1e.d: Likewise. * testsuite/ld-x86-64/largecomm-1f.d: Likewise. * testsuite/ld-x86-64/pr19645.d: Likewise. * testsuite/ld-x86-64/pr19645.s: Likewise. * testsuite/ld-elfcomm/elfcomm.exp: Test --elf-stt-common=yes with assembler. (assembler_generates_commons): Removed. Run -z common/-z nocommon tests. Run *.d tests. * testsuite/ld-i386/i386.exp: Run pr19645. * testsuite/ld-x86-64/x86-64.exp: Likewise. * testsuite/ld-x86-64/dwarfreloc.exp: Test --elf-stt-common with assembler. Test STT_COMMON with readelf.
2016-02-23 01:18:52 +08:00
proc objcopy_test_elf_common_symbols {} {
global srcdir
global subdir
# hpux has a non-standard common directive.
if { [istarget "*-*-hpux*"] } then {
return
}
set test_list [lsort [glob -nocomplain $srcdir/$subdir/common-*.d]]
foreach t $test_list {
# We need to strip the ".d", but can leave the dirname.
verbose [file rootname $t]
run_dump_test [file rootname $t]
}
}
# ia64 specific tests
if { ([istarget "ia64-*-elf*"]
|| [istarget "ia64-*-linux*"]) } {
objcopy_test "ia64 link order" link-order.s object "" ""
}
# ELF specific tests
binutils testsuite strip-13 test The strip-13 test runs into difficulty using dc.a on some targets. dc.a writes a power of 2 number of bytes large enough to contain a target address. On some targets, eg. avr-elf, this can be 2 bytes but the ELF format used require words of 4 bytes to make up a relocation entry. There was a hack in the test, duplicating the reloc type into what is normally the addend to make the test work when little-endian, but that hack fails for similar big-endian targets. This patch fixes that problem by arranging to emit 32-bit and 64-bit ELF relocs using .4byte and .8byte directives, chosen as appropriate for the ELF size. I've also bumped the reloc number tested to a higher unused value, and made the number more easily parameterised by target should that be necessary in the future. Whether REL or RELA relocs are used is now chosen by a new is_rela readelf test of an object file, rather than by lists of targets. * testsuite/lib/binutils-common.exp (is_elf64): Use directory of input file for readelf.out. (is_rela): New proc. * testsuite/binutils-all/objcopy.exp (elf64): Set new variable from first result of is_elf64 test. (reloc_format): Set using is_rela. (strip-13): Pass RELOC and ELF64 to assembler. (strip-14, strip-15): Use elf64 rather than calling is_elf64 again. * testsuite/binutils-all/strip-13.d: Run for more targets. * testsuite/binutils-all/strip-13mips64.s: Use RELOC and set addend to zero. * testsuite/binutils-all/strip-13rel.s: Use RELOC and ELF64. Don't add _NONE reloc. * testsuite/binutils-all/strip-13rela.s: Likewise.
2018-08-13 12:11:18 +08:00
set elf64 ""
if [is_elf_format] {
objcopy: Improve wildcard matching for symbols with '!' prefix. When using options such as --localize-symbol, --globalize-symbol, etc, along with the --wildcard option, prefixing a symbol name with '!' should provide non-matching behaviour, as example the following example is given in the manual: --wildcard --weaken-symbol !foo --weaken-symbol fo* which should weaken all symbols matching the pattern 'fo*', but not the symbol 'foo'. However, this currently does not work, the current logic will waken all symbols matching the pattern 'fo*' AND all symbols that are not 'foo'. The symbol 'foo' is covered by the first condition, and so is weakened, while, other symbols, for example 'bar' will match the second condition, and so be weakened. This patch adjusts the logic so that a pattern prefixed with '!' specifically DOES NOT apply the relevant change to any matching symbols, instead of applying the change to all non-matching symbols. So this: --weaken-symbol !foo will ensure that the symbol 'foo' is not weakened, but says nothing about symbols that are not 'foo'. As a result, a pattern prefixed with '!' now only makes sense when used alongside a more wide ranging wildcard pattern. This change should make the wildcard matching feature more useful, with no overall loss of functionality. The example given in the manual, weaken all symbols matching 'fo*' except 'foo' can now be achieved, but so too can more complex examples, such as weaken all symbols matching 'fo*' except 'foo', 'foa', and 'fob', like this: --wildcard --weaken-symbol !foo \ --weaken-symbol !foa \ --weaken-symbol !fob \ --weaken-symbol fo* Under the previous scheme, something as symbols as, weaken all symbols except 'foo' could have been achieved with this: --weaken-symbol !foo however, this will no longer work. To achieve the same result under the new scheme this is now required: --weaken-symbol !foo --weaken-symbol * binutils/ChangeLog: * objcopy.c (is_specified_symbol_predicate): Don't stop at first match. Non-match rules set found to FALSE. binutils/testsuite/ChangeLog: * binutils-all/objcopy.exp: Run new symbol tests. (objcopy_test_symbol_manipulation): New function. * binutils-all/symbols-1.d: New file. * binutils-all/symbols-2.d: New file. * binutils-all/symbols-3.d: New file. * binutils-all/symbols-4.d: New file. * binutils-all/symbols.s: New file.
2015-07-31 20:48:22 +08:00
objcopy_test_symbol_manipulation
Properly implement STT_COMMON The BFD configure option, --enable-elf-stt-common, can't be to used to verify STT_COMMON implementation with the normal binutils build. Instead, this patch removes it from BFD. It adds --elf-stt-common=[no|yes] to ELF assembler/objcopy and adds -z common/-z nocommon to ld. A configure option, --enable-elf-stt-common, is added to gas to specify whether ELF assembler should generate common symbols with the STT_COMMON type by default. Since BSF_KEEP_G is never used, it is renamed to BSF_ELF_COMMON for ELF common symbols. bfd/ PR ld/19645 * bfd.c (bfd): Change flags to 20 bits. (BFD_CONVERT_ELF_COMMON): New. (BFD_USE_ELF_STT_COMMON): Likewise. (BFD_FLAGS_SAVED): Add BFD_CONVERT_ELF_COMMON and BFD_USE_ELF_STT_COMMON. (BFD_FLAGS_FOR_BFD_USE_MASK): Likewise. * configure.ac: Remove --enable-elf-stt-common. * elf.c (swap_out_syms): Choose STT_COMMON or STT_OBJECT for common symbol depending on BFD_CONVERT_ELF_COMMON and BFD_USE_ELF_STT_COMMON. * elfcode.h (elf_slurp_symbol_table): Set BSF_ELF_COMMON for STT_COMMON. * elflink.c (bfd_elf_link_mark_dynamic_symbol): Also check STT_COMMON. (elf_link_convert_common_type): New function. (elf_link_output_extsym): Choose STT_COMMON or STT_OBJECT for common symbol depending on BFD_CONVERT_ELF_COMMON and BFD_USE_ELF_STT_COMMON. Set sym.st_info after sym.st_shndx. * elfxx-target.h (TARGET_BIG_SYM): Add BFD_CONVERT_ELF_COMMON and BFD_USE_ELF_STT_COMMON to object_flags. (TARGET_LITTLE_SYM): Likewise. * syms.c (BSF_KEEP_G): Renamed to ... (BSF_ELF_COMMON): This. * bfd-in2.h: Regenerated. * config.in: Likewise. * configure: Likewise. binutils/ PR ld/19645 * NEWS: Mention --elf-stt-common= for objcopy. * doc/binutils.texi: Document --elf-stt-common= for objcopy. * objcopy.c (do_elf_stt_common): New. (command_line_switch): Add OPTION_ELF_STT_COMMON. (copy_options): Add --elf-stt-common=. (copy_usage): Add --elf-stt-common=. (copy_object): Also check do_elf_stt_common for ELF targets. (copy_file): Handle do_elf_stt_common. (copy_main): Handle OPTION_ELF_STT_COMMON. * readelf.c (apply_relocations): Support STT_COMMON. * testsuite/binutils-all/common-1.s: New file. * testsuite/binutils-all/common-1a.d: Likewise. * testsuite/binutils-all/common-1b.d: Likewise. * testsuite/binutils-all/common-1c.d: Likewise. * testsuite/binutils-all/common-1d.d: Likewise. * testsuite/binutils-all/common-1e.d: Likewise. * testsuite/binutils-all/common-1f.d: Likewise. * testsuite/binutils-all/common-2.s: Likewise. * testsuite/binutils-all/common-2a.d: Likewise. * testsuite/binutils-all/common-2b.d: Likewise. * testsuite/binutils-all/common-2c.d: Likewise. * testsuite/binutils-all/common-2d.d: Likewise. * testsuite/binutils-all/common-2e.d: Likewise. * testsuite/binutils-all/common-2f.d: Likewise. * testsuite/binutils-all/objcopy.exp (objcopy_test_elf_common_symbols): New proc. Run objcopy_test_elf_common_symbols for ELF targets gas/ PR ld/19645 * NEWS: Mention --enable-elf-stt-common and --elf-stt-common= for ELF assemblers. * as.c (flag_use_elf_stt_common): New. (show_usage): Add --elf-stt-common=. (option_values): Add OPTION_ELF_STT_COMMON. (std_longopts): Add --elf-stt-common=. (parse_args): Handle --elf-stt-common=. * as.h (flag_use_elf_stt_common): New. * config.in: Regenerated. * configure: Likewise. * configure.ac: Add --enable-elf-stt-common and define DEFAULT_GENERATE_ELF_STT_COMMON. * gas/write.c (write_object_file): Set BFD_CONVERT_ELF_COMMON and BFD_USE_ELF_STT_COMMON if flag_use_elf_stt_common is set. * doc/as.texinfo: Document --elf-stt-common=. * testsuite/gas/elf/common3.s: New file. * testsuite/gas/elf/common3a.d: Likewise. * testsuite/gas/elf/common3b.d: Likewise. * testsuite/gas/elf/common4.s: Likewise. * testsuite/gas/elf/common4a.d: Likewise. * testsuite/gas/elf/common4b.d: Likewise. * testsuite/gas/i386/dw2-compress-3b.d: Likewise. * testsuite/gas/i386/dw2-compressed-3b.d: Likewise. * testsuite/gas/elf/elf.exp: Run common3a, common3b, common4a and common4b. * testsuite/gas/i386/dw2-compress-3.d: Renamed to ... * testsuite/gas/i386/dw2-compress-3a.d: This. Pass --elf-stt-common=no to as. * testsuite/gas/i386/dw2-compressed-3.d: Renamed to ... * testsuite/gas/i386/dw2-compressed-3a.d: This. Pass --elf-stt-common=no to as. * testsuite/gas/i386/i386.exp: Run dw2-compress-3a, dw2-compress-3b, dw2-compressed-3a and dw2-compressed-3b instead of dw2-compress-3 and dw2-compressed-3. include/ PR ld/19645 * bfdlink.h (bfd_link_elf_stt_common): New enum. (bfd_link_info): Add elf_stt_common. ld/ PR ld/19645 * NEWS: Mention -z common/-z nocommon for ELF targets. * emultempl/elf32.em (gld${EMULATION_NAME}_handle_option): Handle -z common and -z nocommon. * ld.texinfo: Document -z common/-z nocommon. * lexsup.c (elf_shlib_list_options): Add -z common/-z nocommon. * testsuite/ld-elf/tls_common.exp: Test --elf-stt-common=no and --elf-stt-common=yes with assembler. * testsuite/ld-elfcomm/common-1.s: New file. * testsuite/ld-elfcomm/common-1a.d: Likewise. * testsuite/ld-elfcomm/common-1b.d: Likewise. * testsuite/ld-elfcomm/common-1c.d: Likewise. * testsuite/ld-elfcomm/common-1d.d: Likewise. * testsuite/ld-elfcomm/common-1e.d: Likewise. * testsuite/ld-elfcomm/common-1f.d: Likewise. * testsuite/ld-elfcomm/common-2.s: Likewise. * testsuite/ld-elfcomm/common-2a.d: Likewise. * testsuite/ld-elfcomm/common-2b.d: Likewise. * testsuite/ld-elfcomm/common-2c.d: Likewise. * testsuite/ld-elfcomm/common-2d.d: Likewise. * testsuite/ld-elfcomm/common-2e.d: Likewise. * testsuite/ld-elfcomm/common-2f.d: Likewise. * testsuite/ld-elfcomm/common-3a.rd: Likewise. * testsuite/ld-elfcomm/common-3b.rd: Likewise. * testsuite/ld-i386/pr19645.d: Likewise. * testsuite/ld-i386/pr19645.s: Likewise. * testsuite/ld-x86-64/largecomm-1.s: Likewise. * testsuite/ld-x86-64/largecomm-1a.d: Likewise. * testsuite/ld-x86-64/largecomm-1b.d: Likewise. * testsuite/ld-x86-64/largecomm-1c.d: Likewise. * testsuite/ld-x86-64/largecomm-1d.d: Likewise. * testsuite/ld-x86-64/largecomm-1e.d: Likewise. * testsuite/ld-x86-64/largecomm-1f.d: Likewise. * testsuite/ld-x86-64/pr19645.d: Likewise. * testsuite/ld-x86-64/pr19645.s: Likewise. * testsuite/ld-elfcomm/elfcomm.exp: Test --elf-stt-common=yes with assembler. (assembler_generates_commons): Removed. Run -z common/-z nocommon tests. Run *.d tests. * testsuite/ld-i386/i386.exp: Run pr19645. * testsuite/ld-x86-64/x86-64.exp: Likewise. * testsuite/ld-x86-64/dwarfreloc.exp: Test --elf-stt-common with assembler. Test STT_COMMON with readelf.
2016-02-23 01:18:52 +08:00
objcopy_test_elf_common_symbols
setup_xfail "hppa*-*-*"
setup_xfail "sh-*-coff*"
setup_xfail "tic54x-*-*"
clear_xfail "hppa*64*-*-hpux*" "hppa*-*-linux*" "hppa*-*-lites*"
clear_xfail "hppa*-*-*n*bsd*" "hppa*-*-rtems*" "hppa*-*-*elf*"
objcopy_test "ELF unknown section type" unknown.s object "" ""
2018-09-17 17:10:47 +08:00
objcopy_test_readelf "ELF group 1" group.s
objcopy_test_readelf "ELF group 2" group-2.s
objcopy_test_readelf "ELF group 3" group-3.s
objcopy_test_readelf "ELF group 4" group-4.s
Support ELF SHF_GNU_MBIND and PT_GNU_MBIND_XXX Mark an ALLOC section, which should be placed in special memory area, with SHF_GNU_MBIND. Its sh_info field indicates the special memory type. GNU_MBIND section names start with ".mbind" so that they are placed as orphan sections by linker. All input GNU_MBIND sections with the same sh_type, sh_flags and sh_info are placed in one output GNU_MBIND section. In executable and shared object, create a GNU_MBIND segment for each GNU_MBIND section and its segment type is PT_GNU_MBIND_LO plus the sh_info value. Each GNU_MBIND segment is aligned at page boundary. The assembler syntax: .section .mbind.foo,"adx",%progbits ^ 0: Special memory type. | 'd' for SHF_GNU_MBIND. .section .mbind.foo,"adx",%progbits,0x1 ^ 1: Special memory type. | 'd' for SHF_GNU_MBIND. .section .mbind.bar,"adG",%progbits,.foo_group,comdat,0x2 ^ 2: Special memory type. | 'd' for SHF_GNU_MBIND. bfd/ * elf.c (get_program_header_size): Add a GNU_MBIND segment for each GNU_MBIND section and align GNU_MBIND section to page size. (_bfd_elf_map_sections_to_segments): Create a GNU_MBIND segment for each GNU_MBIND section. (_bfd_elf_init_private_section_data): Copy sh_info from input for GNU_MBIND section. binutils/ * NEWS: Mention support for ELF SHF_GNU_MBIND and PT_GNU_MBIND_XXX. * readelf.c (get_segment_type): Handle PT_GNU_MBIND_XXX. (get_elf_section_flags): Handle SHF_GNU_MBIND. (process_section_headers): Likewise. * testsuite/binutils-all/mbind1.s: New file. * testsuite/binutils-all/objcopy.exp: Run readelf test on mbind1.s. gas/ * NEWS: Mention support for ELF SHF_GNU_MBIND. * config/obj-elf.c (section_match): New. (get_section): Match both sh_info and group name. (obj_elf_change_section): Add argument for sh_info. Pass both sh_info and group name to get_section. Issue an error for SHF_GNU_MBIND section without SHF_ALLOC. Set sh_info. (obj_elf_parse_section_letters): Set SHF_GNU_MBIND for 'd'. (obj_elf_section): Support SHF_GNU_MBIND section info. * config/obj-elf.h (obj_elf_change_section): Add argument for sh_info. * config/tc-arm.c (start_unwind_section): Pass 0 as sh_info to obj_elf_change_section. * config/tc-ia64.c (obj_elf_vms_common): Likewise. * config/tc-microblaze.c (microblaze_s_data): Likewise. (microblaze_s_sdata): Likewise. (microblaze_s_rdata): Likewise. (microblaze_s_bss): Likewise. * config/tc-mips.c (s_change_section): Likewise. * config/tc-msp430.c (msp430_profiler): Likewise. * config/tc-rx.c (parse_rx_section): Likewise. * config/tc-tic6x.c (tic6x_start_unwind_section): Likewise. * doc/as.texinfo: Document 'd' for SHF_GNU_MBIND. * testsuite/gas/elf/elf.exp: Run section12a, section12b and section13. * testsuite/gas/elf/section10.d: Updated. * testsuite/gas/elf/section10.s: Likewise. * testsuite/gas/elf/section12.s: New file. * testsuite/gas/elf/section12a.d: Likewise. * testsuite/gas/elf/section12b.d: Likewise. * testsuite/gas/elf/section13.l: Likewise. * testsuite/gas/elf/section13.d: Likewise. * testsuite/gas/elf/section13.s: Likewise. include/ * elf/common.h (PT_GNU_MBIND_NUM): New. (PT_GNU_MBIND_LO): Likewise. (PT_GNU_MBIND_HI): Likewise. (SHF_GNU_MBIND): Likewise. ld/ * NEWS: Mention support for ELF SHF_GNU_MBIND and PT_GNU_MBIND_XXX. * emultempl/elf32.em (gld${EMULATION_NAME}_place_orphan): Place input GNU_MBIND sections with the same type, attributes and sh_info field into a single output GNU_MBIND section. * testsuite/ld-elf/elf.exp: Run mbind2a and mbind2b. * testsuite/ld-elf/mbind1.s: New file. * testsuite/ld-elf/mbind1a.d: Likewise. * testsuite/ld-elf/mbind1b.d: Likewise. * testsuite/ld-elf/mbind1c.d: Likewise. * testsuite/ld-elf/mbind2a.s: Likewise. * testsuite/ld-elf/mbind2b.c: Likewise.
2017-04-05 00:05:48 +08:00
objcopy_test_readelf "GNU_MBIND section" mbind1.s
run_dump_test "group-5"
run_dump_test "group-6"
run_dump_test "group-7a"
run_dump_test "group-7b"
run_dump_test "group-7c"
run_dump_test "copy-1"
run_dump_test "note-1"
# Use copytest.o from the note-1 test to determine ELF32 or ELF64
if [is_elf64 tmpdir/copytest.o] {
binutils testsuite strip-13 test The strip-13 test runs into difficulty using dc.a on some targets. dc.a writes a power of 2 number of bytes large enough to contain a target address. On some targets, eg. avr-elf, this can be 2 bytes but the ELF format used require words of 4 bytes to make up a relocation entry. There was a hack in the test, duplicating the reloc type into what is normally the addend to make the test work when little-endian, but that hack fails for similar big-endian targets. This patch fixes that problem by arranging to emit 32-bit and 64-bit ELF relocs using .4byte and .8byte directives, chosen as appropriate for the ELF size. I've also bumped the reloc number tested to a higher unused value, and made the number more easily parameterised by target should that be necessary in the future. Whether REL or RELA relocs are used is now chosen by a new is_rela readelf test of an object file, rather than by lists of targets. * testsuite/lib/binutils-common.exp (is_elf64): Use directory of input file for readelf.out. (is_rela): New proc. * testsuite/binutils-all/objcopy.exp (elf64): Set new variable from first result of is_elf64 test. (reloc_format): Set using is_rela. (strip-13): Pass RELOC and ELF64 to assembler. (strip-14, strip-15): Use elf64 rather than calling is_elf64 again. * testsuite/binutils-all/strip-13.d: Run for more targets. * testsuite/binutils-all/strip-13mips64.s: Use RELOC and set addend to zero. * testsuite/binutils-all/strip-13rel.s: Use RELOC and ELF64. Don't add _NONE reloc. * testsuite/binutils-all/strip-13rela.s: Likewise.
2018-08-13 12:11:18 +08:00
set elf64 "--defsym ELF64=1"
Add support for displaying and merging GNU_BUILD_NOTEs. include * elf/common.h (SHF_GNU_BUILD_NOTE): Define. (NT_GNU_PROPERTY_TYPE_0): Define. (NT_GNU_BUILD_ATTRIBUTE_OPEN): Define. (NT_GNU_BUILD_ATTRIBUTE_FUN): Define. (GNU_BUILD_ATTRIBUTE_TYPE_NUMERIC): Define. (GNU_BUILD_ATTRIBUTE_TYPE_STRING): Define. (GNU_BUILD_ATTRIBUTE_TYPE_BOOL_TRUE): Define. (GNU_BUILD_ATTRIBUTE_TYPE_BOOL_FALSE): Define. (GNU_BUILD_ATTRIBUTE_VERSION): Define. (GNU_BUILD_ATTRIBUTE_STACK_PROT): Define. (GNU_BUILD_ATTRIBUTE_RELRO): Define. (GNU_BUILD_ATTRIBUTE_STACK_SIZE): Define. (GNU_BUILD_ATTRIBUTE_TOOL): Define. (GNU_BUILD_ATTRIBUTE_ABI): Define. (GNU_BUILD_ATTRIBUTE_PIC): Define. (NOTE_GNU_PROPERTY_SECTION_NAME): Define. (GNU_BUILD_ATTRS_SECTION_NAME): Define. (GNU_PROPERTY_STACK_SIZE): Define. (GNU_PROPERTY_NO_COPY_ON_PROTECTED): Define. (GNU_PROPERTY_X86_ISA_1_USED): Define. (GNU_PROPERTY_X86_ISA_1_NEEDED): Define. (GNU_PROPERTY_X86_ISA_1_486): Define. (GNU_PROPERTY_X86_ISA_1_586): Define. (GNU_PROPERTY_X86_ISA_1_686): Define. (GNU_PROPERTY_X86_ISA_1_SSE): Define. (GNU_PROPERTY_X86_ISA_1_SSE2): Define. (GNU_PROPERTY_X86_ISA_1_SSE3): Define. (GNU_PROPERTY_X86_ISA_1_SSSE3): Define. (GNU_PROPERTY_X86_ISA_1_SSE4_1): Define. (GNU_PROPERTY_X86_ISA_1_SSE4_2): Define. (GNU_PROPERTY_X86_ISA_1_AVX): Define. (GNU_PROPERTY_X86_ISA_1_AVX2): Define. (GNU_PROPERTY_X86_ISA_1_AVX512F): Define. (GNU_PROPERTY_X86_ISA_1_AVX512CD): Define. (GNU_PROPERTY_X86_ISA_1_AVX512ER): Define. (GNU_PROPERTY_X86_ISA_1_AVX512PF): Define. (GNU_PROPERTY_X86_ISA_1_AVX512VL): Define. (GNU_PROPERTY_X86_ISA_1_AVX512DQ): Define. (GNU_PROPERTY_X86_ISA_1_AVX512BW): Define. binutils* readelf.c (get_note_type): Add support for GNU_BUILD_NOTEs. (get_gnu_elf_note_type): Add support for GNU_PROPERTY_NOTEs. (decode_x86_isa): New function. (print_gnu_property_note): New function. (print_gnu_note): Handle GNU_PROPERTY_NOTEs. (print_gnu_build_attribute_description): New function. (print_gnu_build_attribute_name): New function. (process_note): Add support for GNU_BUILD_NOTEs. * objcopy.c (--merge-notes): New command line option. (copy_options): Add merge-notes. (copy_usage): Likewise. (is_merge_note_section): New function. (merge_gnu_build_notes): New function. (copy_object): Merge note sections if asked to do so. (skip_section): Add skip_copy parameter. Add support for skipping merged note sections. (copy_relocations_in_section): Update call to skip_section. (copy_section): Likewise. (copy_main): Add support for merge-notes option. * doc/binutils.texi: Document the new option to objcopy. * NEWS: Mention the new feature. * testsuite/binutils-all/note-2-32.d: New test. Checks note merging on 32-bit targets. * testsuite/binutils-all/note-2-32.s: New test source file. * testsuite/binutils-all/note-2-64.d: New test. Like note-2-32.d but for 64-bit targets. * testsuite/binutils-all/note-2-64.s: New test source file. * testsuite/binutils-all/objcopy.exp: Run the new test.
2017-03-01 19:09:46 +08:00
run_dump_test "note-2-64"
run_dump_test "note-3-64"
Add support for v3 binary annotation notes. I am checking in the attached patch which updates the binutils support for version 3 binary annotation notes. (Version 3 adds an end address to the ranges covered by the notes, so that it is possible to detect gaps in the coverage). This patch also stops the note merging feature of objcopy from executing if the notes have relocations against them. This makes the code simpler, and prevents the problems with architectures which have unusual relocation management issues. * objcopy.c (objcopy_internal_note): New structure. (gap_exists): New function. (is_open_note): New function. (is_func_note): New function. (is_64bit): New function. (merge_gnu_build_notes): Handle v3 notes. Do not merge if there are relocations against the notes. * readelf.c (get_note_type): Use short names for build attribute notes. (print_symbol_for_build_attribute): Rename to get_symbol_for_build_attribute. Returns the found symbol rather than printing it. (print_gnu_build_attribute_description): Maintain address ranges for function notes as well as global notes. Handle v3 notes. (print_gnu_build_attribute_name): Use more space for printing the name in wide mode. * testsuite/binutils-all/note-2-32.s: Use .dc.l instead of .word. Eliminate symbol references in order to remove the need for relocations. * testsuite/binutils-all/note-2-64.s: Likewise. * testsuite/binutils-all/note-3-32.s: Add a size to the note_1 symbol. * testsuite/binutils-all/note-3-64.s: Likewise. * testsuite/binutils-all/mips/mips-note-2r-n32.d: Update expected output. * testsuite/binutils-all/mips/mips-note-2r-n64.d: Likewise. * testsuite/binutils-all/mips/mips-note-2r.d: Likewise. * testsuite/binutils-all/note-2-32.d: Likewise. * testsuite/binutils-all/note-2-64.d: Likewise. * testsuite/binutils-all/note-3-32.d: Likewise. * testsuite/binutils-all/note-3-64.d: Likewise. * testsuite/binutils-all/note-4-64.s: New test. Checks v3 notes. * testsuite/binutils-all/note-4-32.s: New test. * testsuite/binutils-all/note-4-64.d: New test result file. * testsuite/binutils-all/note-4-32.d: New test result file.
2018-01-03 18:28:33 +08:00
run_dump_test "note-4-64"
Improve objcopy's note mergeing capabilities. * objcopy.c (struct merged_note_section): New structure. Used to chain together details of mergeable note sections. (is_merged_note_section): Rename to is_megreable_note_section and return true for note sections that use GNU_BUILD_ATTRS_SECTION_NAME as a prefix. (num_bytes): Delete (objcoopy_internal_note): Add padded_namesz field. (DEBUG_MERGE): New macro. Set to non-zero to enable debugging of the note merging code. (gap_exists): Rename to overlaps_or_adjoins and return TRUE for overlapping notes or adjoining notes. (contained_by, is_deleted_note, is_version_note) (compare_gnu_build_notes, sort_gnu_build_notes): New functions. (merge_gnu_build_notes): Rework. Sort notes into a mergeable order first. Merge them. Then sort them into an ascending address order before writing them out. (copy_object): Handle more than one mergeable note section. * testsuite/binutils-all/note-2-32.d: Update for new merging behaviour. * testsuite/binutils-all/note-2-32.s: Likewise. * testsuite/binutils-all/note-2-64.d: Likewise. * testsuite/binutils-all/note-2-64.s: Likewise. * testsuite/binutils-all/note-3-32.d: Likewise. * testsuite/binutils-all/note-3-32.s: Likewise. * testsuite/binutils-all/note-3-64.d: Likewise. * testsuite/binutils-all/note-3-64.s: Likewise. * testsuite/binutils-all/note-4-32.d: Likewise. * testsuite/binutils-all/note-4-32.s: Likewise. * testsuite/binutils-all/note-4-64.d: Likewise. * testsuite/binutils-all/note-4-64.s: Likewise. * testsuite/binutils-all/note-6-32.s: New test source file. * testsuite/binutils-all/note-6-64.s: New test source file. * testsuite/binutils-all/note-6-32.d: New test driver file. * testsuite/binutils-all/note-6-64.d: New test driver file. * testsuite/binutils-all/objcopy.exp: Run the new test.
2019-10-25 23:46:07 +08:00
run_dump_test "note-6-64"
Add support for displaying and merging GNU_BUILD_NOTEs. include * elf/common.h (SHF_GNU_BUILD_NOTE): Define. (NT_GNU_PROPERTY_TYPE_0): Define. (NT_GNU_BUILD_ATTRIBUTE_OPEN): Define. (NT_GNU_BUILD_ATTRIBUTE_FUN): Define. (GNU_BUILD_ATTRIBUTE_TYPE_NUMERIC): Define. (GNU_BUILD_ATTRIBUTE_TYPE_STRING): Define. (GNU_BUILD_ATTRIBUTE_TYPE_BOOL_TRUE): Define. (GNU_BUILD_ATTRIBUTE_TYPE_BOOL_FALSE): Define. (GNU_BUILD_ATTRIBUTE_VERSION): Define. (GNU_BUILD_ATTRIBUTE_STACK_PROT): Define. (GNU_BUILD_ATTRIBUTE_RELRO): Define. (GNU_BUILD_ATTRIBUTE_STACK_SIZE): Define. (GNU_BUILD_ATTRIBUTE_TOOL): Define. (GNU_BUILD_ATTRIBUTE_ABI): Define. (GNU_BUILD_ATTRIBUTE_PIC): Define. (NOTE_GNU_PROPERTY_SECTION_NAME): Define. (GNU_BUILD_ATTRS_SECTION_NAME): Define. (GNU_PROPERTY_STACK_SIZE): Define. (GNU_PROPERTY_NO_COPY_ON_PROTECTED): Define. (GNU_PROPERTY_X86_ISA_1_USED): Define. (GNU_PROPERTY_X86_ISA_1_NEEDED): Define. (GNU_PROPERTY_X86_ISA_1_486): Define. (GNU_PROPERTY_X86_ISA_1_586): Define. (GNU_PROPERTY_X86_ISA_1_686): Define. (GNU_PROPERTY_X86_ISA_1_SSE): Define. (GNU_PROPERTY_X86_ISA_1_SSE2): Define. (GNU_PROPERTY_X86_ISA_1_SSE3): Define. (GNU_PROPERTY_X86_ISA_1_SSSE3): Define. (GNU_PROPERTY_X86_ISA_1_SSE4_1): Define. (GNU_PROPERTY_X86_ISA_1_SSE4_2): Define. (GNU_PROPERTY_X86_ISA_1_AVX): Define. (GNU_PROPERTY_X86_ISA_1_AVX2): Define. (GNU_PROPERTY_X86_ISA_1_AVX512F): Define. (GNU_PROPERTY_X86_ISA_1_AVX512CD): Define. (GNU_PROPERTY_X86_ISA_1_AVX512ER): Define. (GNU_PROPERTY_X86_ISA_1_AVX512PF): Define. (GNU_PROPERTY_X86_ISA_1_AVX512VL): Define. (GNU_PROPERTY_X86_ISA_1_AVX512DQ): Define. (GNU_PROPERTY_X86_ISA_1_AVX512BW): Define. binutils* readelf.c (get_note_type): Add support for GNU_BUILD_NOTEs. (get_gnu_elf_note_type): Add support for GNU_PROPERTY_NOTEs. (decode_x86_isa): New function. (print_gnu_property_note): New function. (print_gnu_note): Handle GNU_PROPERTY_NOTEs. (print_gnu_build_attribute_description): New function. (print_gnu_build_attribute_name): New function. (process_note): Add support for GNU_BUILD_NOTEs. * objcopy.c (--merge-notes): New command line option. (copy_options): Add merge-notes. (copy_usage): Likewise. (is_merge_note_section): New function. (merge_gnu_build_notes): New function. (copy_object): Merge note sections if asked to do so. (skip_section): Add skip_copy parameter. Add support for skipping merged note sections. (copy_relocations_in_section): Update call to skip_section. (copy_section): Likewise. (copy_main): Add support for merge-notes option. * doc/binutils.texi: Document the new option to objcopy. * NEWS: Mention the new feature. * testsuite/binutils-all/note-2-32.d: New test. Checks note merging on 32-bit targets. * testsuite/binutils-all/note-2-32.s: New test source file. * testsuite/binutils-all/note-2-64.d: New test. Like note-2-32.d but for 64-bit targets. * testsuite/binutils-all/note-2-64.s: New test source file. * testsuite/binutils-all/objcopy.exp: Run the new test.
2017-03-01 19:09:46 +08:00
} else {
run_dump_test "note-2-32"
run_dump_test "note-3-32"
Add support for v3 binary annotation notes. I am checking in the attached patch which updates the binutils support for version 3 binary annotation notes. (Version 3 adds an end address to the ranges covered by the notes, so that it is possible to detect gaps in the coverage). This patch also stops the note merging feature of objcopy from executing if the notes have relocations against them. This makes the code simpler, and prevents the problems with architectures which have unusual relocation management issues. * objcopy.c (objcopy_internal_note): New structure. (gap_exists): New function. (is_open_note): New function. (is_func_note): New function. (is_64bit): New function. (merge_gnu_build_notes): Handle v3 notes. Do not merge if there are relocations against the notes. * readelf.c (get_note_type): Use short names for build attribute notes. (print_symbol_for_build_attribute): Rename to get_symbol_for_build_attribute. Returns the found symbol rather than printing it. (print_gnu_build_attribute_description): Maintain address ranges for function notes as well as global notes. Handle v3 notes. (print_gnu_build_attribute_name): Use more space for printing the name in wide mode. * testsuite/binutils-all/note-2-32.s: Use .dc.l instead of .word. Eliminate symbol references in order to remove the need for relocations. * testsuite/binutils-all/note-2-64.s: Likewise. * testsuite/binutils-all/note-3-32.s: Add a size to the note_1 symbol. * testsuite/binutils-all/note-3-64.s: Likewise. * testsuite/binutils-all/mips/mips-note-2r-n32.d: Update expected output. * testsuite/binutils-all/mips/mips-note-2r-n64.d: Likewise. * testsuite/binutils-all/mips/mips-note-2r.d: Likewise. * testsuite/binutils-all/note-2-32.d: Likewise. * testsuite/binutils-all/note-2-64.d: Likewise. * testsuite/binutils-all/note-3-32.d: Likewise. * testsuite/binutils-all/note-3-64.d: Likewise. * testsuite/binutils-all/note-4-64.s: New test. Checks v3 notes. * testsuite/binutils-all/note-4-32.s: New test. * testsuite/binutils-all/note-4-64.d: New test result file. * testsuite/binutils-all/note-4-32.d: New test result file.
2018-01-03 18:28:33 +08:00
run_dump_test "note-4-32"
Improve objcopy's note mergeing capabilities. * objcopy.c (struct merged_note_section): New structure. Used to chain together details of mergeable note sections. (is_merged_note_section): Rename to is_megreable_note_section and return true for note sections that use GNU_BUILD_ATTRS_SECTION_NAME as a prefix. (num_bytes): Delete (objcoopy_internal_note): Add padded_namesz field. (DEBUG_MERGE): New macro. Set to non-zero to enable debugging of the note merging code. (gap_exists): Rename to overlaps_or_adjoins and return TRUE for overlapping notes or adjoining notes. (contained_by, is_deleted_note, is_version_note) (compare_gnu_build_notes, sort_gnu_build_notes): New functions. (merge_gnu_build_notes): Rework. Sort notes into a mergeable order first. Merge them. Then sort them into an ascending address order before writing them out. (copy_object): Handle more than one mergeable note section. * testsuite/binutils-all/note-2-32.d: Update for new merging behaviour. * testsuite/binutils-all/note-2-32.s: Likewise. * testsuite/binutils-all/note-2-64.d: Likewise. * testsuite/binutils-all/note-2-64.s: Likewise. * testsuite/binutils-all/note-3-32.d: Likewise. * testsuite/binutils-all/note-3-32.s: Likewise. * testsuite/binutils-all/note-3-64.d: Likewise. * testsuite/binutils-all/note-3-64.s: Likewise. * testsuite/binutils-all/note-4-32.d: Likewise. * testsuite/binutils-all/note-4-32.s: Likewise. * testsuite/binutils-all/note-4-64.d: Likewise. * testsuite/binutils-all/note-4-64.s: Likewise. * testsuite/binutils-all/note-6-32.s: New test source file. * testsuite/binutils-all/note-6-64.s: New test source file. * testsuite/binutils-all/note-6-32.d: New test driver file. * testsuite/binutils-all/note-6-64.d: New test driver file. * testsuite/binutils-all/objcopy.exp: Run the new test.
2019-10-25 23:46:07 +08:00
run_dump_test "note-6-32"
Add support for displaying and merging GNU_BUILD_NOTEs. include * elf/common.h (SHF_GNU_BUILD_NOTE): Define. (NT_GNU_PROPERTY_TYPE_0): Define. (NT_GNU_BUILD_ATTRIBUTE_OPEN): Define. (NT_GNU_BUILD_ATTRIBUTE_FUN): Define. (GNU_BUILD_ATTRIBUTE_TYPE_NUMERIC): Define. (GNU_BUILD_ATTRIBUTE_TYPE_STRING): Define. (GNU_BUILD_ATTRIBUTE_TYPE_BOOL_TRUE): Define. (GNU_BUILD_ATTRIBUTE_TYPE_BOOL_FALSE): Define. (GNU_BUILD_ATTRIBUTE_VERSION): Define. (GNU_BUILD_ATTRIBUTE_STACK_PROT): Define. (GNU_BUILD_ATTRIBUTE_RELRO): Define. (GNU_BUILD_ATTRIBUTE_STACK_SIZE): Define. (GNU_BUILD_ATTRIBUTE_TOOL): Define. (GNU_BUILD_ATTRIBUTE_ABI): Define. (GNU_BUILD_ATTRIBUTE_PIC): Define. (NOTE_GNU_PROPERTY_SECTION_NAME): Define. (GNU_BUILD_ATTRS_SECTION_NAME): Define. (GNU_PROPERTY_STACK_SIZE): Define. (GNU_PROPERTY_NO_COPY_ON_PROTECTED): Define. (GNU_PROPERTY_X86_ISA_1_USED): Define. (GNU_PROPERTY_X86_ISA_1_NEEDED): Define. (GNU_PROPERTY_X86_ISA_1_486): Define. (GNU_PROPERTY_X86_ISA_1_586): Define. (GNU_PROPERTY_X86_ISA_1_686): Define. (GNU_PROPERTY_X86_ISA_1_SSE): Define. (GNU_PROPERTY_X86_ISA_1_SSE2): Define. (GNU_PROPERTY_X86_ISA_1_SSE3): Define. (GNU_PROPERTY_X86_ISA_1_SSSE3): Define. (GNU_PROPERTY_X86_ISA_1_SSE4_1): Define. (GNU_PROPERTY_X86_ISA_1_SSE4_2): Define. (GNU_PROPERTY_X86_ISA_1_AVX): Define. (GNU_PROPERTY_X86_ISA_1_AVX2): Define. (GNU_PROPERTY_X86_ISA_1_AVX512F): Define. (GNU_PROPERTY_X86_ISA_1_AVX512CD): Define. (GNU_PROPERTY_X86_ISA_1_AVX512ER): Define. (GNU_PROPERTY_X86_ISA_1_AVX512PF): Define. (GNU_PROPERTY_X86_ISA_1_AVX512VL): Define. (GNU_PROPERTY_X86_ISA_1_AVX512DQ): Define. (GNU_PROPERTY_X86_ISA_1_AVX512BW): Define. binutils* readelf.c (get_note_type): Add support for GNU_BUILD_NOTEs. (get_gnu_elf_note_type): Add support for GNU_PROPERTY_NOTEs. (decode_x86_isa): New function. (print_gnu_property_note): New function. (print_gnu_note): Handle GNU_PROPERTY_NOTEs. (print_gnu_build_attribute_description): New function. (print_gnu_build_attribute_name): New function. (process_note): Add support for GNU_BUILD_NOTEs. * objcopy.c (--merge-notes): New command line option. (copy_options): Add merge-notes. (copy_usage): Likewise. (is_merge_note_section): New function. (merge_gnu_build_notes): New function. (copy_object): Merge note sections if asked to do so. (skip_section): Add skip_copy parameter. Add support for skipping merged note sections. (copy_relocations_in_section): Update call to skip_section. (copy_section): Likewise. (copy_main): Add support for merge-notes option. * doc/binutils.texi: Document the new option to objcopy. * NEWS: Mention the new feature. * testsuite/binutils-all/note-2-32.d: New test. Checks note merging on 32-bit targets. * testsuite/binutils-all/note-2-32.s: New test source file. * testsuite/binutils-all/note-2-64.d: New test. Like note-2-32.d but for 64-bit targets. * testsuite/binutils-all/note-2-64.s: New test source file. * testsuite/binutils-all/objcopy.exp: Run the new test.
2017-03-01 19:09:46 +08:00
}
run_dump_test "note-5"
}
run_dump_test "copy-2"
run_dump_test "copy-3"
run_dump_test "copy-4"
run_dump_test "copy-5"
run_dump_test "copy-6"
binutils testsuite strip-13 test The strip-13 test runs into difficulty using dc.a on some targets. dc.a writes a power of 2 number of bytes large enough to contain a target address. On some targets, eg. avr-elf, this can be 2 bytes but the ELF format used require words of 4 bytes to make up a relocation entry. There was a hack in the test, duplicating the reloc type into what is normally the addend to make the test work when little-endian, but that hack fails for similar big-endian targets. This patch fixes that problem by arranging to emit 32-bit and 64-bit ELF relocs using .4byte and .8byte directives, chosen as appropriate for the ELF size. I've also bumped the reloc number tested to a higher unused value, and made the number more easily parameterised by target should that be necessary in the future. Whether REL or RELA relocs are used is now chosen by a new is_rela readelf test of an object file, rather than by lists of targets. * testsuite/lib/binutils-common.exp (is_elf64): Use directory of input file for readelf.out. (is_rela): New proc. * testsuite/binutils-all/objcopy.exp (elf64): Set new variable from first result of is_elf64 test. (reloc_format): Set using is_rela. (strip-13): Pass RELOC and ELF64 to assembler. (strip-14, strip-15): Use elf64 rather than calling is_elf64 again. * testsuite/binutils-all/strip-13.d: Run for more targets. * testsuite/binutils-all/strip-13mips64.s: Use RELOC and set addend to zero. * testsuite/binutils-all/strip-13rel.s: Use RELOC and ELF64. Don't add _NONE reloc. * testsuite/binutils-all/strip-13rela.s: Likewise.
2018-08-13 12:11:18 +08:00
# Use bintest.o from the copy-4 test to determine ELF reloc type
set reloc_format rel
if { [is_elf_format] && [is_rela tmpdir/bintest.o] } {
set reloc_format rela
}
run_dump_test "pr19020a"
run_dump_test "pr19020b"
if [is_elf_format] {
run_dump_test "strip-1"
run_dump_test "strip-2"
run_dump_test "strip-3"
run_dump_test "strip-4"
run_dump_test "strip-5"
run_dump_test "strip-6"
run_dump_test "strip-7"
run_dump_test "strip-8"
run_dump_test "strip-9"
run_dump_test "strip-12"
binutils/testsuite: Support REL and MIPS64 reloc formats with `strip-13' Add source variants for the `strip-13' test that produce relocations in the REL and MIPS64 formats, fixing a failure for the `mips64el-openbsd' target. This also corrects output for `i*86-*', `i960-*', `m6812-*' and `m68hc12-*', o32 `mips*-*', and `score*-*' targets, which however does not show up as a test result change due to lax error message matching causing `bad value' previously produced by `strip' as a result of input file rejection to be accepted as a test pass. For `m6811-*' aka `m68hc11-*' targets this causes a phantom regression, because they use 16-bit addressing and therefore `.dc.a' emits 16-bit quantities causing relocation data constructed in assembly not to be as expected. Previously input was rejected by `strip' with a `bad value' message and now it is accepted, however due to the relocation data error the relocation number is not one of the unsupported ones and the tool completes successfully, which scores as a test failure. Disable the test case for `m6811-*' and `m68hc11-*' targets then, as it is a test case bug rather than a problem with the relevant backend. A separate change to the test case is required to correct this problem, at which point the test case can be enabled for the affected targets. binutils/ * testsuite/binutils-all/strip-13.s: Rename to... * testsuite/binutils-all/strip-13rela.s: ... this. * testsuite/binutils-all/strip-13rel.s: New test source. * testsuite/binutils-all/strip-13mips64.s: New test source. * testsuite/binutils-all/strip-13.d: Remove `arm-*', `d10v-*', `dlx-*' and `xgate-*' from `not-target' list. Add `m6811-*' and `m68hc11-*' to `not-target' list. * testsuite/binutils-all/objcopy.exp: Switch between sources for `strip-13'.
2018-04-05 20:08:35 +08:00
if { [istarget "mips64*-*-openbsd*"] } {
set reloc_format mips64
}
binutils testsuite strip-13 test The strip-13 test runs into difficulty using dc.a on some targets. dc.a writes a power of 2 number of bytes large enough to contain a target address. On some targets, eg. avr-elf, this can be 2 bytes but the ELF format used require words of 4 bytes to make up a relocation entry. There was a hack in the test, duplicating the reloc type into what is normally the addend to make the test work when little-endian, but that hack fails for similar big-endian targets. This patch fixes that problem by arranging to emit 32-bit and 64-bit ELF relocs using .4byte and .8byte directives, chosen as appropriate for the ELF size. I've also bumped the reloc number tested to a higher unused value, and made the number more easily parameterised by target should that be necessary in the future. Whether REL or RELA relocs are used is now chosen by a new is_rela readelf test of an object file, rather than by lists of targets. * testsuite/lib/binutils-common.exp (is_elf64): Use directory of input file for readelf.out. (is_rela): New proc. * testsuite/binutils-all/objcopy.exp (elf64): Set new variable from first result of is_elf64 test. (reloc_format): Set using is_rela. (strip-13): Pass RELOC and ELF64 to assembler. (strip-14, strip-15): Use elf64 rather than calling is_elf64 again. * testsuite/binutils-all/strip-13.d: Run for more targets. * testsuite/binutils-all/strip-13mips64.s: Use RELOC and set addend to zero. * testsuite/binutils-all/strip-13rel.s: Use RELOC and ELF64. Don't add _NONE reloc. * testsuite/binutils-all/strip-13rela.s: Likewise.
2018-08-13 12:11:18 +08:00
# A relocation type not supported by any target
Andes Technology has good news for you, we plan to update the nds32 port of binutils on upstream! We have not only removed all unsupported and obsolete code, but also supported lost of new features, including better link-time relaxations and TLS implementations. Besides, the files generated by the newly assembler and linker usually get higher performance and more optimized code size. ld * emultempl/nds32elf.em (hyper_relax): New variable. (nds32_elf_create_output_section_statements): the parameters of bfd_elf32_nds32_set_target_option (PARSE_AND_LIST_PROLOGUE, PARSE_AND_LIST_OPTIONS, PARSE_AND_LIST_ARGS_CASES): Add new option --mhyper-relax. * emultempl/nds32elf.em (nds32_elf_after_open): Updated. * emultempl/nds32elf.em (tls_desc_trampoline): New variable. * (nds32_elf_create_output_section_statements): Updated. * (nds32_elf_after_parse): Disable relaxations when PIC is enable. * (PARSE_AND_LIST_PROLOGUE, PARSE_AND_LIST_OPTIONS, PARSE_AND_LIST_ARGS_CASES): Add new option --m[no-]tlsdesc-trampoline. include * elf/nds32.h: Remove the unused target features. * dis-asm.h (disassemble_init_nds32): Declared. * elf/nds32.h (E_NDS32_NULL): Removed. (E_NDS32_HAS_DSP_INST, E_NDS32_HAS_ZOL): New. * opcode/nds32.h: Ident. (N32_SUB6, INSN_LW): New macros. (enum n32_opcodes): Updated. * elf/nds32.h: Doc fixes. * elf/nds32.h: Add R_NDS32_LSI. * elf/nds32.h: Add new relocations for TLS. gas * config/tc-nds32.c: Remove the unused target features. (nds32_relax_relocs, md_pseudo_table, nds32_elf_record_fixup_exp, nds32_set_elf_flags_by_insn, nds32_insert_relax_entry, nds32_apply_fix): Likewise. (nds32_no_ex9_begin): Removed. * config/tc-nds32.c (add_mapping_symbol_for_align, make_mapping_symbol, add_mapping_symbol): New functions. * config/tc-nds32.h (enum mstate): New. (nds32_segment_info_type): Likewise. * configure.ac (--enable-dsp-ext, --enable-zol-ext): New options. * config.in: Regenerated. * configure: Regenerated. * config/tc-nds32.c (nds32_dx_regs): Set the value according to the configuration. (nds32_perf_ext, nds32_perf_ext2, nds32_string_ext, nds32_audio_ext): Likewise. (nds32_dsp_ext): New variable. Set the value according to the configuration. (nds32_zol_ext): Likewise. (asm_desc, nds32_pseudo_opcode_table): Make them static. (nds32_set_elf_flags_by_insn): Updated. (nds32_check_insn_available): Updated. (nds32_str_tolower): New function. * config/tc-nds32.c (relax_table): Updated. (md_begin): Updated. (md_assemble): Use XNEW macro to allocate space for `insn.info', and then remember to free it. (md_section_align): Cast (-1) to ValueT. (nds32_get_align): Cast (~0U) to addressT. (nds32_relax_branch_instructions): Updated. (md_convert_frag): Add new local variable `final_r_type'. (invalid_prev_frag): Add new bfd_boolean parameter `relax'. All callers changed. * config/tc-nds32.c (struct nds32_relocs_pattern): Add `insn' field. (struct nds32_hint_map): Add `option_list' field. (struct suffix_name, suffix_table): Remove the unused `pic' field. (do_pseudo_b, do_pseudo_bal): Remove the suffix checking. (do_pseudo_la_internal, do_pseudo_pushpopm): Indent. (relax_hint_bias, relax_hint_id_current): New static variables. (reset_bias, relax_hint_begin): New variables. (nds_itoa): New function. (CLEAN_REG, GET_OPCODE): New macros. (struct relax_hint_id): New. (nds32_relax_hint): For .relax_hint directive, we can use `begin' and `end' to mark the relax pattern without giving exactly id number. (nds32_elf_append_relax_relocs): Handle the case that the .relax_hint directives are attached to pseudo instruction. (nds32_elf_save_pseudo_pattern): Change the second parameter from instruction's opcode to byte code. (nds32_elf_build_relax_relation): Add new bfd_boolean parameter `pseudo_hint'. (nds32_lookup_pseudo_opcode): Fix the overflow issue. (enum nds32_insn_type): Add N32_RELAX_ALU1 and N32_RELAX_16BIT. (nds32_elf_record_fixup_exp, relax_ls_table, hint_map, nds32_find_reloc_table, nds32_match_hint_insn, nds32_parse_name): Updated. * config/tc-nds32.h (MAX_RELAX_NUM): Extend it to 6. (enum nds32_relax_hint_type): Merge NDS32_RELAX_HINT_LA and NDS32_RELAX_HINT_LS into NDS32_RELAX_HINT_LALS. Add NDS32_RELAX_HINT_LA_PLT, NDS32_RELAX_HINT_LA_GOT and NDS32_RELAX_HINT_LA_GOTOFF. * config/tc-nds32.h (relax_ls_table): Add floating load/store to gp relax pattern. (hint_map, nds32_find_reloc_table): Likewise. * configure.ac: Define NDS32_LINUX_TOOLCHAIN. * configure: Regenerated. * config.in: Regenerated. * config/tc-nds32.h (enum nds32_ramp): Updated. (enum nds32_relax_hint_type): Likewise. * config/tc-nds32.c: Include "errno.h" and "limits.h". (relax_ls_table): Add TLS relax patterns. (nds32_elf_append_relax_relocs): Attach BFD_RELOC_NDS32_GROUP on each instructions of TLS patterns. (nds32_elf_record_fixup_exp): Updated. (nds32_apply_fix): Likewise. (suffix_table): Add TLSDESC suffix. binutils* testsuite/binutils-all/objcopy.exp: Set the unsupported reloc number from 215 to 255 for NDS32. bfd * elf32-nds32.c (nds32_elf_relax_loadstore): Remove the unused target features. (bfd_elf32_nds32_set_target_option): Remove the unused parameters. (nds32_elf_relax_piclo12, nds32_elf_relax_letlslo12, nds32_elf_relax_letlsadd, nds32_elf_relax_letlsls, nds32_elf_relax_pltgot_suff, nds32_elf_relax_got_suff nds32_elf_relax_gotoff_suff, calculate_plt_memory_address, calculate_plt_offset, calculate_got_memory_address, nds32_elf_check_dup_relocs): Removed. All callers changed. * elf32-nds32.h: Remove the unused macros and defines. (elf_nds32_link_hash_table): Remove the unused variable. (bfd_elf32_nds32_set_target_option): Update prototype. (nds32_elf_ex9_init): Removed. * elf32-nds32.c (nds32_convert_32_to_16): Updated. * elf32-nds32.c (HOWTO2, HOWTO3): Define new HOWTO macros to initialize array nds32_elf_howto_table in any order without lots of EMPTY_HOWTO. (nds32_reloc_map): Updated. * reloc.c: Add BFD_RELOC_NDS32_LSI. * bfd-in2.h: Regenerated. * bfd/libbfd.h: Regenerated. * elf32-nds32.c (nds32_elf_relax_howto_table): Add R_NDS32_LSI. (nds32_reloc_map): Likewise. (nds32_elf_relax_flsi): New function. (nds32_elf_relax_section): Support floating load/store relaxation. * elf32-nds32.c (NDS32_GUARD_SEC_P, elf32_nds32_local_gp_offset): New macro. (struct elf_nds32_link_hash_entry): New `offset_to_gp' field. (struct elf_nds32_obj_tdata): New `offset_to_gp' and `hdr_size' fields. (elf32_nds32_allocate_local_sym_info, nds32_elf_relax_guard, nds32_elf_is_target_special_symbol, nds32_elf_maybe_function_sym): New functions. (nds32_info_to_howto_rel): Add BFD_ASSERT. (bfd_elf32_bfd_reloc_type_table_lookup, nds32_elf_link_hash_newfunc, nds32_elf_link_hash_table_create, nds32_elf_relocate_section, nds32_elf_relax_loadstore, nds32_elf_relax_lo12, nds32_relax_adjust_label, bfd_elf32_nds32_set_target_option, nds32_fag_mark_relax): Updated. (nds32_elf_final_sda_base): Improve it to find the better gp value. (insert_nds32_elf_blank): Must consider `len' when inserting blanks. * elf32-nds32.h (bfd_elf32_nds32_set_target_option): Update prototype. (struct elf_nds32_link_hash_table): Add new variable `hyper_relax'. * elf32-nds32.c (elf32_nds32_allocate_dynrelocs): New function. (create_got_section): Likewise. (allocate_dynrelocs, nds32_elf_size_dynamic_sections, nds32_elf_relocate_section, nds32_elf_finish_dynamic_symbol): Updated. (nds32_elf_check_relocs): Fix the issue that the shared library may has TEXTREL entry in the dynamic section. (nds32_elf_create_dynamic_sections): Enable to call readonly_dynrelocs since the TEXTREL issue is fixed in the nds32_elf_check_relocs. (nds32_elf_finish_dynamic_sections): Update and add DT_RELASZ dynamic entry. (calculate_offset): Remove the unused parameter `pic_ext_target' and related codes. All callers changed. (elf_backend_dtrel_excludes_plt): Disable it temporarily since it will cause some errors for our test cases. * elf32-nds32.c (nds32_elf_merge_private_bfd_data): Allow to link the generic object. * reloc.c: Add TLS relocations. * libbfd.h: Regenerated. * bfd-in2.h: Regenerated. * elf32-nds32.h (struct section_id_list_t): New. (elf32_nds32_lookup_section_id, elf32_nds32_check_relax_group, elf32_nds32_unify_relax_group, nds32_elf_unify_tls_model): New prototypes. (elf32_nds32_compute_jump_table_size, elf32_nds32_local_tlsdesc_gotent): New macro. (nds32_insertion_sort, bfd_elf32_nds32_set_target_option, elf_nds32_link_hash_table): Updated. * elf32-nds32.c (enum elf_nds32_tls_type): New. (struct elf32_nds32_relax_group_t, struct relax_group_list_t): New. (elf32_nds32_add_dynreloc, patch_tls_desc_to_ie, get_tls_type, fls, ones32, list_insert, list_insert_sibling, dump_chain, elf32_nds32_check_relax_group, elf32_nds32_lookup_section_id, elf32_nds32_unify_relax_group, nds32_elf_unify_tls_model): New functions. (elf_nds32_obj_tdata): Add new fields. (elf32_nds32_relax_group_ptr, nds32_elf_local_tlsdesc_gotent): New macros. (nds32_elf_howto_table): Add TLS relocations. (nds32_reloc_map): Likewise. (nds32_elf_copy_indirect_symbol, nds32_elf_size_dynamic_sections, nds32_elf_finish_dynamic_symbol, elf32_nds32_allocate_local_sym_info, nds32_elf_relocate_section, bfd_elf32_nds32_set_target_option, nds32_elf_check_relocs, allocate_dynrelocs): Updated. (nds32_elf_relax_section): Call nds32_elf_unify_tls_model. (dtpoff_base): Rename it to `gottpof' and then update it. opcodes * nds32-asm.c (operand_fields): Remove the unused fields. (nds32_opcodes): Remove the unused instructions. * nds32-dis.c (nds32_ex9_info): Removed. (nds32_parse_opcode): Updated. (print_insn_nds32): Likewise. * nds32-asm.c (config.h, stdlib.h, string.h): New includes. (LEX_SET_FIELD, LEX_GET_FIELD): Update defines. (nds32_asm_init, build_operand_hash_table, build_keyword_hash_table, build_opcode_hash_table): New functions. (nds32_keyword_table, nds32_keyword_count_table, nds32_field_table, nds32_opcode_table): New. (hw_ktabs): Declare it to a pointer rather than an array. (build_hash_table): Removed. * nds32-asm.h (enum): Add SYN_INPUT, SYN_OUTPUT, SYN_LOPT, SYN_ROPT and upadte HW_GPR and HW_INT. * nds32-dis.c (keywords): Remove const. (match_field): New function. (nds32_parse_opcode): Updated. * disassemble.c (disassemble_init_for_target): Add disassemble_init_nds32. * nds32-dis.c (eum map_type): New. (nds32_private_data): Likewise. (get_mapping_symbol_type, is_mapping_symbol, nds32_symbol_is_valid, nds32_add_opcode_hash_table, disassemble_init_nds32): New functions. (print_insn_nds32): Updated. * nds32-asm.c (parse_aext_reg): Add new parameter. (parse_re, parse_re2, parse_aext_reg): Only reduced registers are allowed to use. All callers changed. * nds32-asm.c (keyword_usr, keyword_sr): Updated. (operand_fields): Add new fields. (nds32_opcodes): Add new instructions. (keyword_aridxi_mx): New keyword. * nds32-asm.h (enum): Add NASM_ATTR_DSP_ISAEXT, HW_AEXT_ARIDXI_MX and NASM_ATTR_ZOL. (ALU2_1, ALU2_2, ALU2_3): New macros. * nds32-dis.c (nds32_filter_unknown_insn): Updated.
2018-09-20 20:27:31 +08:00
if { [istarget "nds32*-*"] } {
set reloc 255
} else {
set reloc 215
}
binutils testsuite strip-13 test The strip-13 test runs into difficulty using dc.a on some targets. dc.a writes a power of 2 number of bytes large enough to contain a target address. On some targets, eg. avr-elf, this can be 2 bytes but the ELF format used require words of 4 bytes to make up a relocation entry. There was a hack in the test, duplicating the reloc type into what is normally the addend to make the test work when little-endian, but that hack fails for similar big-endian targets. This patch fixes that problem by arranging to emit 32-bit and 64-bit ELF relocs using .4byte and .8byte directives, chosen as appropriate for the ELF size. I've also bumped the reloc number tested to a higher unused value, and made the number more easily parameterised by target should that be necessary in the future. Whether REL or RELA relocs are used is now chosen by a new is_rela readelf test of an object file, rather than by lists of targets. * testsuite/lib/binutils-common.exp (is_elf64): Use directory of input file for readelf.out. (is_rela): New proc. * testsuite/binutils-all/objcopy.exp (elf64): Set new variable from first result of is_elf64 test. (reloc_format): Set using is_rela. (strip-13): Pass RELOC and ELF64 to assembler. (strip-14, strip-15): Use elf64 rather than calling is_elf64 again. * testsuite/binutils-all/strip-13.d: Run for more targets. * testsuite/binutils-all/strip-13mips64.s: Use RELOC and set addend to zero. * testsuite/binutils-all/strip-13rel.s: Use RELOC and ELF64. Don't add _NONE reloc. * testsuite/binutils-all/strip-13rela.s: Likewise.
2018-08-13 12:11:18 +08:00
run_dump_test "strip-13" [list \
[list source strip-13${reloc_format}.s] \
[list as "${elf64} --defsym RELOC=${reloc}"]]
# Select a relocation number that corresponds to one actually
# supported by the target and ABI being tested.
if { [istarget "aarch64*-*"] } {
set reloc 259
} elseif { [istarget "ia64*-*"] \
|| [istarget "m32r*-*"] \
|| [istarget "nds32*-*"] \
|| [istarget "v850*-*"] } {
set reloc 50
} elseif { [istarget "pru-*"] } {
set reloc 11
} else {
set reloc 1
}
run_dump_test "strip-14" [list \
binutils testsuite strip-13 test The strip-13 test runs into difficulty using dc.a on some targets. dc.a writes a power of 2 number of bytes large enough to contain a target address. On some targets, eg. avr-elf, this can be 2 bytes but the ELF format used require words of 4 bytes to make up a relocation entry. There was a hack in the test, duplicating the reloc type into what is normally the addend to make the test work when little-endian, but that hack fails for similar big-endian targets. This patch fixes that problem by arranging to emit 32-bit and 64-bit ELF relocs using .4byte and .8byte directives, chosen as appropriate for the ELF size. I've also bumped the reloc number tested to a higher unused value, and made the number more easily parameterised by target should that be necessary in the future. Whether REL or RELA relocs are used is now chosen by a new is_rela readelf test of an object file, rather than by lists of targets. * testsuite/lib/binutils-common.exp (is_elf64): Use directory of input file for readelf.out. (is_rela): New proc. * testsuite/binutils-all/objcopy.exp (elf64): Set new variable from first result of is_elf64 test. (reloc_format): Set using is_rela. (strip-13): Pass RELOC and ELF64 to assembler. (strip-14, strip-15): Use elf64 rather than calling is_elf64 again. * testsuite/binutils-all/strip-13.d: Run for more targets. * testsuite/binutils-all/strip-13mips64.s: Use RELOC and set addend to zero. * testsuite/binutils-all/strip-13rel.s: Use RELOC and ELF64. Don't add _NONE reloc. * testsuite/binutils-all/strip-13rela.s: Likewise.
2018-08-13 12:11:18 +08:00
[list source strip-14${reloc_format}.s] \
[list as "${elf64} --defsym RELOC=${reloc}"]]
run_dump_test "strip-15" [list \
binutils testsuite strip-13 test The strip-13 test runs into difficulty using dc.a on some targets. dc.a writes a power of 2 number of bytes large enough to contain a target address. On some targets, eg. avr-elf, this can be 2 bytes but the ELF format used require words of 4 bytes to make up a relocation entry. There was a hack in the test, duplicating the reloc type into what is normally the addend to make the test work when little-endian, but that hack fails for similar big-endian targets. This patch fixes that problem by arranging to emit 32-bit and 64-bit ELF relocs using .4byte and .8byte directives, chosen as appropriate for the ELF size. I've also bumped the reloc number tested to a higher unused value, and made the number more easily parameterised by target should that be necessary in the future. Whether REL or RELA relocs are used is now chosen by a new is_rela readelf test of an object file, rather than by lists of targets. * testsuite/lib/binutils-common.exp (is_elf64): Use directory of input file for readelf.out. (is_rela): New proc. * testsuite/binutils-all/objcopy.exp (elf64): Set new variable from first result of is_elf64 test. (reloc_format): Set using is_rela. (strip-13): Pass RELOC and ELF64 to assembler. (strip-14, strip-15): Use elf64 rather than calling is_elf64 again. * testsuite/binutils-all/strip-13.d: Run for more targets. * testsuite/binutils-all/strip-13mips64.s: Use RELOC and set addend to zero. * testsuite/binutils-all/strip-13rel.s: Use RELOC and ELF64. Don't add _NONE reloc. * testsuite/binutils-all/strip-13rela.s: Likewise.
2018-08-13 12:11:18 +08:00
[list source strip-15${reloc_format}.s] \
[list as "${elf64} --defsym RELOC=${reloc}"]]
Have info_to_howto functions return a success/fail status. Check this result. Stop strip from completeing if one of these functions fails. bfd PR 22875 * elf-bfd.h (struct elf_backend_data): Change the return type of the elf_info_to_howto and elf_info_to_howto_rel function pointers to bfd_boolean. * elfcode.h (elf_slurp_reloc_table_from_section): Check the return value from the info_to_howto function and fail if that function failed. * elf32-h8300.c (elf32_h8_relocate_section): Check return value from the info_to_howto function. (elf32_h8_relax_section): Likewise. * elf32-lm32.c (lm32_elf_relocate_section): Likewise. * elf32-m68hc1x.c (elf32_m68hc11_relocate_section): Likewise. * elf32-score.c (s3_bfd_score_elf_relocate_section): Likewise. * elf32-score7.c (s7_bfd_score_elf_relocate_section): Likewise. * elf32-tic6x.c (elf32_tic6x_relocate_section): Likewise. * elf64-ia64-vms.c (elf64_ia64_relocate_section): Likewise. * elf64-sparc.c (elf64_sparc_slurp_one_reloc_table): Likewise. * elf64-x86-64.c (elf_x86_64_tls_transition): Likewise. * elfnn-ia64.c (elfNN_ia64_relocate_section): Likewise. * elfnn-riscv.c (riscv_elf_check_relocs): Likewise. (riscv_elf_relocate_section): Likewise. * elf-hppa.h (elf_hppa_info_to_howto): Change return type to bfd_boolean. Issue an error message, set an error value and return FALSE if the reloc is not recognized. (elf_hppa_info_to_howto_rel): Likewise. * elf-m10200.c (mn10200_info_to_howto): Likewise. * elf-m10300.c (mn10300_info_to_howto): Likewise. * elf.c (_bfd_elf_no_info_to_howto): Likewise. * elf32-arc.c (arc_info_to_howto_rel): Likewise. * elf32-arm.c (elf32_arm_info_to_howto): Likewise. * elf32-avr.c (avr_info_to_howto_rela): Likewise. * elf32-bfin.c (bfin_info_to_howto): Likewise. * elf32-cr16.c (elf_cr16_info_to_howto): Likewise. * elf32-cr16c.c (elf_cr16c_info_to_howto): Likewise. * elf32-cris.c (elf_cr16c_info_to_howto_rel, cris_info_to_howto_rela): Likewise. * elf32-crx.c (elf_crx_info_to_howto): Likewise. * elf32-d10v.c (d10v_info_to_howto_rel): Likewise. * elf32-d30v.c (d30v_info_to_howto_rel, d30v_info_to_howto_rela): Likewise. * elf32-dlx.c (dlx_rtype_to_howto, elf32_dlx_info_to_howto, elf32_dlx_info_to_howto_rel): Likewise. * elf32-epiphany.c (epiphany_info_to_howto_rela): Likewise. * elf32-fr30.c (fr30_info_to_howto_rela): Likewise. * elf32-frv.c (frv_info_to_howto_rela, frvfdpic_info_to_howto_rel): Likewise. * elf32-ft32.c (ft32_info_to_howto_rela): Likewise. * elf32-gen.c (elf_generic_info_to_howto, elf_generic_info_to_howto_rel): Likewise. * elf32-h8300.c (elf32_h8_info_to_howto, elf32_h8_info_to_howto_rel): Likewise. * elf32-i370.c (i370_elf_info_to_howto): Likewise. * elf32-i386.c (elf_i386_reloc_type_lookup, elf_i386_rtype_to_howto, elf_i386_info_to_howto_rel): Likewise. * elf32-i860.c (lookup_howto, elf32_i860_info_to_howto_rela): Likewise. * elf32-i960.c (elf32_i960_info_to_howto_rel): Likewise. * elf32-ip2k.c (ip2k_info_to_howto_rela): Likewise. * elf32-iq2000.c (iq2000_info_to_howto_rela): Likewise. * elf32-lm32.c (lm32_info_to_howto_rela): Likewise. * elf32-m32c.c (m32c_info_to_howto_rela): Likewise. * elf32-m32r.c (m32r_info_to_howto_rel, m32r_info_to_howto): Likewise. * elf32-m68hc11.c (m68hc11_info_to_howto_rel): Likewise. * elf32-m68hc12.c (m68hc11_info_to_howto_rel): Likewise. * elf32-m68k.c (rtype_to_howto): Likewise. * elf32-mcore.c (mcore_elf_info_to_howto): Likewise. * elf32-mep.c (mep_info_to_howto_rela): Likewise. * elf32-metag.c (metag_info_to_howto_rela): Likewise. * elf32-microblaze.c (microblaze_elf_info_to_howto): Likewise. * elf32-mips.c (mips_info_to_howto_rel, mips_info_to_howto_rela): Likewise. * elf32-moxie.c (moxie_info_to_howto_rela): Likewise. * elf32-msp430.c (msp430_info_to_howto_rela): Likewise. * elf32-mt.c (mt_info_to_howto_rela): Likewise. * elf32-nds32.c (nds32_info_to_howto_rel, nds32_info_to_howto): Likewise. * elf32-nios2.c (nios2_elf32_info_to_howto): Likewise. * elf32-or1k.c (or1k_info_to_howto_rela): Likewise. * elf32-pj.c (pj_elf_info_to_howto): Likewise. * elf32-ppc.c (ppc_elf_info_to_howto): Likewise. * elf32-pru.c (pru_elf32_info_to_howto): Likewise. * elf32-rl78.c (rl78_info_to_howto_rela): Likewise. * elf32-rx.c (rx_info_to_howto_rela): Likewise. * elf32-s390.c (elf_s390_info_to_howto): Likewise. * elf32-score.c (s3_bfd_score_info_to_howto, _bfd_score_info_to_howto): Likewise. * elf32-score7.c (s7_bfd_score_info_to_howto): Likewise. * elf32-sh.c (sh_elf_info_to_howto): Likewise. * elf32-spu.c (spu_elf_info_to_howto): Likewise. * elf32-tic6x.c (elf32_tic6x_info_to_howto, elf32_tic6x_info_to_howto_rel): Likewise. * elf32-tilepro.c (tilepro_info_to_howto_rela): Likewise. * elf32-v850.c (v850_elf_info_to_howto_rel, v850_elf_info_to_howto_rela, v800_elf_info_to_howto): Likewise. * elf32-vax.c (rtype_to_howto): Likewise. * elf32-visium.c (visium_info_to_howto_rela): Likewise. * elf32-wasm32.c (elf32_wasm32_rtype_to_howto, elf32_wasm32_info_to_howto_rela): Likewise. * elf32-xc16x.c (elf32_xc16x_info_to_howto): Likewise. * elf32-xgate.c (xgate_info_to_howto_rel): Likewise. * elf32-xstormy16.c (xstormy16_info_to_howto_rela): Likewise. * elf32-xtensa.c (elf_xtensa_info_to_howto_rela): Likewise. * elf64-alpha.c (elf64_alpha_info_to_howto): Likewise. * elf64-gen.c (elf_generic_info_to_howto, elf_generic_info_to_howto_rel): Likewise. * elf64-ia64-vms.c (elf64_ia64_info_to_howto): Likewise. * elf64-mips.c (mips_elf64_info_to_howto_rela): Likewise. * elf64-mmix.c (mmix_info_to_howto_rela): Likewise. * elf64-ppc.c (ppc64_elf_info_to_howto): Likewise. * elf64-s390.c (elf_s390_reloc_type_lookup): Likewise. * elf64-sh64.c (elf_s390_info_to_howto, sh_elf64_info_to_howto): Likewise. * elf64-x86-64.c (elf_x86_64_info_to_howto): Likewise. * elfn32-mips.c (mips_info_to_howto_rel, mips_info_to_howto_rela): Likewise. * elfnn-aarch64.c (elfNN_aarch64_info_to_howto): Likewise. * elfnn-ia64.c (elfNN_ia64_info_to_howto): Likewise. * elfnn-riscv.c (riscv_info_to_howto_rela): Likewise. * elfxx-ia64.c (ia64_elf_reloc_type_lookup): Likewise. * elfxx-sparc.c (_bfd_sparc_elf_info_to_howto): Likewise. * elfxx-tilegx.c (tilegx_info_to_howto_rela): Likewise. * elf32-score.h (s7_bfd_score_info_to_howto): Update prototype. * elfxx-sparc.h (_bfd_sparc_elf_info_to_howto): Update prototype. * elfxx-tilegx.h (tilegx_info_to_howto_rela): Update prototype. * elfxx-target.h (elf_info_to_howto, elf_info_to_howto_rel): Default to NULL. binutils PR 22875 * objcopy.c (copy_object): Check the error status after marking symbols used in relocations. * testsuite/binutils-all/strip-13.s: New test source file. * testsuite/binutils-all/strip-13.s: New test driver file. * testsuite/binutils-all/objcopy.exp: Run the new test.
2018-02-27 18:15:13 +08:00
# This requires STB_GNU_UNIQUE support with OSABI set to GNU.
if { [supports_gnu_unique] } {
run_dump_test "strip-10"
}
Remove sh5 and sh64 support include/ * dis-asm.h: Remove sh5 and sh64 support. bfd/ * Makefile.am: Remove sh5 and sh64 support. * archures.c: Likewise. * config.bfd: Likewise. * configure.ac: Likewise. * cpu-sh.c: Likewise. * elf32-sh-relocs.h: Likewise. * elf32-sh.c: Likewise. * targets.c: Likewise. * elf32-sh64-com.c: Delete. * elf32-sh64.c: Delete. * elf32-sh64.h: Delete. * elf64-sh64.c: Delete. * Makefile.in: Regenerate. * bfd-in2.h: Regenerate. * configure: Regenerate. * po/SRC-POTFILES.in: Regenerate. opcodes/ * Makefile.am: Remove sh5 and sh64 support. * configure.ac: Likewise. * disassemble.c: Likewise. * disassemble.h: Likewise. * sh-dis.c: Likewise. * sh64-dis.c: Delete. * sh64-opc.c: Delete. * sh64-opc.h: Delete. * Makefile.in: Regenerate. * configure: Regenerate. * po/POTFILES.in: Regenerate. bintuils/ * testsuite/binutils-all/objcopy.exp: Remove sh5 and sh64 support. gas/ * Makefile.am: Remove sh5 and sh64 support. * config/tc-sh.c: Likewise. * configure.tgt: Likewise. * doc/Makefile.am: Likewise. * doc/as.texinfo: Likewise. * testsuite/gas/cfi/cfi.exp: Likewise. * testsuite/gas/sh/basic.exp: Likewise. * config/tc-sh64.c: Delete. * config/tc-sh64.h: Delete. * doc/c-sh64.texi: Delete. * testsuite/gas/sh/sh64/abi-32.d: Delete. * testsuite/gas/sh/sh64/abi-32.s: Delete. * testsuite/gas/sh/sh64/abi-64.d: Delete. * testsuite/gas/sh/sh64/abi-64.s: Delete. * testsuite/gas/sh/sh64/basic-1.d: Delete. * testsuite/gas/sh/sh64/basic-1.s: Delete. * testsuite/gas/sh/sh64/case-1.d: Delete. * testsuite/gas/sh/sh64/case-1.s: Delete. * testsuite/gas/sh/sh64/case-noexp-1.d: Delete. * testsuite/gas/sh/sh64/crange1-1.d: Delete. * testsuite/gas/sh/sh64/crange1-2.d: Delete. * testsuite/gas/sh/sh64/crange1.s: Delete. * testsuite/gas/sh/sh64/crange2-1.d: Delete. * testsuite/gas/sh/sh64/crange2-2.d: Delete. * testsuite/gas/sh/sh64/crange2-noexp-1.d: Delete. * testsuite/gas/sh/sh64/crange2.s: Delete. * testsuite/gas/sh/sh64/crange3-1.d: Delete. * testsuite/gas/sh/sh64/crange3.s: Delete. * testsuite/gas/sh/sh64/crange4-1.d: Delete. * testsuite/gas/sh/sh64/crange4.s: Delete. * testsuite/gas/sh/sh64/crange5-1.d: Delete. * testsuite/gas/sh/sh64/crange5.s: Delete. * testsuite/gas/sh/sh64/creg-1.d: Delete. * testsuite/gas/sh/sh64/creg-1.s: Delete. * testsuite/gas/sh/sh64/creg-2.d: Delete. * testsuite/gas/sh/sh64/creg-2.s: Delete. * testsuite/gas/sh/sh64/datal-1.s: Delete. * testsuite/gas/sh/sh64/datal-2.d: Delete. * testsuite/gas/sh/sh64/datal-2.s: Delete. * testsuite/gas/sh/sh64/datal-3.s: Delete. * testsuite/gas/sh/sh64/datal32-1.d: Delete. * testsuite/gas/sh/sh64/datal32-3.d: Delete. * testsuite/gas/sh/sh64/datal64-1.d: Delete. * testsuite/gas/sh/sh64/datal64-3.d: Delete. * testsuite/gas/sh/sh64/eh-1.d: Delete. * testsuite/gas/sh/sh64/eh-1.s: Delete. * testsuite/gas/sh/sh64/endian-1.d: Delete. * testsuite/gas/sh/sh64/endian-1.s: Delete. * testsuite/gas/sh/sh64/endian-2.d: Delete. * testsuite/gas/sh/sh64/endian-2.s: Delete. * testsuite/gas/sh/sh64/err-1.s: Delete. * testsuite/gas/sh/sh64/err-2.s: Delete. * testsuite/gas/sh/sh64/err-3.s: Delete. * testsuite/gas/sh/sh64/err-4.s: Delete. * testsuite/gas/sh/sh64/err-abi-32.s: Delete. * testsuite/gas/sh/sh64/err-abi-64.s: Delete. * testsuite/gas/sh/sh64/err-dsp.s: Delete. * testsuite/gas/sh/sh64/err-movi-noexp-1.s: Delete. * testsuite/gas/sh/sh64/err-noexp-cmd1.s: Delete. * testsuite/gas/sh/sh64/err-pt-1.s: Delete. * testsuite/gas/sh/sh64/err-pt32-cmd1.s: Delete. * testsuite/gas/sh/sh64/err-pt32-cmd2.s: Delete. * testsuite/gas/sh/sh64/err-pt32-cmd3.s: Delete. * testsuite/gas/sh/sh64/err-ptb-1.s: Delete. * testsuite/gas/sh/sh64/err-ptb-2.s: Delete. * testsuite/gas/sh/sh64/err.exp: Delete. * testsuite/gas/sh/sh64/immexpr1.s: Delete. * testsuite/gas/sh/sh64/immexpr2.s: Delete. * testsuite/gas/sh/sh64/immexpr32-1.d: Delete. * testsuite/gas/sh/sh64/immexpr32-2.d: Delete. * testsuite/gas/sh/sh64/immexpr64-1.d: Delete. * testsuite/gas/sh/sh64/immexpr64-2.d: Delete. * testsuite/gas/sh/sh64/lineno.d: Delete. * testsuite/gas/sh/sh64/lineno.s: Delete. * testsuite/gas/sh/sh64/localcom-1.d: Delete. * testsuite/gas/sh/sh64/localcom-1.s: Delete. * testsuite/gas/sh/sh64/mix-1.d: Delete. * testsuite/gas/sh/sh64/mix-1.s: Delete. * testsuite/gas/sh/sh64/mix-noexp-1.d: Delete. * testsuite/gas/sh/sh64/movi-1.s: Delete. * testsuite/gas/sh/sh64/movi-2.s: Delete. * testsuite/gas/sh/sh64/movi-3.d: Delete. * testsuite/gas/sh/sh64/movi-3.s: Delete. * testsuite/gas/sh/sh64/movi32-1.d: Delete. * testsuite/gas/sh/sh64/movi32-2.d: Delete. * testsuite/gas/sh/sh64/movi32-noexp-2.d: Delete. * testsuite/gas/sh/sh64/movi64-1.d: Delete. * testsuite/gas/sh/sh64/movi64-2.d: Delete. * testsuite/gas/sh/sh64/movi64-2.s: Delete. * testsuite/gas/sh/sh64/movi64-3.d: Delete. * testsuite/gas/sh/sh64/movi64-noexp-2.d: Delete. * testsuite/gas/sh/sh64/pt-1.d: Delete. * testsuite/gas/sh/sh64/pt-1.s: Delete. * testsuite/gas/sh/sh64/pt-2.s: Delete. * testsuite/gas/sh/sh64/pt-noexp-1.d: Delete. * testsuite/gas/sh/sh64/pt32-1.d: Delete. * testsuite/gas/sh/sh64/pt32-noexp-2.d: Delete. * testsuite/gas/sh/sh64/pt64-1.d: Delete. * testsuite/gas/sh/sh64/pt64-32-1.d: Delete. * testsuite/gas/sh/sh64/pt64-32-2.d: Delete. * testsuite/gas/sh/sh64/pt64-noexp-2.d: Delete. * testsuite/gas/sh/sh64/ptc-1.s: Delete. * testsuite/gas/sh/sh64/ptc32-1.d: Delete. * testsuite/gas/sh/sh64/ptc32-noexp-1.d: Delete. * testsuite/gas/sh/sh64/ptc64-1.d: Delete. * testsuite/gas/sh/sh64/ptc64-32-1.d: Delete. * testsuite/gas/sh/sh64/ptc64-noexp-1.d: Delete. * testsuite/gas/sh/sh64/ptext-1.s: Delete. * testsuite/gas/sh/sh64/ptext32-1.d: Delete. * testsuite/gas/sh/sh64/ptext32-noexp-1.d: Delete. * testsuite/gas/sh/sh64/ptext64-1.d: Delete. * testsuite/gas/sh/sh64/ptext64-32-1.d: Delete. * testsuite/gas/sh/sh64/ptext64-noexp-1.d: Delete. * testsuite/gas/sh/sh64/rel-1.s: Delete. * testsuite/gas/sh/sh64/rel-2.s: Delete. * testsuite/gas/sh/sh64/rel-3.s: Delete. * testsuite/gas/sh/sh64/rel-4.s: Delete. * testsuite/gas/sh/sh64/rel-5.s: Delete. * testsuite/gas/sh/sh64/rel32-1.d: Delete. * testsuite/gas/sh/sh64/rel32-2.d: Delete. * testsuite/gas/sh/sh64/rel32-3.d: Delete. * testsuite/gas/sh/sh64/rel32-4.d: Delete. * testsuite/gas/sh/sh64/rel32-5.d: Delete. * testsuite/gas/sh/sh64/rel64-1.d: Delete. * testsuite/gas/sh/sh64/rel64-2.d: Delete. * testsuite/gas/sh/sh64/rel64-3.d: Delete. * testsuite/gas/sh/sh64/rel64-4.d: Delete. * testsuite/gas/sh/sh64/rel64-5.d: Delete. * testsuite/gas/sh/sh64/relax-1.d: Delete. * testsuite/gas/sh/sh64/relax-1.s: Delete. * testsuite/gas/sh/sh64/relax-2.d: Delete. * testsuite/gas/sh/sh64/relax-2.s: Delete. * testsuite/gas/sh/sh64/relax-3.d: Delete. * testsuite/gas/sh/sh64/relax-3.s: Delete. * testsuite/gas/sh/sh64/sh64.exp: Delete. * testsuite/gas/sh/sh64/shift-1.s: Delete. * testsuite/gas/sh/sh64/shift-2.s: Delete. * testsuite/gas/sh/sh64/shift-3.s: Delete. * testsuite/gas/sh/sh64/shift32-1.d: Delete. * testsuite/gas/sh/sh64/shift32-3.d: Delete. * testsuite/gas/sh/sh64/shift32-noexp-3.d: Delete. * testsuite/gas/sh/sh64/shift64-1.d: Delete. * testsuite/gas/sh/sh64/shift64-2.d: Delete. * testsuite/gas/sh/sh64/shift64-3.d: Delete. * testsuite/gas/sh/sh64/shift64-noexp-3.d: Delete. * testsuite/gas/sh/sh64/syntax-1.d: Delete. * testsuite/gas/sh/sh64/syntax-1.s: Delete. * testsuite/gas/sh/sh64/syntax-2.d: Delete. * testsuite/gas/sh/sh64/syntax-2.s: Delete. * testsuite/gas/sh/sh64/ua-1.s: Delete. * testsuite/gas/sh/sh64/ua32-1.d: Delete. * testsuite/gas/sh/sh64/ua64-1.d: Delete. * Makefile.in: Regenerate. * doc/Makefile.in: Regenerate. * po/POTFILES.in: Regenerate. ld/ * Makefile.am: Remove sh5 and sh64 support. * configure.tgt: Likewise. * ldlang.c: Likewise. * testsuite/ld-elfcomm/elfcomm.exp: Likewise. * testsuite/ld-gc/gc.exp: Likewise. * testsuite/ld-gc/pr13683.d: Likewise. * testsuite/ld-scripts/crossref.exp: Likewise. * testsuite/ld-selective/selective.exp: Likewise. * testsuite/ld-sh/ld-r-1.d: Likewise. * testsuite/ld-sh/rd-sh.exp: Likewise. * testsuite/ld-sh/sh.exp: Likewise. * testsuite/ld-srec/srec.exp: Likewise. * testsuite/ld-undefined/undefined.exp: Likewise. * emulparams/shelf32.sh: Delete. * emulparams/shelf32_linux.sh: Delete. * emulparams/shelf32_nbsd.sh: Delete. * emulparams/shelf64.sh: Delete. * emulparams/shelf64_nbsd.sh: Delete. * emulparams/shlelf32.sh: Delete. * emulparams/shlelf32_linux.sh: Delete. * emulparams/shlelf32_nbsd.sh: Delete. * emulparams/shlelf64.sh: Delete. * emulparams/shlelf64_nbsd.sh: Delete. * emultempl/sh64elf.em: Delete. * testsuite/ld-sh/sh64/abi32.sd: Delete. * testsuite/ld-sh/sh64/abi32.xd: Delete. * testsuite/ld-sh/sh64/abi64.sd: Delete. * testsuite/ld-sh/sh64/abi64.xd: Delete. * testsuite/ld-sh/sh64/abixx-noexp.sd: Delete. * testsuite/ld-sh/sh64/cmpct1.sd: Delete. * testsuite/ld-sh/sh64/cmpct1.xd: Delete. * testsuite/ld-sh/sh64/crange-1.s: Delete. * testsuite/ld-sh/sh64/crange-2a.s: Delete. * testsuite/ld-sh/sh64/crange-2b.s: Delete. * testsuite/ld-sh/sh64/crange-2c.s: Delete. * testsuite/ld-sh/sh64/crange-2d.s: Delete. * testsuite/ld-sh/sh64/crange-2e.s: Delete. * testsuite/ld-sh/sh64/crange-2f.s: Delete. * testsuite/ld-sh/sh64/crange-2g.s: Delete. * testsuite/ld-sh/sh64/crange-2h.s: Delete. * testsuite/ld-sh/sh64/crange-2i.s: Delete. * testsuite/ld-sh/sh64/crange1.rd: Delete. * testsuite/ld-sh/sh64/crange2.rd: Delete. * testsuite/ld-sh/sh64/crange3-cmpct.rd: Delete. * testsuite/ld-sh/sh64/crange3-media.rd: Delete. * testsuite/ld-sh/sh64/crange3.dd: Delete. * testsuite/ld-sh/sh64/crange3.rd: Delete. * testsuite/ld-sh/sh64/crangerel1.rd: Delete. * testsuite/ld-sh/sh64/crangerel2.rd: Delete. * testsuite/ld-sh/sh64/dlsection-1.s: Delete. * testsuite/ld-sh/sh64/dlsection.sd: Delete. * testsuite/ld-sh/sh64/endian.dbd: Delete. * testsuite/ld-sh/sh64/endian.dld: Delete. * testsuite/ld-sh/sh64/endian.ld: Delete. * testsuite/ld-sh/sh64/endian.s: Delete. * testsuite/ld-sh/sh64/endian.sbd: Delete. * testsuite/ld-sh/sh64/endian.sld: Delete. * testsuite/ld-sh/sh64/gotplt.d: Delete. * testsuite/ld-sh/sh64/gotplt.map: Delete. * testsuite/ld-sh/sh64/gotplt.s: Delete. * testsuite/ld-sh/sh64/init-cmpct.d: Delete. * testsuite/ld-sh/sh64/init-media.d: Delete. * testsuite/ld-sh/sh64/init.s: Delete. * testsuite/ld-sh/sh64/init64.d: Delete. * testsuite/ld-sh/sh64/mix1-noexp.sd: Delete. * testsuite/ld-sh/sh64/mix1.sd: Delete. * testsuite/ld-sh/sh64/mix1.xd: Delete. * testsuite/ld-sh/sh64/mix2-noexp.sd: Delete. * testsuite/ld-sh/sh64/mix2.sd: Delete. * testsuite/ld-sh/sh64/mix2.xd: Delete. * testsuite/ld-sh/sh64/rd-sh64.exp: Delete. * testsuite/ld-sh/sh64/rel-1.s: Delete. * testsuite/ld-sh/sh64/rel-2.s: Delete. * testsuite/ld-sh/sh64/rel32.xd: Delete. * testsuite/ld-sh/sh64/rel64.xd: Delete. * testsuite/ld-sh/sh64/relax.exp: Delete. * testsuite/ld-sh/sh64/relax1.s: Delete. * testsuite/ld-sh/sh64/relax2.s: Delete. * testsuite/ld-sh/sh64/relax3.s: Delete. * testsuite/ld-sh/sh64/relax4.s: Delete. * testsuite/ld-sh/sh64/reldl-1.s: Delete. * testsuite/ld-sh/sh64/reldl-2.s: Delete. * testsuite/ld-sh/sh64/reldl32.rd: Delete. * testsuite/ld-sh/sh64/reldl64.rd: Delete. * testsuite/ld-sh/sh64/relfail.exp: Delete. * testsuite/ld-sh/sh64/relfail.s: Delete. * testsuite/ld-sh/sh64/sh64-1.s: Delete. * testsuite/ld-sh/sh64/sh64-2.s: Delete. * testsuite/ld-sh/sh64/sh64.exp: Delete. * testsuite/ld-sh/sh64/shcmp-1.s: Delete. * testsuite/ld-sh/sh64/shdl-1.s: Delete. * testsuite/ld-sh/sh64/shdl-2.s: Delete. * testsuite/ld-sh/sh64/shdl32.xd: Delete. * testsuite/ld-sh/sh64/shdl64.sd: Delete. * testsuite/ld-sh/sh64/shdl64.xd: Delete. * testsuite/ld-sh/sh64/shmix-1.s: Delete. * testsuite/ld-sh/sh64/shmix-2.s: Delete. * testsuite/ld-sh/sh64/shmix-3.s: Delete. * testsuite/ld-sh/sh64/stobin-0-dso.d: Delete. * testsuite/ld-sh/sh64/stobin-1.d: Delete. * testsuite/ld-sh/sh64/stobin.s: Delete. * testsuite/ld-sh/sh64/stolib.s: Delete. * Makefile.in: Regenerate. * po/BLD-POTFILES.in: Regenerate.
2018-04-16 13:59:39 +08:00
run_dump_test "strip-11"
if { [istarget "i*86-*"] || [istarget "x86_64-*-*"] } {
# Check to make sure we don't strip a symbol named in relocations.
set test "objcopy keeps symbols needed by relocs"
set srcfile $srcdir/$subdir/needed-by-reloc.s
if {![binutils_assemble $srcfile tmpdir/bintest.o]} then {
unsupported $test
} else {
set got [binutils_run $OBJCOPY "$OBJCOPYFLAGS --strip-symbol=foo tmpdir/bintest.o ${copyfile}.o"]
if [regexp "not stripping symbol `foo' because it is named in a relocation" $got] {
pass $test
} else {
fail $test
}
}
}
# 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.
if { [is_bad_symtab] } then {
setup_xfail "*-*-*"
}
run_dump_test "localize-hidden-1"
run_dump_test "testranges"
run_dump_test "testranges-ia64"
run_dump_test "add-section"
run_dump_test "add-symbol"
run_dump_test "add-empty-section"
Implement generic SHF_EXCLUDE. bfd/ 2010-05-18 H.J. Lu <hongjiu.lu@intel.com> PR gas/11600 * elf.c (_bfd_elf_make_section_from_shdr): Handle SHF_EXCLUDE (elf_fake_sections): Likewise. * elf32-i370.c (i370_elf_section_from_shdr): Don't handle SHF_EXCLUDE here. * elf32-ppc.c (ppc_elf_fake_sections): Likewise. binutils/ 2010-05-18 H.J. Lu <hongjiu.lu@intel.com> PR gas/11600 * readelf.c (get_elf_section_flags): Treat SHF_EXCLUDE as a generic flag. binutils/testsuite/ 2010-05-18 H.J. Lu <hongjiu.lu@intel.com> PR gas/11600 * binutils-all/objcopy.exp: Run exclude-1a and exclude-1b for ELF targets. * binutils-all/exclude-1.s: New. * binutils-all/exclude-1a.d: Likewise. * binutils-all/exclude-1b.d: Likewise. gas/ 2010-05-18 H.J. Lu <hongjiu.lu@intel.com> PR gas/11600 * obj-elf.c (obj_elf_change_section): Handle SHF_EXCLUDE. (obj_elf_parse_section_letters): Likewise. (obj_elf_section_word): Likewise. * config/tc-ppc.c (ppc_section_letter): Removed. (ppc_section_word): Likewise. * config/tc-ppc.h (ppc_section_letter): Likewise. (ppc_section_word): Likewise. (md_elf_section_letter): Likewise. (md_elf_section_word): Likewise. * doc/as.texinfo: Document `e' and `#exclude'. gas/testsuite/ 2010-05-18 H.J. Lu <hongjiu.lu@intel.com> PR gas/11600 * gas/elf/elf.exp: Run section8. * gas/elf/section8.d: New. * gas/elf/section8.s: Likewise. include/elf/ 2010-05-18 H.J. Lu <hongjiu.lu@intel.com> PR gas/11600 * common.h (SHF_EXCLUDE): New. * i370.h (SHF_EXCLUDE): Removed. * or32.h (SHF_EXCLUDE): Likewise. * ppc.h (SHF_EXCLUDE): Likewise. * sparc.h (SHF_EXCLUDE): Likewise. ld/testsuite/ 2010-05-18 H.J. Lu <hongjiu.lu@intel.com> PR gas/11600 * ld-elf/exclude3.s: New. * ld-elf/exclude3a.d: Likewise. * ld-elf/exclude3b.d: Likewise. * ld-elf/exclude3c.d: Likewise.
2010-05-18 11:31:07 +08:00
run_dump_test "exclude-1a"
run_dump_test "exclude-1b"
run_dump_test "only-section-01"
run_dump_test "remove-section-01"
objcopy/strip: Add option --remove-relocations=SECTIONPATTERN The objcopy and strip tools make use of the bfd library to manipulate the state of the input file (to produce an output file). Within the input file (for ELF at least), relocations are held within a section, and so, if the user wanted to remove the relocations, but keep the section to which the relocations would have been applied, it is tempting to think that specifying the name of a relocation section to objcopy's --remove-section option might do what you want, for example: objcopy --remove-section=.rela.text input.elf output.elf However, this does not work. The reason is that when the input file is loaded, relocations are not managed as sections, but are, instead, loaded as data associated with the section to which the relocations would be applied. In our example above the relocations in '.rela.text' are held as data on the section '.text' once 'input.elf' is loaded. One task that objcopy and strip do is copy the relocations from the input file to the output file if the section is also being copied from the input file to the output file. This commit adds a new command line option for objcopy and strip, --remove-relocations, which can be used to remove the relocations, while keeping the section that the relocations would have been applied to, for example: objcopy --remove-relocations=.text input.elf output.elf in this case the section '.text' will appear in both 'input.elf' and 'output.elf', but any relocations in 'input.elf' that apply to '.text' will not be present in 'output.elf'. I have also added a special case to the handling of --remove-section that spots if a user tries to remove a relocation section (currently this is done by spotting the '.rela.' or '.rel.' prefix) and forwards the request to --remove-relocations. As with --remove-section and --only-section the --remove-relocations option supports the '!' prefix on the section-patterns it takes to allow for sections to be specifically not matched. There are tests for all the new functionality. binutils/ChangeLog: * doc/binutils.texi (objcopy): Document 'remove-relocations'. (strip): Likewise. * objcopy.c (SECTION_CONTEXT_REMOVE_RELOCS): Define. (enum command_line_switch): Add 'OPTION_REMOVE_RELOCS'. (struct option strip_options): Add 'remove-relocations'. (struct option copy_options): Likewise. (copy_usage): Likewise. (strip_usage): Likewise. (handle_remove_relocations_option): New function. (discard_relocations): New function. (handle_remove_section_option): New function. (copy_relocations_in_section): Use discard_relocations. (strip_main): Use handle_remove_section_option for 'remove-section', and handle 'remove-relocations' option. (copy_main): Likewise. * testsuite/binutils-all/objcopy.exp: Run new tests. * testsuite/binutils-all/remove-relocs-01.d: New file. * testsuite/binutils-all/remove-relocs-01.s: New file. * testsuite/binutils-all/remove-relocs-02.d: New file. * testsuite/binutils-all/remove-relocs-03.d: New file. * testsuite/binutils-all/remove-relocs-04.d: New file. * testsuite/binutils-all/remove-relocs-05.d: New file. * testsuite/binutils-all/remove-relocs-06.d: New file.
2015-08-22 03:08:26 +08:00
run_dump_test "keep-section-1"
run_dump_test "keep-section-2"
objcopy/strip: Add option --remove-relocations=SECTIONPATTERN The objcopy and strip tools make use of the bfd library to manipulate the state of the input file (to produce an output file). Within the input file (for ELF at least), relocations are held within a section, and so, if the user wanted to remove the relocations, but keep the section to which the relocations would have been applied, it is tempting to think that specifying the name of a relocation section to objcopy's --remove-section option might do what you want, for example: objcopy --remove-section=.rela.text input.elf output.elf However, this does not work. The reason is that when the input file is loaded, relocations are not managed as sections, but are, instead, loaded as data associated with the section to which the relocations would be applied. In our example above the relocations in '.rela.text' are held as data on the section '.text' once 'input.elf' is loaded. One task that objcopy and strip do is copy the relocations from the input file to the output file if the section is also being copied from the input file to the output file. This commit adds a new command line option for objcopy and strip, --remove-relocations, which can be used to remove the relocations, while keeping the section that the relocations would have been applied to, for example: objcopy --remove-relocations=.text input.elf output.elf in this case the section '.text' will appear in both 'input.elf' and 'output.elf', but any relocations in 'input.elf' that apply to '.text' will not be present in 'output.elf'. I have also added a special case to the handling of --remove-section that spots if a user tries to remove a relocation section (currently this is done by spotting the '.rela.' or '.rel.' prefix) and forwards the request to --remove-relocations. As with --remove-section and --only-section the --remove-relocations option supports the '!' prefix on the section-patterns it takes to allow for sections to be specifically not matched. There are tests for all the new functionality. binutils/ChangeLog: * doc/binutils.texi (objcopy): Document 'remove-relocations'. (strip): Likewise. * objcopy.c (SECTION_CONTEXT_REMOVE_RELOCS): Define. (enum command_line_switch): Add 'OPTION_REMOVE_RELOCS'. (struct option strip_options): Add 'remove-relocations'. (struct option copy_options): Likewise. (copy_usage): Likewise. (strip_usage): Likewise. (handle_remove_relocations_option): New function. (discard_relocations): New function. (handle_remove_section_option): New function. (copy_relocations_in_section): Use discard_relocations. (strip_main): Use handle_remove_section_option for 'remove-section', and handle 'remove-relocations' option. (copy_main): Likewise. * testsuite/binutils-all/objcopy.exp: Run new tests. * testsuite/binutils-all/remove-relocs-01.d: New file. * testsuite/binutils-all/remove-relocs-01.s: New file. * testsuite/binutils-all/remove-relocs-02.d: New file. * testsuite/binutils-all/remove-relocs-03.d: New file. * testsuite/binutils-all/remove-relocs-04.d: New file. * testsuite/binutils-all/remove-relocs-05.d: New file. * testsuite/binutils-all/remove-relocs-06.d: New file.
2015-08-22 03:08:26 +08:00
# Test the remove relocation functionality
set test_list [lsort [glob -nocomplain $srcdir/$subdir/remove-relocs-*.d]]
foreach t $test_list {
# We need to strip the ".d", but can leave the dirname.
verbose [file rootname $t]
run_dump_test [file rootname $t]
}
}
run_dump_test "localize-hidden-2"
# Test objcopying an object file without global symbol
proc objcopy_test_without_global_symbol { } {
global OBJCOPY
global OBJCOPYFLAGS
global OBJDUMP
global OBJDUMPFLAGS
global srcdir
global subdir
set test "strip without global symbol "
if { [target_compile $srcdir/$subdir/pr19547.c tmpdir/pr19547.o object debug] != "" } {
untested $test
return
}
if [is_remote host] {
set objfile [remote_download host tmpdir/pr19547.o]
} else {
set objfile tmpdir/pr19547.o
}
set exec_output [binutils_run $OBJCOPY "$OBJCOPYFLAGS --strip-unneeded $objfile"]
2018-08-23 21:12:37 +08:00
set exec_output [prune_warnings $exec_output]
if ![string equal "" $exec_output] {
fail $test
return
}
set exec_output [binutils_run $OBJDUMP "$OBJDUMPFLAGS -t $objfile"]
2018-08-23 21:12:37 +08:00
set exec_output [prune_warnings $exec_output]
if {![regexp "no symbols" $exec_output]} {
fail $test
return
}
pass $test
}
# The AArch64 and ARM targets preserve mapping symbols
# in object files, so they will fail this test.
setup_xfail aarch64*-*-* arm*-*-*
objcopy_test_without_global_symbol
2018-09-10 10:27:08 +08:00
# objcopy remove relocation from executable test
proc objcopy_remove_relocations_from_executable { } {
global OBJCOPY
global srcdir
global subdir
global READELF
set test "remove-section relocation sections"
if { [target_compile $srcdir/$subdir/testprog.c tmpdir/pr23611 executable debug] != "" } {
untested $test
return
}
if [is_remote host] {
set objfile [remote_download host tmpdir/pr23611]
} else {
set objfile tmpdir/pr23611
}
set out tmpdir/pr23611.out
set exec_output1 [binutils_run $OBJCOPY "-R .rela.plt -R .rela.dyn -R .rel.plt -R .rel.dyn $objfile $out"]
set exec_output1 [prune_warnings $exec_output1]
if ![string equal "" $exec_output1] {
fail $test
return
}
2018-09-10 10:27:08 +08:00
set exec_output2 [binutils_run $READELF "-S $out"]
if { [string match "*.rel.plt*" $exec_output2] || [string match "*.rela.plt*" $exec_output2] || [string match "*.rel.dyn*" $exec_output2] || [string match "*.rela.dyn*" $exec_output2] } {
fail $test
return
}
pass $test
}
if [is_elf_format] {
objcopy_remove_relocations_from_executable
}
run_dump_test "pr23633"
run_dump_test "set-section-alignment"
setup_xfail "hppa*-*-*"
setup_xfail "sh-*-coff*"
setup_xfail "spu-*-*"
clear_xfail "hppa*64*-*-hpux*" "hppa*-*-linux*" "hppa*-*-lites*"
clear_xfail "hppa*-*-*n*bsd*" "hppa*-*-rtems*" "hppa*-*-*elf*"
if { [istarget pdp11-*-*] } {
set src "pr25662-pdp11.s"
} else {
set src "pr25662.s"
}
set ldflags "-T$srcdir/$subdir/pr25662.ld"
if { [istarget *-*-cygwin] || [istarget *-*-mingw*] } {
append ldflags " --disable-reloc-section"
}
#xcoff doesn't support arbitrary sections
if { ![is_xcoff_format] } {
objcopy_test "pr25662" $src executable "" $ldflags
}