1# Expect script for frame section tests 2# Copyright (C) 2004-2020 Free Software Foundation, Inc. 3# 4# This file is part of the GNU Binutils. 5# 6# This program is free software; you can redistribute it and/or modify 7# it under the terms of the GNU General Public License as published by 8# the Free Software Foundation; either version 3 of the License, or 9# (at your option) any later version. 10# 11# This program is distributed in the hope that it will be useful, 12# but WITHOUT ANY WARRANTY; without even the implied warranty of 13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14# GNU General Public License for more details. 15# 16# You should have received a copy of the GNU General Public License 17# along with this program; if not, write to the Free Software 18# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, 19# MA 02110-1301, USA. 20# 21# Written by H.J. Lu (hongjiu.lu@intel.com) 22# 23 24# Make sure that ld correctly handles frame sections in ELF. 25 26# This test can only be run on ELF platforms. 27if ![is_elf_format] { 28 return 29} 30 31# No shared lib support on this target. 32if ![check_shared_lib_support] { 33 return 34} 35 36# Too small MAXPAGESIZE on this target. 37if { [istarget "sh*-*-elf*"] } { 38 return 39} 40 41# ??? These targets have their own .tbss section, with different meaning 42# to the usual ELF .tbss. 43if { [istarget "hppa64-*-*"] || [istarget "v850*-*-*"] } { 44 return 45} 46 47set as_opt "" 48 49# This target requires extra as options when building code for shared 50# libraries. 51if { [istarget "tic6x-*-*"] } { 52 set as_opt "-mpic -mpid=near" 53} 54 55set test1 "read-only .eh_frame section" 56set test2 "read-only .gcc_except_table section" 57 58if { ![ld_assemble_flags $as $as_opt $srcdir/$subdir/tbss.s tmpdir/tbss.o ] 59 || ![ld_assemble_flags $as $as_opt $srcdir/$subdir/frame.s tmpdir/frame.o] } { 60 unresolved "$test1" 61 return 62} 63 64if { [ld_link $ld tmpdir/frame.so "-z noseparate-code --shared tmpdir/frame.o tmpdir/tbss.o"] } { 65 pass "$test1 -z noseparate-code" 66} else { 67 fail "$test1 -z noseparate-code" 68} 69 70if { [ld_link $ld tmpdir/frame.so "-z separate-code --shared tmpdir/frame.o tmpdir/tbss.o"] } { 71 pass "$test1 -z separate-code" 72} else { 73 fail "$test1 -z separate-code" 74} 75 76if ![ld_assemble_flags $as $as_opt $srcdir/$subdir/table.s tmpdir/table.o ] { 77 unresolved "$test2" 78 return 79} 80 81if { [ld_link $ld tmpdir/table.so "-z noseparate-code --shared tmpdir/table.o tmpdir/tbss.o"] } { 82 pass "$test2 -z noseparate-code" 83} else { 84 fail "$test2 -z noseparate-code" 85} 86 87if { [ld_link $ld tmpdir/table.so "-z separate-code --shared tmpdir/table.o tmpdir/tbss.o"] } { 88 pass "$test2 -z separate-code" 89} else { 90 fail "$test2 -z separate-code" 91} 92