From: nobody <> Date: Mon, 7 Feb 2011 00:04:10 +0000 (+0000) Subject: This commit was manufactured by cvs2svn to create branch 'binutils- X-Git-Tag: binutils-2_21_1~213 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7ce626f5b02056daa03603424d935592289b318f;p=thirdparty%2Fbinutils-gdb.git This commit was manufactured by cvs2svn to create branch 'binutils- 2_21-branch'. Cherrypick from master 2011-02-07 00:04:09 UTC Alan Modra ' PR gas/3041': binutils/testsuite/lib/binutils-common.exp gas/testsuite/gas/elf/section9.d gas/testsuite/gas/elf/section9.s gas/testsuite/gas/m68k/p3041pcrel.d gas/testsuite/gas/m68k/p3041pcrel.s ld/testsuite/ld-elfvers/vers.h ld/testsuite/ld-ifunc/ifunc-12-i386.d ld/testsuite/ld-ifunc/ifunc-12-i386.s ld/testsuite/ld-ifunc/ifunc-12-x86-64.d ld/testsuite/ld-ifunc/ifunc-12-x86-64.s ld/testsuite/ld-ifunc/ifunc-13-i386.d ld/testsuite/ld-ifunc/ifunc-13-x86-64.d ld/testsuite/ld-ifunc/ifunc-13a-i386.s ld/testsuite/ld-ifunc/ifunc-13a-x86-64.s ld/testsuite/ld-ifunc/ifunc-13b-i386.s ld/testsuite/ld-ifunc/ifunc-13b-x86-64.s --- diff --git a/binutils/testsuite/lib/binutils-common.exp b/binutils/testsuite/lib/binutils-common.exp new file mode 100644 index 00000000000..8e2c36f504a --- /dev/null +++ b/binutils/testsuite/lib/binutils-common.exp @@ -0,0 +1,314 @@ +# Copyright 1993, 1994, 1995, 1996, 1997, 2000, 2001, 2003, 2004, 2006, 2007, +# 2009, 2010 Free Software Foundation, Inc. +# +# This file is part of the GNU Binutils. +# +# This file 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. + +# True if the object format is known to be ELF. +# +proc is_elf_format {} { + if { ![istarget *-*-sysv4*] + && ![istarget *-*-unixware*] + && ![istarget *-*-elf*] + && ![istarget *-*-eabi*] + && ![istarget *-*-rtems*] + && ![istarget hppa*64*-*-hpux*] + && ![istarget ia64-*-hpux*] + && ![istarget *-*-linux*] + && ![istarget *-*-gnu*] + && ![istarget frv-*-uclinux*] + && ![istarget bfin-*-uclinux] + && ![istarget sh*-*-uclinux*] + && ![istarget *-*-irix5*] + && ![istarget *-*-irix6*] + && ![istarget *-*-netbsd*] + && ![istarget *-*-openbsd*] + && ![istarget *-*-solaris2*] } { + return 0 + } + + if { [istarget *-*-linux*aout*] + || [istarget *-*-linux*oldld*] + || [istarget h8500-*-rtems*] + || [istarget i960-*-rtems*] + || [istarget *-*-rtemscoff*] } { + return 0 + } + + if { ![istarget *-*-netbsdelf*] + && ([istarget *-*-netbsd*aout*] + || [istarget *-*-netbsdpe*] + || [istarget arm*-*-netbsd*] + || [istarget sparc-*-netbsd*] + || [istarget i*86-*-netbsd*] + || [istarget m68*-*-netbsd*] + || [istarget vax-*-netbsd*] + || [istarget ns32k-*-netbsd*]) } { + return 0 + } + + if { [istarget arm-*-openbsd*] + || [istarget i386-*-openbsd\[0-2\].*] + || [istarget i386-*-openbsd3.\[0-2\]] + || [istarget m68*-*-openbsd*] + || [istarget ns32k-*-openbsd*] + || [istarget sparc-*-openbsd\[0-2\].*] + || [istarget sparc-*-openbsd3.\[0-1\]] + || [istarget vax-*-openbsd*] } { + return 0 + } + + return 1 +} + +# True if the object format is known to be a.out. +# +proc is_aout_format {} { + if { [istarget *-*-netbsdelf] + || [istarget sparc64-*-netbsd*] + || [istarget sparc64-*-openbsd*] } { + return 0 + } + if { [istarget *-*-*\[ab\]out*] + || [istarget *-*-linux*oldld*] + || [istarget *-*-bsd*] + || [istarget *-*-msdos*] + || [istarget arm-*-netbsd*] + || [istarget arm-*-openbsd*] + || [istarget arm-*-riscix*] + || [istarget i?86-*-freebsd\[12\]*] + || [istarget i?86-*-netbsd*] + || [istarget i?86-*-openbsd\[0-2\]*] + || [istarget i?86-*-openbsd3.\[0-2\]*] + || [istarget i?86-*-vsta] + || [istarget i?86-*-mach*] + || [istarget m68*-*-netbsd*] + || [istarget m68*-*-openbsd*] + || [istarget ns32k-*-*] + || [istarget pdp11-*-*] + || [istarget sparc*-*-sunos4*] + || [istarget sparc*-*-netbsd*] + || [istarget sparc*-*-openbsd\[0-2\]*] + || [istarget sparc*-*-openbsd3.\[0-1\]*] + || [istarget sparc*-fujitsu-none] + || [istarget vax-dec-ultrix*] + || [istarget vax-*-netbsd] } { + return 1 + } + return 0 +} + +# True if the object format is known to be PE COFF. +# +proc is_pecoff_format {} { + if { ![istarget *-*-mingw*] + && ![istarget *-*-cygwin*] + && ![istarget *-*-cegcc*] + && ![istarget *-*-pe*] } { + return 0 + } + + return 1 +} + +# True if the object format is known to be 64-bit ELF. +# +proc is_elf64 { binary_file } { + global READELF + global READELFFLAGS + + set readelf_size "" + catch "exec $READELF $READELFFLAGS -h $binary_file > readelf.out" got + + if ![string match "" $got] then { + return 0 + } + + if { ![regexp "\n\[ \]*Class:\[ \]*ELF(\[0-9\]+)\n" \ + [file_contents readelf.out] nil readelf_size] } { + return 0 + } + + if { $readelf_size == "64" } { + return 1 + } + + return 0 +} + +# Compare two files line-by-line. FILE_1 is the actual output and FILE_2 +# is the expected output. Ignore blank lines in either file. +# +# FILE_2 is a series of regexps, comments and # directives. The directives +# are: +# +# #pass +# Treat the test as a PASS if everything up till this point has +# matched. Ignore any remaining lines in either FILE_1 or FILE_2. +# +# #failif +# Reverse the sense of the test: expect differences to exist. +# +# #... +# REGEXP +# Skip all lines in FILE_1 until the first that matches REGEXP. +# +# Other # lines are comments. Regexp lines starting with the `!' character +# specify inverse matching (use `\!' for literal matching against a leading +# `!'). Skip empty lines in both files. +# +# The first optional argument is a list of regexp substitutions of the form: +# +# EXP1 SUBSPEC1 EXP2 SUBSPEC2 ... +# +# This tells the function to apply each regexp substitution EXPi->SUBSPECi +# in order to every line of FILE_2. +# +# Return nonzero if differences exist. +proc regexp_diff { file_1 file_2 args } { + set eof -1 + set end_1 0 + set end_2 0 + set differences 0 + set diff_pass 0 + set fail_if_match 0 + set ref_subst "" + if { [llength $args] > 0 } { + set ref_subst [lindex $args 0] + } + if { [llength $args] > 1 } { + perror "Too many arguments to regexp_diff" + return 1 + } + + if [file exists $file_1] then { + set file_a [open $file_1 r] + } else { + perror "$file_1 doesn't exist" + return 1 + } + + if [file exists $file_2] then { + set file_b [open $file_2 r] + } else { + perror "$file_2 doesn't exist" + close $file_a + return 1 + } + + verbose " Regexp-diff'ing: $file_1 $file_2" 2 + + while { 1 } { + set line_a "" + set line_b "" + while { [string length $line_a] == 0 } { + # Ignore blank line in FILE_1. + if { [gets $file_a line_a] == $eof } { + set end_1 1 + break + } + } + while { [string length $line_b] == 0 || [string match "#*" $line_b] } { + if { [string match "#pass" $line_b] } { + set end_2 1 + set diff_pass 1 + break + } elseif { [string match "#failif" $line_b] } { + send_log "fail if no difference\n" + verbose "fail if no difference" 3 + set fail_if_match 1 + } elseif { [string match "#..." $line_b] } { + if { [gets $file_b line_b] == $eof } { + set end_2 1 + set diff_pass 1 + break + } + set negated [expr { [string index $line_b 0] == "!" }] + set line_bx [string range $line_b $negated end] + set n [expr { $negated ? "! " : "" }] + # Substitute on the reference. + foreach {name value} $ref_subst { + regsub -- $name $line_bx $value line_bx + } + verbose "looking for $n\"^$line_bx$\"" 3 + while { [expr [regexp "^$line_bx$" "$line_a"] == $negated] } { + verbose "skipping \"$line_a\"" 3 + if { [gets $file_a line_a] == $eof } { + set end_1 1 + break + } + } + break + } + if { [gets $file_b line_b] == $eof } { + set end_2 1 + break + } + } + + if { $diff_pass } { + break + } elseif { $end_1 && $end_2 } { + break + } elseif { $end_1 } { + send_log "extra regexps in $file_2 starting with \"^$line_b$\"\nEOF from $file_1\n" + verbose "extra regexps in $file_2 starting with \"^$line_b$\"\nEOF from $file_1" 3 + set differences 1 + break + } elseif { $end_2 } { + send_log "extra lines in $file_1 starting with \"^$line_a$\"\nEOF from $file_2\n" + verbose "extra lines in $file_1 starting with \"^$line_a$\"\nEOF from $file_2\n" 3 + set differences 1 + break + } else { + set negated [expr { [string index $line_b 0] == "!" }] + set line_bx [string range $line_b $negated end] + set n [expr { $negated ? "! " : "" }] + set s [expr { $negated ? " " : "" }] + # Substitute on the reference. + foreach {name value} $ref_subst { + regsub -- $name $line_bx $value line_bx + } + verbose "regexp $n\"^$line_bx$\"\nline \"$line_a\"" 3 + if { [expr [regexp "^$line_bx$" "$line_a"] == $negated] } { + send_log "regexp_diff match failure\n" + send_log "regexp $n\"^$line_bx$\"\nline $s\"$line_a\"\n" + verbose "regexp_diff match failure\n" 3 + set differences 1 + } + } + } + + if { $differences == 0 && !$diff_pass && [eof $file_a] != [eof $file_b] } { + send_log "$file_1 and $file_2 are different lengths\n" + verbose "$file_1 and $file_2 are different lengths" 3 + set differences 1 + } + + if { $fail_if_match } { + if { $differences == 0 } { + set differences 1 + } else { + set differences 0 + } + } + + close $file_a + close $file_b + + return $differences +} diff --git a/gas/testsuite/gas/elf/section9.d b/gas/testsuite/gas/elf/section9.d new file mode 100644 index 00000000000..1acf63e8193 --- /dev/null +++ b/gas/testsuite/gas/elf/section9.d @@ -0,0 +1,7 @@ +#readelf: -S --wide +#name: section flags + +#... +[ ]*\[.*\][ ]+\.gnu\.lto_main[ ]+PROGBITS.*[ ]+E[ ]+.* +[ ]*\[.*\][ ]+\.gnu\.lto_\.pureconst[ ]+PROGBITS.*[ ]+E[ ]+.* +#pass diff --git a/gas/testsuite/gas/elf/section9.s b/gas/testsuite/gas/elf/section9.s new file mode 100644 index 00000000000..6b8b1074ca3 --- /dev/null +++ b/gas/testsuite/gas/elf/section9.s @@ -0,0 +1,4 @@ + .section .gnu.lto_main,"",%progbits + .byte 0,0,0,0 + .section .gnu.lto_.pureconst,"",%progbits + .byte 0,0,0,0 diff --git a/gas/testsuite/gas/m68k/p3041pcrel.d b/gas/testsuite/gas/m68k/p3041pcrel.d new file mode 100644 index 00000000000..91168cc9cd7 --- /dev/null +++ b/gas/testsuite/gas/m68k/p3041pcrel.d @@ -0,0 +1,38 @@ +#name: PR 3041 pcrel +#as: -m68000 +#objdump: -tdr + +.*: file format .* + +SYMBOL TABLE: +00000024 w \.text 0000 00 0f mytext +0000002e w \.data 0000 00 10 mydata +0000003a w \.bss 0000 00 11 mybss + +Disassembly of section \.text: + +00000000 <.*>: + 0: 41fa fffe lea %pc@\(0 <.*>\),%a0 + 2: DISP16 mytext + 4: 41fa fffc lea %pc@\(2 <.*>\),%a0 + 6: DISP16 mytext + 8: 41fa fff2 lea %pc@\(fffffffc <.*>\),%a0 + a: DISP16 mytext + c: 41fa fff2 lea %pc@\(0 <.*>\),%a0 + e: DISP16 mydata + 10: 41fa fff1 lea %pc@\(3 <.*>\),%a0 + 12: DISP16 mydata + 14: 41fa ffe9 lea %pc@\(ffffffff <.*>\),%a0 + 16: DISP16 mydata + 18: 41fa ffe6 lea %pc@\(0 <.*>\),%a0 + 1a: DISP16 mybss + 1c: 41fa ffe3 lea %pc@\(1 <.*>\),%a0 + 1e: DISP16 mybss + 20: 41fa ffdc lea %pc@\(fffffffe <.*>\),%a0 + 22: DISP16 mybss + +00000024 : + 24: 4e71 nop + 26: 4e71 nop + 28: 4e71 nop + 2a: 4e71 nop diff --git a/gas/testsuite/gas/m68k/p3041pcrel.s b/gas/testsuite/gas/m68k/p3041pcrel.s new file mode 100644 index 00000000000..59d61ead42c --- /dev/null +++ b/gas/testsuite/gas/m68k/p3041pcrel.s @@ -0,0 +1,28 @@ + lea mytext(%pc),%a0 + lea mytext+2(%pc),%a0 + lea mytext-4(%pc),%a0 + lea mydata(%pc),%a0 + lea mydata+3(%pc),%a0 + lea mydata-1(%pc),%a0 + lea mybss(%pc),%a0 + lea mybss+1(%pc),%a0 + lea mybss-2(%pc),%a0 + .weak mytext +mytext: + nop + nop + nop + nop + + .data + .word 0x8081 + .weak mydata +mydata: + .word 0x8283 + .word 0x8485 + + .bss + .skip 6 + .weak mybss +mybss: + .skip 2 diff --git a/ld/testsuite/ld-elfvers/vers.h b/ld/testsuite/ld-elfvers/vers.h new file mode 100644 index 00000000000..4455527457c --- /dev/null +++ b/ld/testsuite/ld-elfvers/vers.h @@ -0,0 +1,9 @@ +/* Add the symbol prefix to the symbol as needed. + Usage: SYMPFX(foo); */ +#define __SYMPFX(pfx, sym) #pfx sym +#define _SYMPFX(pfx, sym) __SYMPFX(pfx, sym) +#define SYMPFX(sym) _SYMPFX(__USER_LABEL_PREFIX__, #sym) + +/* Generate a .symver reference with symbol prefixes. + Usage: SYMVER(foo, foobar@ver); */ +#define SYMVER(name, name2) __asm__(".symver " SYMPFX(name) "," SYMPFX(name2)) diff --git a/ld/testsuite/ld-ifunc/ifunc-12-i386.d b/ld/testsuite/ld-ifunc/ifunc-12-i386.d new file mode 100644 index 00000000000..de1418154e6 --- /dev/null +++ b/ld/testsuite/ld-ifunc/ifunc-12-i386.d @@ -0,0 +1,6 @@ +#ld: -shared -m elf_i386 -e bar --gc-sections +#as: --32 +#readelf: -r --wide +#target: x86_64-*-* i?86-*-* + +There are no relocations in this file. diff --git a/ld/testsuite/ld-ifunc/ifunc-12-i386.s b/ld/testsuite/ld-ifunc/ifunc-12-i386.s new file mode 100644 index 00000000000..840302f3ef7 --- /dev/null +++ b/ld/testsuite/ld-ifunc/ifunc-12-i386.s @@ -0,0 +1,25 @@ + .section .text.foo,"ax",@progbits + .type foo, @function +foo: + movl ifunc@GOT(%ecx), %eax + movl ifunc@GOTOFF(%ecx), %eax + call ifunc@PLT + call ifunc + movl xxx@GOT(%ecx), %eax + movl xxx, %eax + ret + + .section .text.bar,"ax",@progbits + .type bar, @function +bar: + .global bar + ret + + .section .text.ifunc,"ax",@progbits + .type ifunc, @gnu_indirect_function +ifunc: + ret + + .section .data.foo,"aw",@progbits +xxx: + .long ifunc diff --git a/ld/testsuite/ld-ifunc/ifunc-12-x86-64.d b/ld/testsuite/ld-ifunc/ifunc-12-x86-64.d new file mode 100644 index 00000000000..40f07c38bb7 --- /dev/null +++ b/ld/testsuite/ld-ifunc/ifunc-12-x86-64.d @@ -0,0 +1,6 @@ +#ld: -shared -m elf_x86_64 -e bar --gc-sections +#as: --64 +#readelf: -r --wide +#target: x86_64-*-* + +There are no relocations in this file. diff --git a/ld/testsuite/ld-ifunc/ifunc-12-x86-64.s b/ld/testsuite/ld-ifunc/ifunc-12-x86-64.s new file mode 100644 index 00000000000..491684bdc23 --- /dev/null +++ b/ld/testsuite/ld-ifunc/ifunc-12-x86-64.s @@ -0,0 +1,24 @@ + .section .text.foo,"ax",@progbits + .type foo, @function +foo: + movl ifunc@GOTPCREL(%rip), %eax + movl ifunc(%rip), %eax + call ifunc@PLT + call ifunc + movl xxx(%rip), %eax + ret + + .section .text.bar,"ax",@progbits + .type bar, @function +bar: + .global bar + ret + + .section .text.ifunc,"ax",@progbits + .type ifunc, @gnu_indirect_function +ifunc: + ret + + .section .data.foo,"aw",@progbits +xxx: + .quad ifunc diff --git a/ld/testsuite/ld-ifunc/ifunc-13-i386.d b/ld/testsuite/ld-ifunc/ifunc-13-i386.d new file mode 100644 index 00000000000..162c3e40f97 --- /dev/null +++ b/ld/testsuite/ld-ifunc/ifunc-13-i386.d @@ -0,0 +1,19 @@ +#source: ifunc-13a-i386.s +#source: ifunc-13b-i386.s +#ld: -shared -m elf_i386 -z nocombreloc +#as: --32 +#readelf: -r --wide +#target: x86_64-*-* i?86-*-* + +Relocation section '.rel.got' at .* +[ ]+Offset[ ]+Info[ ]+Type[ ]+.* +#... +[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_386_GLOB_DAT[ ]+ifunc\(\)[ ]+ifunc +#... +Relocation section '.rel.ifunc' at .* +[ ]+Offset[ ]+Info[ ]+Type[ ]+.* +[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_386_32[ ]+ifunc\(\)[ ]+ifunc +#... +Relocation section '.rel.plt' at .* +[ ]+Offset[ ]+Info[ ]+Type[ ]+.* +[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_386_JUMP_SLOT[ ]+ifunc\(\)[ ]+ifunc diff --git a/ld/testsuite/ld-ifunc/ifunc-13-x86-64.d b/ld/testsuite/ld-ifunc/ifunc-13-x86-64.d new file mode 100644 index 00000000000..d0c064773a4 --- /dev/null +++ b/ld/testsuite/ld-ifunc/ifunc-13-x86-64.d @@ -0,0 +1,18 @@ +#source: ifunc-13a-x86-64.s +#source: ifunc-13b-x86-64.s +#ld: -shared -m elf_x86_64 -z nocombreloc +#as: --64 +#readelf: -r --wide +#target: x86_64-*-* + +Relocation section '.rela.got' at .* +[ ]+Offset[ ]+Info[ ]+Type[ ]+.* +[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_X86_64_GLOB_DAT[ ]+ifunc\(\)[ ]+ifunc \+ 0 +#... +Relocation section '.rela.ifunc' at .* +[ ]+Offset[ ]+Info[ ]+Type[ ]+.* +[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_X86_64_64[ ]+ifunc\(\)[ ]+ifunc \+ 0 +#... +Relocation section '.rela.plt' at .* +[ ]+Offset[ ]+Info[ ]+Type[ ]+.* +[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_X86_64_JUMP_SLOT[ ]+ifunc\(\)[ ]+ifunc \+ 0 diff --git a/ld/testsuite/ld-ifunc/ifunc-13a-i386.s b/ld/testsuite/ld-ifunc/ifunc-13a-i386.s new file mode 100644 index 00000000000..eb893af3d30 --- /dev/null +++ b/ld/testsuite/ld-ifunc/ifunc-13a-i386.s @@ -0,0 +1,10 @@ + .text + .type foo, @function + .global +foo: + movl xxx@GOT(%ebx), %eax + ret + + .data +xxx: + .long ifunc diff --git a/ld/testsuite/ld-ifunc/ifunc-13a-x86-64.s b/ld/testsuite/ld-ifunc/ifunc-13a-x86-64.s new file mode 100644 index 00000000000..5bfc9e03b04 --- /dev/null +++ b/ld/testsuite/ld-ifunc/ifunc-13a-x86-64.s @@ -0,0 +1,10 @@ + .text + .type foo, @function + .global +foo: + movl xxx(%rip), %eax + ret + + .data +xxx: + .quad ifunc diff --git a/ld/testsuite/ld-ifunc/ifunc-13b-i386.s b/ld/testsuite/ld-ifunc/ifunc-13b-i386.s new file mode 100644 index 00000000000..3560394298f --- /dev/null +++ b/ld/testsuite/ld-ifunc/ifunc-13b-i386.s @@ -0,0 +1,5 @@ + .text + .type ifunc, @gnu_indirect_function + .globl ifunc +ifunc: + ret diff --git a/ld/testsuite/ld-ifunc/ifunc-13b-x86-64.s b/ld/testsuite/ld-ifunc/ifunc-13b-x86-64.s new file mode 100644 index 00000000000..3560394298f --- /dev/null +++ b/ld/testsuite/ld-ifunc/ifunc-13b-x86-64.s @@ -0,0 +1,5 @@ + .text + .type ifunc, @gnu_indirect_function + .globl ifunc +ifunc: + ret