old-cross-binutils/ld/testsuite/ld-elf/binutils.exp
Nathan Sidwell 04c3a75556 bfd/
* bfd-in.h (bfd_elf_stack_segment_size): Declare.
	* bfd-in2.h: Rebuilt.
	* elfxx-target.h (elf_backend_stack_align): New.
	(elfNN_bed): Add it.
	* elf-bfd.h (struct elf_backend_data): Add stack_align field.
	* elf.c (bfd_elf_map_sections_to_segments): Pay attention to
	stack_align and stacksize for PT_GNU_STACK segment.
	(assign_file_positions_for_non_load_sections): Set p_memsz for
	PT_GNU_STACK segment.
	(copy_elf_program_header): Copy PT_GNU_STACK size.
	* elflink.c (bfd_elf_stack_segment_size): New function, taken from
	uclinux backends.
	(bfd_elf_size_dynamic_sections): Determine
	PT_GNU_STACK requirements after calling backend.  Pay attention to
	stacksize.
	* elf32-bfin.c (elf32_bfinfdpic_always_size_sections): Call
	bfd_elf_stack_segment_size.
	(elf32_bfinfdpic_modify_program_headers): Delete.
	(elf32_bfingfdpic_copy_private_bfd_data): Don't copy PT_GNU_STACK
	here.
	(elf_backend_stack_align): Override.
	(elf_backend_modify_program_headers): Don't override.
	* elf32-frv.c (frvfdpic_always_size_sections): Call
	bfd_elf_stack_segment_size.
	(elf32_frvfdpic_modify_program_headers): Delete.
	(elf32_frvfdpic_copy_private_bfd_data): Don't copy PT_GNU_STACK
	here.
	(elf_backend_stack_align): Override.
	(elf_backend_modify_program_headers): Don't override.
	* elf32-lm32.c (lm32_elf_always_size_sections): Leave
	PT_GNU_STACK creation to underlying elf support.  Check
	__stacksize here for backwards compatibility, and set it if
	needed.
	(lm32_elf_modify_segment_map): Delete.
	(lm32_elf_modify_program_headers): Delete.
	(elf_backend_stack_align): Override.
	(elf_backend_modify_segment_map): Don't override.
	(elf_backend_modify_program_headers): Don't override.
	* elf32-sh.c (sh_elf_always_size_sections): Call
	bfd_elf_stack_segment_size.
	(sh_elf_modify_program_headers): Delete.
	(sh_elf_copy_private_data): Don't copy PT_GNU_STACK
	here.
	(elf_backend_stack_align): Override.
	(elf_backend_modify_program_headers): Don't override.
	* elf32-tic6x.c (elf32_tic6x_always_size_sections): Call
	bfd_elf_stack_segment_size.
	(elf32_tic6x_modify_program_headers): Delete.
	(elf32_tic6x_copy_private_data): Delete.
	(elf_backend_stack_align): Override.
	(bfd_elf32_bfd_copy_private_bfd_data): Don't override.
	(elf_backend_modify_program_headers): Don't override.

	include/
	* bfdlink.h (struct bfd_link_info): Add stacksize option.

	ld/
	* ld.texinfo (stack-size): New option.
	* emultempl/elf32.em: Add stack-size option.

	ld/testsuite/
	* ld-elf/binutils.exp: Add -z stack-size=0.
	* ld-elf/elf.exp: Add stack-exec and stack-size tests.
	* ld-elf/orphan-region.d: Add stack-size option. Remove xfail.
	* ld-elf/stack-exec.rd: New.
	* ld-elf/stack-size.rd: New.
	* ld-elf/stack.s: New.
	* ld-scripts/empty-aligned.d: Add stack-size option.
	* ld-sh/fdpic-stack-set.d: New.
	* ld-tic6x/shlib-1.rd: Remove __stacksize symbol.
	* ld-tic6x/shlib-1b.rd: Likewise.
	* ld-tic6x/shlib-1r.rd: Likewise.
	* ld-tic6x/shlib-1rb.rd: Likewise.
	* ld-tic6x/shlib-app-1.rd: Likewise.
	* ld-tic6x/shlib-app-1b.rd: Likewise.
	* ld-tic6x/shlib-app-1r.rd: Likewise.
	* ld-tic6x/shlib-app-1rb.rd: Likewise.
	* ld-tic6x/shlib-noindex.rd: Likewise.
	* ld-tic6x/static-app-1.rd: Likewise.
	* ld-tic6x/static-app-1b.rd: Likewise.
	* ld-tic6x/static-app-1r.rd: Likewise.
	* ld-tic6x/static-app-1rb.rd: Likewise.
2012-10-23 09:33:56 +00:00

