1# Copyright (C) 2012-2016 Free Software Foundation, Inc. 2 3# This program is free software; you can redistribute it and/or modify 4# it under the terms of the GNU General Public License as published by 5# the Free Software Foundation; either version 3 of the License, or 6# (at your option) any later version. 7# 8# This program is distributed in the hope that it will be useful, 9# but WITHOUT ANY WARRANTY; without even the implied warranty of 10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11# GNU General Public License for more details. 12# 13# You should have received a copy of the GNU General Public License 14# along with this program; if not, write to the Free Software 15# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. 16 17# Relocation test. 18# This test is special because it exercises the linker's 19 20proc ld_test { objects ldflags dest test } { 21 set ld_output [target_link $objects $dest $ldflags] 22 if [string match "" $ld_output] then { pass $test } else { fail $test } 23} 24 25 26proc objdump_test { exec flags dest test } { 27 set objcopy [find_binutils_prog objdump] 28 verbose -log "$objcopy $flags $exec > $dest" 29 catch "exec $objcopy $flags $exec > $dest" objdump_output 30 if [string match "" $objdump_output] then { pass $test } else { fail $test } 31} 32 33proc regexp_test { file1 file2 test } { 34 if [regexp_diff $file1 $file2] then { fail $test } else { pass $test } 35} 36 37 38global srcdir subdir 39if [istarget mt-*] { 40 gas_test "relocs1.s" {-o relocs1.o} {} {assembling relocs1} 41 42 # gas_test "relocs2.s" {-o relocs2.o} {} {assembling relocs2} 43 # ld_test {relocs1.o relocs2.o} {} {relocs.x} {linking relocs.x} 44 # objdump_test {relocs.x} {-ds} {relocs.dump} {disassembling relocs.x} 45 # regexp_test {relocs.dump} "$srcdir/$subdir/relocs.d" {matching disassembly} 46 47 gas_test "relocs2.s" {-o relocs2.o} {} {assembling relocs2} 48 ld_test {relocs1.o relocs2.o} {} {relocs.x} {linking relocs.x} 49 objdump_test {relocs.x} {-ds} {relocs.dump} {disassembling relocs.x} 50 regexp_test {relocs.dump} "$srcdir/$subdir/relocs.d" {matching disassembly} 51} 52