154 lines
4.8 KiB
Text

# Expect script for binutils tests
# Copyright 2006, 2007, 2008, 2009, 2010, 2012 Free Software Foundation, Inc.
#
# This file is part of the GNU Binutils.
#
# 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
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# 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.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
# MA 02110-1301, USA.
#
# Written by H.J. Lu (hongjiu.lu@intel.com)
#
# Make sure that binutils can correctly handle ld output in ELF.
if { ![istarget *-*-linux*]
&& ![istarget *-*-nacl*]
&& ![istarget *-*-gnu*]} {
return
}
if { [istarget *-*-linux*aout*]
|| [istarget *-*-linux*oldld*] } {
return
}
# The optional test_name argument provides a mechanism for the caller
# to hardwire the test name. This is important if ld_options contains
# absolute path names because the default test name is constructed
# from the prog_name and ld_options and we do not want absolute paths
# to appear in the test_name.
proc binutils_test { prog_name ld_options test {test_name ""}} {
global as
global ld
global READELF
global objcopy
global strip
global srcdir
global subdir
global link_output
eval set prog \$$prog_name
if { "$test_name" == "" } {
set test_name "$prog_name $ld_options ($test)"
}
if { ![ld_assemble $as $srcdir/$subdir/$test.s tmpdir/$test.o ] } {
unresolved "$test_name"
return
}
if { ![ld_simple_link $ld tmpdir/$test "$ld_options -z stack-size=0 tmpdir/$test.o"] } {
if { [string match "*not supported*" $link_output]
|| [string match "*unrecognized option*" $link_output]
|| [string match "*-z relro ignored*" $link_output] } {
unsupported "$ld_options is not supported by this target"
} else {
unresolved "$test_name"
}
return
}
send_log "$READELF -l --wide tmpdir/$test > tmpdir/$test.exp\n"
set got [remote_exec host "$READELF -l --wide tmpdir/$test" "" "/dev/null" "tmpdir/$test.exp"]
if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
send_log "$got\n"
unresolved "$test_name"
return
}
send_log "$prog tmpdir/$test\n"
set got [remote_exec host "$prog tmpdir/$test"]
if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
send_log "$got\n"
fail "$test_name"
return
}
send_log "$READELF -l --wide tmpdir/$test > tmpdir/$test.out\n"
set got [remote_exec host "$READELF -l --wide tmpdir/$test" "" "/dev/null" "tmpdir/$test.out"]
if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
send_log "$got\n"
unresolved "$test_name"
return
}
if { [catch {exec cmp tmpdir/$test.exp tmpdir/$test.out}] } then {
send_log "tmpdir/$test.exp tmpdir/$test.out differ.\n"
fail "$test_name"
return
}
pass "$test_name"
}
binutils_test strip "-z max-page-size=0x200000" maxpage1
binutils_test strip "-z max-page-size=0x200000 -z common-page-size=0x100000" maxpage1
binutils_test strip "-z max-page-size=0x100000" maxpage1
binutils_test strip "-z max-page-size=0x100000 -z common-page-size=0x1000" maxpage1
binutils_test strip "" maxpage1
binutils_test strip "-shared" maxpage1
binutils_test objcopy "" maxpage1
binutils_test objcopy "-shared" maxpage1
binutils_test strip "-z relro" relro1
binutils_test strip "-z relro -shared" relro1
binutils_test objcopy "-z relro" relro1
binutils_test objcopy "-z relro -shared" relro1
if { ([istarget "i?86-*-elf*"]
|| (([istarget "i?86-*-linux*"]
|| [istarget "i?86-*-gnu*"])
&& ![istarget "*-*-*aout*"]
&& ![istarget "*-*-*oldld*"])
|| [istarget "x86_64-*-linux*"]
|| [istarget "amd64-*-linux*"]
|| [istarget "i?86-*nacl*"]
|| [istarget "x86_64-*nacl*"]) } {
binutils_test strip "-z relro -shared" relro2
binutils_test objcopy "-z relro -shared" relro2
}
binutils_test strip "-T ${srcdir}/${subdir}/lma.lnk" lma "strip -T lma.lnk"
set tls_tests { "tdata1" "tdata2" }
# hppa64 has its own .tbss section, with different flags.
if { ![istarget "hppa64-*-*"] } {
lappend tls_tests "tdata3" "tbss1" "tbss2" "tbss3"
}
set tls_opts {
""
"-z relro"
"-shared"
"-shared -z relro"
"-z max-page-size=0x100000"
"-z max-page-size=0x100000 -z common-page-size=0x1000"
}
foreach testitem $tls_tests {
foreach testopt $tls_opts {
binutils_test objcopy $testopt $testitem
}
}