diff options
author | Andrew Hsieh <andrewhsieh@google.com> | 2014-06-13 12:38:00 -0700 |
---|---|---|
committer | Andrew Hsieh <andrewhsieh@google.com> | 2014-06-13 12:38:00 -0700 |
commit | 54f1b3cf509cd889905287cb8ce6c5ae33911a21 (patch) | |
tree | e39b1a7fa04db86a8215b7f9d4656d74e394aec0 /binutils-2.25/ld/testsuite/ld-elf | |
parent | 2a6558a8ecfb81d75215b4ec7dc61113e12cfd5f (diff) | |
download | toolchain_binutils-54f1b3cf509cd889905287cb8ce6c5ae33911a21.zip toolchain_binutils-54f1b3cf509cd889905287cb8ce6c5ae33911a21.tar.gz toolchain_binutils-54f1b3cf509cd889905287cb8ce6c5ae33911a21.tar.bz2 |
Add upstream binutils-2.25 snapshot 4/4 2014
For MIPS -mmsa support
Change-Id: I08c4f002fa7b33dec85ed75956e6ab551bb03c96
Diffstat (limited to 'binutils-2.25/ld/testsuite/ld-elf')
450 files changed, 7396 insertions, 0 deletions
diff --git a/binutils-2.25/ld/testsuite/ld-elf/audit.exp b/binutils-2.25/ld/testsuite/ld-elf/audit.exp new file mode 100644 index 0000000..407c61a --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/audit.exp @@ -0,0 +1,65 @@ +# Expect script for various ELF tests. +# Copyright 2009 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. +# + +# Exclude non-ELF targets. + +if ![is_elf_format] { + return +} + +# The following tests require running the executable generated by ld. +if ![isnative] { + return +} + +# Check if compiler works +if { [which $CC] == 0 } { + return +} + +set build_tests { + {"Run with -paudit.so" + "-Wl,--audit=tmpdir/audit.so" "" + {main.c} {{"readelf" {-d} "audit.rd"}} "audit.out"} + {"Run with -Paudit.so" + "-Wl,-Ptmpdir/audit.so" "" + {main.c} {{"readelf" {-d} "depaudit.rd"}} "depaudit.out"} + {"Run with --depaudit=audit.so" + "-Wl,--depaudit=tmpdir/audit.so" "" + {main.c} {{"readelf" {-d} "depaudit.rd"}} "depaudit2.out"} + {"Run with shared with --audit" + "-shared -Wl,--audit=tmpdir/audit.so" "-fPIC" + {main.c} {} "libusesaudit.so"} + {"Run with shared with --audit" + "-shared -Wl,--audit=tmpdir/audit.so -Wl,--audit=tmpdir/audit2.so \ + -Wl,--audit=tmpdir/audit3.so" + "-fPIC" + {main.c} {} "libusesaudit2.so"} + {"Run with -lusesaudit" + "-Ltmpdir/ -lusesaudit" "" + {main.c} {{"readelf" {-d} "depaudit.rd"}} "useslibusesaudit.out"} + {"Run with -lusesaudit -lusesaudit2" + "-Ltmpdir/ -lusesaudit -lusesaudit2" "" + {main.c} {{"readelf" {-d} "depaudit2.rd"}} "useslibusesaudit2.out"} +} + +run_cc_link_tests $build_tests + diff --git a/binutils-2.25/ld/testsuite/ld-elf/audit.rd b/binutils-2.25/ld/testsuite/ld-elf/audit.rd new file mode 100644 index 0000000..fd3b941 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/audit.rd @@ -0,0 +1,3 @@ +#... +.*Audit library: \[tmpdir/audit.so\].* +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/begin.c b/binutils-2.25/ld/testsuite/ld-elf/begin.c new file mode 100644 index 0000000..ccc47d4 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/begin.c @@ -0,0 +1,5 @@ +extern void foo (void); + +static void (*const init_array []) (void) + __attribute__ ((used, section (".init_array"), aligned (sizeof (void *)))) + = { foo }; diff --git a/binutils-2.25/ld/testsuite/ld-elf/beginwarn.c b/binutils-2.25/ld/testsuite/ld-elf/beginwarn.c new file mode 100644 index 0000000..ebe2819 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/beginwarn.c @@ -0,0 +1,9 @@ +static const char _evoke_link_warning_foo [] + __attribute__ ((used, section (".gnu.warning.foo"))) + = "function foo is deprecated"; + +extern void foo (void); + +static void (*const init_array []) (void) + __attribute__ ((used, section (".init_array"), aligned (sizeof (void *)))) + = { foo }; diff --git a/binutils-2.25/ld/testsuite/ld-elf/binutils.exp b/binutils-2.25/ld/testsuite/ld-elf/binutils.exp new file mode 100644 index 0000000..0101512 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/binutils.exp @@ -0,0 +1,154 @@ +# 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 + } +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/comm-data.exp b/binutils-2.25/ld/testsuite/ld-elf/comm-data.exp new file mode 100644 index 0000000..71613c5 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/comm-data.exp @@ -0,0 +1,117 @@ +# Expect script for common symbol override. +# +# Copyright 2011, 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 Maciej W. Rozycki <macro@codesourcery.com> +# + +# This test is for ELF shared-library targets. +if { ![is_elf_format] || ![check_shared_lib_support] } { + return +} + +# This target requires extra GAS options when building code for shared +# libraries. +set AFLAGS_PIC "" +if [istarget "tic6x-*-*"] { + append AFLAGS_PIC " -mpic -mpid=near" +} +# This target requires a non-default emulation for successful shared +# library/executable builds. +set LFLAGS "" +if [istarget "tic6x-*-*"] { + append LFLAGS " -melf32_tic6x_le" +} + +set testname "Common symbol override test" + +# Define a global symbol. +run_ld_link_tests [list \ + [list \ + "$testname (auxiliary shared object build)" \ + "$LFLAGS -shared" "" \ + "$AFLAGS_PIC" \ + { comm-data1.s } \ + { \ + { readelf -s comm-data1.sd } \ + } \ + "libcomm-data.so" \ + ] \ +] + +# Set the pointer size according to the ELF flavor. +set AFLAGS "" +if [is_elf64 "tmpdir/libcomm-data.so"] { + append AFLAGS " --defsym ELF64=1" +} +# HPUX targets use a different .comm syntax. +if [istarget "*-*-hpux*"] { + append AFLAGS " --defsym HPUX=1" +} + +setup_xfail "arm*-*-*" "ld/13802" + +# List targets here that keep copy relocs rather than eliminating +# them where possible in favour to dynamic relocs in the relevant +# loadable sections; see also the "-z nocopyreloc" command-line +# option and the ELIMINATE_COPY_RELOCS macro some backends use. +set copy_reloc [expr [istarget mn10300-*-*] || [istarget vax-*-*]] + +# Verify that a common symbol has been converted to an undefined +# reference to the global symbol of the same name defined above +# and that the debug reference has been dropped. +run_ld_link_tests [list \ + [list \ + "$testname" \ + "$LFLAGS -T comm-data2.ld -Ltmpdir -lcomm-data" "" \ + "$AFLAGS" \ + { comm-data2.s } \ + [list \ + [list readelf -s \ + [expr { $copy_reloc ? "comm-data2r.sd" : "comm-data2.sd"}]] \ + [list readelf -r \ + [expr { $copy_reloc ? "comm-data2r.rd" : "comm-data2.rd"}]] \ + [list readelf "-x .debug_foo" \ + [expr { $copy_reloc ? "comm-data2r.xd" : "comm-data2.xd"}]]] \ + "comm-data" \ + ] \ + [list \ + "$testname 3a" \ + "-static" "" \ + "" \ + { comm-data3a.s comm-data3b.s } \ + { \ + { readelf -s comm-data3.sd } \ + } \ + "comm-data3a" \ + ] \ + [list \ + "$testname 3b" \ + "-static" "" \ + "" \ + { comm-data3b.s comm-data3a.s } \ + { \ + { readelf -s comm-data3.sd } \ + } \ + "comm-data3b" \ + ] \ +] diff --git a/binutils-2.25/ld/testsuite/ld-elf/comm-data1.s b/binutils-2.25/ld/testsuite/ld-elf/comm-data1.s new file mode 100644 index 0000000..ac20a64 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/comm-data1.s @@ -0,0 +1,6 @@ + .section .rodata,"a",%progbits + .balign 8 + .globl foo + .type foo,%object +foo: + .skip 4, 0 diff --git a/binutils-2.25/ld/testsuite/ld-elf/comm-data1.sd b/binutils-2.25/ld/testsuite/ld-elf/comm-data1.sd new file mode 100644 index 0000000..d00435b --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/comm-data1.sd @@ -0,0 +1,10 @@ +Symbol table '\.dynsym' contains [0-9]+ entries: + +Num: +Value +Size +Type +Bind +Vis +Ndx +Name +#... + +[0-9]+: +[0-9a-f]+ +0 +OBJECT +GLOBAL +DEFAULT +[0-9]+ +foo +#... +Symbol table '\.symtab' contains [0-9]+ entries: + +Num: +Value +Size +Type +Bind +Vis +Ndx +Name +#... + +[0-9]+: +[0-9a-f]+ +0 +OBJECT +GLOBAL +DEFAULT +[0-9]+ +foo +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/comm-data2.ld b/binutils-2.25/ld/testsuite/ld-elf/comm-data2.ld new file mode 100644 index 0000000..3244453 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/comm-data2.ld @@ -0,0 +1,20 @@ +SECTIONS +{ + . = 0x12340000; + .bss : { *(.dynbss) } + .got : { *(.got.plt) *(.got) } + .dynamic : { *(.dynamic) } + .data : { *(.data) } + . = 0x56780000; + .rela.dyn : { *(.rela.*) } + .interp : { *(.interp) } + .hash : { *(.hash) } + .dynsym : { *(.dynsym) } + .dynstr : { *(.dynstr) } + . = 0x76540000; + .debug_foo : { *(.debug_foo) } + .shstrtab : { *(.shstrtab) } + .symtab : { *(.symtab) } + .strtab : { *(.strtab) } + /DISCARD/ : { *(*) } +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/comm-data2.rd b/binutils-2.25/ld/testsuite/ld-elf/comm-data2.rd new file mode 100644 index 0000000..b852c16 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/comm-data2.rd @@ -0,0 +1 @@ +There are no relocations in this file\. diff --git a/binutils-2.25/ld/testsuite/ld-elf/comm-data2.s b/binutils-2.25/ld/testsuite/ld-elf/comm-data2.s new file mode 100644 index 0000000..168671f --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/comm-data2.s @@ -0,0 +1,18 @@ + .text + .globl _start + .globl __start +_start: +__start: + .ifdef HPUX +foo .comm 4 + .else + .comm foo, 4, 4 + .endif + .section .debug_foo,"",%progbits + .balign 16 + .ifdef ELF64 + .8byte foo + .else + .4byte foo + .endif + .balign 16 diff --git a/binutils-2.25/ld/testsuite/ld-elf/comm-data2.sd b/binutils-2.25/ld/testsuite/ld-elf/comm-data2.sd new file mode 100644 index 0000000..0e44eeb --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/comm-data2.sd @@ -0,0 +1,10 @@ +Symbol table '\.dynsym' contains [0-9]+ entries: + +Num: +Value +Size +Type +Bind +Vis +Ndx +Name +#... + +[0-9]+: +0+ +0 +OBJECT +GLOBAL +DEFAULT +UND +foo +#... +Symbol table '\.symtab' contains [0-9]+ entries: + +Num: +Value +Size +Type +Bind +Vis +Ndx +Name +#... + +[0-9]+: +0+ +0 +OBJECT +GLOBAL +DEFAULT +UND +foo +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/comm-data2.xd b/binutils-2.25/ld/testsuite/ld-elf/comm-data2.xd new file mode 100644 index 0000000..bff116e --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/comm-data2.xd @@ -0,0 +1,2 @@ +Hex dump of section '\.debug_foo': + +0x0*76540000 00000000 00000000 00000000 00000000 .* diff --git a/binutils-2.25/ld/testsuite/ld-elf/comm-data2r.rd b/binutils-2.25/ld/testsuite/ld-elf/comm-data2r.rd new file mode 100644 index 0000000..52c486d --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/comm-data2r.rd @@ -0,0 +1,3 @@ +Relocation section '\.rela\.dyn' at offset 0x[0-9a-f]+ contains 1 entries: + +Offset +Info +Type +Sym\.Value +Sym\. Name \+ Addend +0*12340000 +[0-9a-f]+ +R_.*_COPY +0*12340000 +foo \+ 0 diff --git a/binutils-2.25/ld/testsuite/ld-elf/comm-data2r.sd b/binutils-2.25/ld/testsuite/ld-elf/comm-data2r.sd new file mode 100644 index 0000000..685b0be --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/comm-data2r.sd @@ -0,0 +1,10 @@ +Symbol table '\.dynsym' contains [0-9]+ entries: + +Num: +Value +Size +Type +Bind +Vis +Ndx +Name +#... + +[0-9]+: +0*12340000 +4 +OBJECT +GLOBAL +DEFAULT +[0-9]+ +foo +#... +Symbol table '\.symtab' contains [0-9]+ entries: + +Num: +Value +Size +Type +Bind +Vis +Ndx +Name +#... + +[0-9]+: +0*12340000 +4 +OBJECT +GLOBAL +DEFAULT +[0-9]+ +foo +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/comm-data2r.xd b/binutils-2.25/ld/testsuite/ld-elf/comm-data2r.xd new file mode 100644 index 0000000..58f6f2a --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/comm-data2r.xd @@ -0,0 +1,2 @@ +Hex dump of section '\.debug_foo': + +0x0*76540000 (?:12340000 00000000|00003412 00000000|00000000 00003412) 00000000 00000000 .* diff --git a/binutils-2.25/ld/testsuite/ld-elf/comm-data3.sd b/binutils-2.25/ld/testsuite/ld-elf/comm-data3.sd new file mode 100644 index 0000000..5a96ed7 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/comm-data3.sd @@ -0,0 +1,3 @@ +#... + +[0-9]+: +[0-9a-f]+ +4 +OBJECT +GLOBAL +DEFAULT +[1-9] foo +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/comm-data3a.s b/binutils-2.25/ld/testsuite/ld-elf/comm-data3a.s new file mode 100644 index 0000000..e0bde49 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/comm-data3a.s @@ -0,0 +1,11 @@ + .globl main + .globl start + .globl _start + .globl __start + .text +main: +start: +_start: +__start: + .byte 0 + .common foo,4,4 diff --git a/binutils-2.25/ld/testsuite/ld-elf/comm-data3b.s b/binutils-2.25/ld/testsuite/ld-elf/comm-data3b.s new file mode 100644 index 0000000..837a099 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/comm-data3b.s @@ -0,0 +1,6 @@ + .weak foo + .type foo,%function + .size foo,1 + .text +foo: + .byte 1 diff --git a/binutils-2.25/ld/testsuite/ld-elf/comm-data4.d b/binutils-2.25/ld/testsuite/ld-elf/comm-data4.d new file mode 100644 index 0000000..05c4401 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/comm-data4.d @@ -0,0 +1,6 @@ +#source: comm-data4.s +#ld: +#readelf: -r +#notarget: hppa64*-*-hpux* + +There are no relocations in this file. diff --git a/binutils-2.25/ld/testsuite/ld-elf/comm-data4.s b/binutils-2.25/ld/testsuite/ld-elf/comm-data4.s new file mode 100644 index 0000000..ed17cf2 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/comm-data4.s @@ -0,0 +1,15 @@ + .comm i,4,4 + + .data + .dc.a i + + .globl main + .globl start + .globl _start + .globl __start + .text +main: +start: +_start: +__start: + .dc.a 0 diff --git a/binutils-2.25/ld/testsuite/ld-elf/comm-data5.d b/binutils-2.25/ld/testsuite/ld-elf/comm-data5.d new file mode 100644 index 0000000..36c09ba --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/comm-data5.d @@ -0,0 +1,7 @@ +#source: comm-data5.s +#ld: +#readelf: -r +#notarget: hppa64*-*-hpux* +#xfail: frv-*-*linux* + +There are no relocations in this file. diff --git a/binutils-2.25/ld/testsuite/ld-elf/comm-data5.s b/binutils-2.25/ld/testsuite/ld-elf/comm-data5.s new file mode 100644 index 0000000..1605b8a --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/comm-data5.s @@ -0,0 +1,15 @@ + .comm i,4,4 + + .section .rodata,"a",%progbits + .dc.a i + + .globl main + .globl start + .globl _start + .globl __start + .text +main: +start: +_start: +__start: + .dc.a 0 diff --git a/binutils-2.25/ld/testsuite/ld-elf/comm1.c b/binutils-2.25/ld/testsuite/ld-elf/comm1.c new file mode 100644 index 0000000..c553d86 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/comm1.c @@ -0,0 +1,17 @@ +#include <stdio.h> +#include <stdlib.h> + +int foo; +void bar (void); + +int +main () +{ + if (foo != 0) + abort (); + foo = 200; + bar (); + if (foo == 200) + printf ("PASS\n"); + return 0; +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/commonpage1.d b/binutils-2.25/ld/testsuite/ld-elf/commonpage1.d new file mode 100644 index 0000000..2b17574 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/commonpage1.d @@ -0,0 +1,9 @@ +#source: maxpage1.s +#ld: -z max-page-size=0x200000 -z common-page-size=0x100000 +#readelf: -l --wide +#target: *-*-linux* *-*-gnu* + +#... + LOAD+.*0x200000 + LOAD+.*0x200000 +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/commonpage2.d b/binutils-2.25/ld/testsuite/ld-elf/commonpage2.d new file mode 100644 index 0000000..e4d582b --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/commonpage2.d @@ -0,0 +1,9 @@ +#source: maxpage1.s +#as: --32 +#ld: -z max-page-size=0x200000 -z common-page-size=0x100000 -T maxpage4.t +#readelf: -l --wide +#target: x86_64-*-linux* + +#... + LOAD+.*0x200000 +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/compress.exp b/binutils-2.25/ld/testsuite/ld-elf/compress.exp new file mode 100644 index 0000000..55269ee --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/compress.exp @@ -0,0 +1,63 @@ +# Expect script for ELF compressed debug section tests. +# Copyright 2010 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. +# + +# Exclude non-ELF targets. + +if ![is_elf_format] { + return +} + +if ![is_zlib_supported] { + return +} + +# The following tests require running the executable generated by ld. +if ![isnative] { + return +} + +# Check if compiler works +if { [which $CC] == 0 } { + return +} + +global as +if { ![ld_assemble $as "--compress-debug-sections $srcdir/$subdir/empty.s" tmpdir/empty.o ] } { + unsupported "linker compressed debug sections" +} + +set build_tests { + {"Build libfoo.so with compressed debug sections" + "-shared" "-fPIC -g -Wa,--compress-debug-sections" + {foo.c} {} "libfoo.so"} + {"Build libbar.so with compressed debug sections" + "-shared" "-fPIC -g -Wa,--compress-debug-sections" + {begin.c end.c} {} "libbar.so"} +} + +set run_tests { + {"Run normal with libfoo.so with compressed debug sections" + "tmpdir/begin.o tmpdir/libfoo.so tmpdir/end.o" "-Wa,--compress-debug-sections" + {main.c} "normal" "normal.out"} +} + +run_cc_link_tests $build_tests +run_ld_link_exec_tests [] $run_tests diff --git a/binutils-2.25/ld/testsuite/ld-elf/compress1.s b/binutils-2.25/ld/testsuite/ld-elf/compress1.s new file mode 100644 index 0000000..8ef0a15 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/compress1.s @@ -0,0 +1,216 @@ +/* This testcase is derived from a similar test in GDB. + + Copyright 2008, 2009, 2010 Free Software Foundation, Inc. + + 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, see <http://www.gnu.org/licenses/>. */ + +/* Dummy function to provide debug information for. */ + + .text +.Lbegin_text1: + .globl func_cu2 + .type func_cu2, %function +func_cu2: +.Lbegin_func_cu2: + .int 0 +.Lend_func_cu2: + .size func_cu2, .-func_cu2 +.Lend_text1: + +/* Debug information */ + + .section .debug_info +.Lcu1_begin: + /* CU header */ + .4byte .Lcu1_end - .Lcu1_start /* Length of Compilation Unit */ +.Lcu1_start: + .2byte 2 /* DWARF Version */ + .4byte .Labbrev1_begin /* Offset into abbrev section */ + .byte 4 /* Pointer size */ + + /* CU die */ + .uleb128 1 /* Abbrev: DW_TAG_compile_unit */ + .4byte .Lline1_begin /* DW_AT_stmt_list */ + .4byte .Lend_text1 /* DW_AT_high_pc */ + .4byte .Lbegin_text1 /* DW_AT_low_pc */ + .ascii "file1.txt\0" /* DW_AT_name */ + .ascii "GNU C 3.3.3\0" /* DW_AT_producer */ + .byte 1 /* DW_AT_language (C) */ + + /* func_cu2 */ + .uleb128 2 /* Abbrev: DW_TAG_subprogram */ + .byte 1 /* DW_AT_external */ + .byte 1 /* DW_AT_decl_file */ + .byte 2 /* DW_AT_decl_line */ + .ascii "func_cu2\0" /* DW_AT_name */ + .4byte .Ltype_int-.Lcu1_begin /* DW_AT_type */ + .4byte .Lbegin_func_cu2 /* DW_AT_low_pc */ + .4byte .Lend_func_cu2 /* DW_AT_high_pc */ + .byte 1 /* DW_AT_frame_base: length */ + .byte 0x55 /* DW_AT_frame_base: DW_OP_reg5 */ + +.Ltype_int: + .uleb128 3 /* Abbrev: DW_TAG_base_type */ + .ascii "int\0" /* DW_AT_name */ + .byte 4 /* DW_AT_byte_size */ + .byte 5 /* DW_AT_encoding */ + + .byte 0 /* End of children of CU */ + +.Lcu1_end: + +/* Line table */ + .section .debug_line +.Lline1_begin: + .4byte .Lline1_end - .Lline1_start /* Initial length */ +.Lline1_start: + .2byte 2 /* Version */ + .4byte .Lline1_lines - .Lline1_hdr /* header_length */ +.Lline1_hdr: + .byte 1 /* Minimum insn length */ + .byte 1 /* default_is_stmt */ + .byte 1 /* line_base */ + .byte 1 /* line_range */ + .byte 0x10 /* opcode_base */ + + /* Standard lengths */ + .byte 0 + .byte 1 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .byte 0 + .byte 0 + .byte 1 + .byte 0 + .byte 0 + .byte 1 + .byte 0 + .byte 0 + .byte 0 + + /* Include directories */ + .byte 0 + + /* File names */ + .ascii "file1.txt\0" + .uleb128 0 + .uleb128 0 + .uleb128 0 + + .byte 0 + +.Lline1_lines: + .byte 0 /* DW_LNE_set_address */ + .uleb128 5 + .byte 2 + .4byte .Lbegin_func_cu2 + + .byte 3 /* DW_LNS_advance_line */ + .sleb128 3 /* ... to 4 */ + + .byte 1 /* DW_LNS_copy */ + + .byte 1 /* DW_LNS_copy (second time as an end-of-prologue marker) */ + + .byte 0 /* DW_LNE_set_address */ + .uleb128 5 + .byte 2 + .4byte .Lend_func_cu2 + + .byte 0 /* DW_LNE_end_of_sequence */ + .uleb128 1 + .byte 1 + +.Lline1_end: + +/* Abbrev table */ + .section .debug_abbrev +.Labbrev1_begin: + .uleb128 1 /* Abbrev code */ + .uleb128 0x11 /* DW_TAG_compile_unit */ + .byte 1 /* has_children */ + .uleb128 0x10 /* DW_AT_stmt_list */ + .uleb128 0x6 /* DW_FORM_data4 */ + .uleb128 0x12 /* DW_AT_high_pc */ + .uleb128 0x1 /* DW_FORM_addr */ + .uleb128 0x11 /* DW_AT_low_pc */ + .uleb128 0x1 /* DW_FORM_addr */ + .uleb128 0x3 /* DW_AT_name */ + .uleb128 0x8 /* DW_FORM_string */ + .uleb128 0x25 /* DW_AT_producer */ + .uleb128 0x8 /* DW_FORM_string */ + .uleb128 0x13 /* DW_AT_language */ + .uleb128 0xb /* DW_FORM_data1 */ + .byte 0x0 /* Terminator */ + .byte 0x0 /* Terminator */ + + .uleb128 2 /* Abbrev code */ + .uleb128 0x2e /* DW_TAG_subprogram */ + .byte 0 /* has_children */ + .uleb128 0x3f /* DW_AT_external */ + .uleb128 0xc /* DW_FORM_flag */ + .uleb128 0x3a /* DW_AT_decl_file */ + .uleb128 0xb /* DW_FORM_data1 */ + .uleb128 0x3b /* DW_AT_decl_line */ + .uleb128 0xb /* DW_FORM_data1 */ + .uleb128 0x3 /* DW_AT_name */ + .uleb128 0x8 /* DW_FORM_string */ + .uleb128 0x49 /* DW_AT_type */ + .uleb128 0x13 /* DW_FORM_ref4 */ + .uleb128 0x11 /* DW_AT_low_pc */ + .uleb128 0x1 /* DW_FORM_addr */ + .uleb128 0x12 /* DW_AT_high_pc */ + .uleb128 0x1 /* DW_FORM_addr */ + .uleb128 0x40 /* DW_AT_frame_base */ + .uleb128 0xa /* DW_FORM_block1 */ + .byte 0x0 /* Terminator */ + .byte 0x0 /* Terminator */ + + .uleb128 3 /* Abbrev code */ + .uleb128 0x24 /* DW_TAG_base_type */ + .byte 0 /* has_children */ + .uleb128 0x3 /* DW_AT_name */ + .uleb128 0x8 /* DW_FORM_string */ + .uleb128 0xb /* DW_AT_byte_size */ + .uleb128 0xb /* DW_FORM_data1 */ + .uleb128 0x3e /* DW_AT_encoding */ + .uleb128 0xb /* DW_FORM_data1 */ + .byte 0x0 /* Terminator */ + .byte 0x0 /* Terminator */ + + .byte 0x0 /* Terminator */ + .byte 0x0 /* Terminator */ + + .section .debug_pubnames,"",%progbits + .4byte 0x19 + .2byte 0x2 + .4byte .Lcu1_begin + .4byte 0x43 + .4byte 0x25 + .string "func_cu2" + .4byte 0x0 + .section .debug_aranges,"",%progbits + .4byte 0x1c + .2byte 0x2 + .4byte .Lcu1_begin + .byte 0x4 + .byte 0x0 + .2byte 0x0 + .2byte 0x0 + .4byte .Lbegin_text1 + .4byte .Lbegin_text1-.Lend_text1 + .4byte 0x0 + .4byte 0x0 diff --git a/binutils-2.25/ld/testsuite/ld-elf/compress1a.d b/binutils-2.25/ld/testsuite/ld-elf/compress1a.d new file mode 100644 index 0000000..a8eac40 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/compress1a.d @@ -0,0 +1,10 @@ +#source: compress1.s +#as: --compress-debug-sections +#ld: -e func_cu2 +#readelf: -S --wide +#notarget: alpha-* + +#failif +#... + \[[ 0-9]+\] \.zdebug_.*[ ]+(PROGBITS|MIPS_DWARF)[ 0-9a-z]+ .* +#... diff --git a/binutils-2.25/ld/testsuite/ld-elf/compress1b.d b/binutils-2.25/ld/testsuite/ld-elf/compress1b.d new file mode 100644 index 0000000..f3428d4 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/compress1b.d @@ -0,0 +1,9 @@ +#source: compress1.s +#as: --compress-debug-sections +#ld: -r +#readelf: -S --wide + +#failif +#... + \[[ 0-9]+\] \.zdebug_.*[ ]+(PROGBITS|MIPS_DWARF)[ 0-9a-z]+ .* +#... diff --git a/binutils-2.25/ld/testsuite/ld-elf/compress1c.d b/binutils-2.25/ld/testsuite/ld-elf/compress1c.d new file mode 100644 index 0000000..90abe0f --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/compress1c.d @@ -0,0 +1,10 @@ +#source: compress1.s +#as: --compress-debug-sections +#ld: -shared +#readelf: -S --wide +#target: *-*-linux* *-*-gnu* + +#failif +#... + \[[ 0-9]+\] \.zdebug_.*[ ]+(PROGBITS|MIPS_DWARF)[ 0-9a-z]+ .* +#... diff --git a/binutils-2.25/ld/testsuite/ld-elf/data1.c b/binutils-2.25/ld/testsuite/ld-elf/data1.c new file mode 100644 index 0000000..c205f82 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/data1.c @@ -0,0 +1,6 @@ +#include "data1.h" + +char a1[1] __attribute__ ((aligned (ALIGNMENT1))) = { 10 }; +char a2[2] __attribute__ ((aligned (ALIGNMENT2))); +char a3[3] __attribute__ ((aligned (ALIGNMENT3))); +char a4[4] __attribute__ ((aligned (ALIGNMENT4))); diff --git a/binutils-2.25/ld/testsuite/ld-elf/data1.h b/binutils-2.25/ld/testsuite/ld-elf/data1.h new file mode 100644 index 0000000..529ee4b --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/data1.h @@ -0,0 +1,9 @@ +#define ALIGNMENT1 0x800 +#define ALIGNMENT2 0x400 +#define ALIGNMENT3 0x200 +#define ALIGNMENT4 0x100 + +extern char a1[1]; +extern char a2[2]; +extern char a3[3]; +extern char a4[4]; diff --git a/binutils-2.25/ld/testsuite/ld-elf/data2.c b/binutils-2.25/ld/testsuite/ld-elf/data2.c new file mode 100644 index 0000000..c137b7c --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/data2.c @@ -0,0 +1,9 @@ +int foo = 0; +extern int foo_alias __attribute__ ((weak, alias ("foo"))); + +void +bar (void) +{ + foo = -1; +} + diff --git a/binutils-2.25/ld/testsuite/ld-elf/del.cc b/binutils-2.25/ld/testsuite/ld-elf/del.cc new file mode 100644 index 0000000..4e2cc60 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/del.cc @@ -0,0 +1,29 @@ +#include <new> + +extern "C" void free (void *); + +void +operator delete (void *ptr, const std::nothrow_t&) throw () +{ + if (ptr) + free (ptr); +} + +void +operator delete (void *ptr) throw () +{ + if (ptr) + free (ptr); +} + +void +operator delete[] (void *ptr) throw () +{ + ::operator delete (ptr); +} + +void +operator delete[] (void *ptr, const std::nothrow_t&) throw () +{ + ::operator delete (ptr); +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/depaudit.rd b/binutils-2.25/ld/testsuite/ld-elf/depaudit.rd new file mode 100644 index 0000000..98a2692 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/depaudit.rd @@ -0,0 +1,3 @@ +#... +.*Dependency audit library: \[tmpdir/audit.so\].* +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/depaudit2.rd b/binutils-2.25/ld/testsuite/ld-elf/depaudit2.rd new file mode 100644 index 0000000..3554416 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/depaudit2.rd @@ -0,0 +1,3 @@ +#... +.*Dependency audit library: \[tmpdir/audit.so:tmpdir/audit2.so:tmpdir/audit3.so\].* +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/discard.ld b/binutils-2.25/ld/testsuite/ld-elf/discard.ld new file mode 100644 index 0000000..bd094f2 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/discard.ld @@ -0,0 +1,3 @@ +SECTIONS { + /DISCARD/ : { *(.discard) } +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/discard1.d b/binutils-2.25/ld/testsuite/ld-elf/discard1.d new file mode 100644 index 0000000..da54b36 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/discard1.d @@ -0,0 +1,9 @@ +#source: discard1.s +#ld: -r -T discard.ld +#readelf: -r +#target: x86_64-*-linux-gnu* i?86-*-linux-gnu i?86-*-gnu* + +Relocation section '.rel.*.debug_info' at offset 0x[0-9a-z]+ contains 1 entries: +[ \t]+Offset[ \t]+Info[ \t]+Type[ \t]+Sym.* +[0-9a-f]+[ \t]+[0-9a-f]+[ \t]+R_.*[ \t]+[0-9a-f]+[ \t]+bar.* +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/discard1.s b/binutils-2.25/ld/testsuite/ld-elf/discard1.s new file mode 100644 index 0000000..ac3b92f --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/discard1.s @@ -0,0 +1,11 @@ + .globl bar + .data +bar: + .long 1 + .section .discard,"aw",%progbits + .align 4 +there: + .long 2 + .section .debug_info,"",%progbits + .long bar + .long there diff --git a/binutils-2.25/ld/testsuite/ld-elf/discard2.d b/binutils-2.25/ld/testsuite/ld-elf/discard2.d new file mode 100644 index 0000000..54bedcb --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/discard2.d @@ -0,0 +1,9 @@ +#source: discard2.s +#ld: -r -T discard.ld +#readelf: -r +#target: x86_64-*-linux-gnu* i?86-*-linux-gnu i?86-*-gnu* + +Relocation section '.rel.*.debug_info' at offset 0x[0-9a-z]+ contains 1 entries: +[ \t]+Offset[ \t]+Info[ \t]+Type[ \t]+Sym.* +[0-9a-f]+[ \t]+[0-9a-f]+[ \t]+R_.*[ \t]+[0-9a-f]+[ \t]+here.* +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/discard2.s b/binutils-2.25/ld/testsuite/ld-elf/discard2.s new file mode 100644 index 0000000..27b66f4 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/discard2.s @@ -0,0 +1,12 @@ + .globl here + .data +here: + .long 1 + .globl there + .section .discard,"aw",%progbits + .align 4 +there: + .long 2 + .section .debug_info,"",%progbits + .long here + .long there diff --git a/binutils-2.25/ld/testsuite/ld-elf/discard3.d b/binutils-2.25/ld/testsuite/ld-elf/discard3.d new file mode 100644 index 0000000..970a8af --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/discard3.d @@ -0,0 +1,11 @@ +#source: discard1.s +#source: discard2.s +#ld: -r -T discard.ld +#readelf: -r +#target: x86_64-*-linux-gnu* i?86-*-linux-gnu i?86-*-gnu* + +Relocation section '.rel.*.debug_info' at offset 0x[0-9a-z]+ contains 2 entries: +[ \t]+Offset[ \t]+Info[ \t]+Type[ \t]+Sym.* +[0-9a-f]+[ \t]+[0-9a-f]+[ \t]+R_.*[ \t]+[0-9a-f]+[ \t]+bar.* +[0-9a-f]+[ \t]+[0-9a-f]+[ \t]+R_.*[ \t]+[0-9a-f]+[ \t]+here.* +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/dl1.c b/binutils-2.25/ld/testsuite/ld-elf/dl1.c new file mode 100644 index 0000000..09426f3 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/dl1.c @@ -0,0 +1,10 @@ +#include <stdio.h> + +extern int bar; + +void +foo (void) +{ + if (bar == -20) + printf ("OK\n"); +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/dl1.list b/binutils-2.25/ld/testsuite/ld-elf/dl1.list new file mode 100644 index 0000000..9ffada0 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/dl1.list @@ -0,0 +1,6 @@ +{ + extern "C" + { + bar; + }; +}; diff --git a/binutils-2.25/ld/testsuite/ld-elf/dl1.out b/binutils-2.25/ld/testsuite/ld-elf/dl1.out new file mode 100644 index 0000000..d86bac9 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/dl1.out @@ -0,0 +1 @@ +OK diff --git a/binutils-2.25/ld/testsuite/ld-elf/dl1main.c b/binutils-2.25/ld/testsuite/ld-elf/dl1main.c new file mode 100644 index 0000000..f224e12 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/dl1main.c @@ -0,0 +1,33 @@ +#include <stdio.h> +#include <dlfcn.h> + +int bar = -20; + +int +main (void) +{ + int ret = 0; + void *handle; + void (*fcn) (void); + + handle = dlopen("./tmpdir/libdl1.so", RTLD_GLOBAL|RTLD_LAZY); + if (!handle) + { + printf("dlopen ./tmpdir/libdl1.so: %s\n", dlerror ()); + return 1; + } + + fcn = (void (*)(void)) dlsym(handle, "foo"); + if (!fcn) + { + printf("dlsym foo: %s\n", dlerror ()); + ret += 1; + } + else + { + (*fcn) (); + } + + dlclose (handle); + return ret; +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/dl2.c b/binutils-2.25/ld/testsuite/ld-elf/dl2.c new file mode 100644 index 0000000..b5cd927 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/dl2.c @@ -0,0 +1,16 @@ +#include <stdio.h> + +int foo; + +extern void xxx (void); + +void +bar (int x) +{ + if (foo == 1) + printf ("OK1\n"); + else if (foo == 0) + printf ("OK2\n"); + foo = -1; + xxx (); +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/dl2.list b/binutils-2.25/ld/testsuite/ld-elf/dl2.list new file mode 100644 index 0000000..e985dcf --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/dl2.list @@ -0,0 +1,3 @@ +{ + foo; +}; diff --git a/binutils-2.25/ld/testsuite/ld-elf/dl2a.list b/binutils-2.25/ld/testsuite/ld-elf/dl2a.list new file mode 100644 index 0000000..989646e --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/dl2a.list @@ -0,0 +1,3 @@ +{ + "foo"; +}; diff --git a/binutils-2.25/ld/testsuite/ld-elf/dl2a.out b/binutils-2.25/ld/testsuite/ld-elf/dl2a.out new file mode 100644 index 0000000..f3d5b9f --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/dl2a.out @@ -0,0 +1,3 @@ +OK1 +DSO +OK1 diff --git a/binutils-2.25/ld/testsuite/ld-elf/dl2b.out b/binutils-2.25/ld/testsuite/ld-elf/dl2b.out new file mode 100644 index 0000000..f30cead --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/dl2b.out @@ -0,0 +1,3 @@ +OK1 +MAIN +OK1 diff --git a/binutils-2.25/ld/testsuite/ld-elf/dl2main.c b/binutils-2.25/ld/testsuite/ld-elf/dl2main.c new file mode 100644 index 0000000..ddf677f --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/dl2main.c @@ -0,0 +1,22 @@ +#include <stdio.h> + +extern int foo; +extern void bar (void); + +void +xxx (void) +{ + printf ("MAIN\n"); +} + +int +main (void) +{ + foo = 1; + bar (); + if (foo == -1) + printf ("OK1\n"); + else if (foo == 1) + printf ("OK2\n"); + return 0; +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/dl2xxx.c b/binutils-2.25/ld/testsuite/ld-elf/dl2xxx.c new file mode 100644 index 0000000..cf3a1d0 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/dl2xxx.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +void +xxx (void) +{ + printf ("DSO\n"); +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/dl2xxx.list b/binutils-2.25/ld/testsuite/ld-elf/dl2xxx.list new file mode 100644 index 0000000..9388cda --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/dl2xxx.list @@ -0,0 +1,3 @@ +{ + xxx; +}; diff --git a/binutils-2.25/ld/testsuite/ld-elf/dl3.cc b/binutils-2.25/ld/testsuite/ld-elf/dl3.cc new file mode 100644 index 0000000..558e49f --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/dl3.cc @@ -0,0 +1,7 @@ +#include "dl3header.h" + +void +f (void) +{ + throw (A (42)); +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/dl3.list b/binutils-2.25/ld/testsuite/ld-elf/dl3.list new file mode 100644 index 0000000..0b347ea --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/dl3.list @@ -0,0 +1,6 @@ +{ + extern "C++" + { + typeinfo*; + }; +}; diff --git a/binutils-2.25/ld/testsuite/ld-elf/dl3a.out b/binutils-2.25/ld/testsuite/ld-elf/dl3a.out new file mode 100644 index 0000000..d86bac9 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/dl3a.out @@ -0,0 +1 @@ +OK diff --git a/binutils-2.25/ld/testsuite/ld-elf/dl3b.out b/binutils-2.25/ld/testsuite/ld-elf/dl3b.out new file mode 100644 index 0000000..8a15044 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/dl3b.out @@ -0,0 +1 @@ +BAD2 diff --git a/binutils-2.25/ld/testsuite/ld-elf/dl3header.h b/binutils-2.25/ld/testsuite/ld-elf/dl3header.h new file mode 100644 index 0000000..66f7d46 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/dl3header.h @@ -0,0 +1,5 @@ +struct A +{ + int i; + A (int i): i(i) {} +}; diff --git a/binutils-2.25/ld/testsuite/ld-elf/dl3main.cc b/binutils-2.25/ld/testsuite/ld-elf/dl3main.cc new file mode 100644 index 0000000..977f9bb --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/dl3main.cc @@ -0,0 +1,25 @@ +#include <stdio.h> +#include "dl3header.h" + +extern void f (void); + +int +main (void) +{ + try + { + f(); + } + catch (A a) + { + if (a.i == 42) + printf ("OK\n"); + else + printf ("BAD1\n"); + } + catch (...) + { + printf ("BAD2\n"); + } + return 0; +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/dl4.c b/binutils-2.25/ld/testsuite/ld-elf/dl4.c new file mode 100644 index 0000000..bf6f070 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/dl4.c @@ -0,0 +1,24 @@ +#include <stdio.h> + +int foo1; +int foo2; + +extern void xxx1 (void); +extern void xxx2 (void); + +void +bar (int x) +{ + if (foo1 == 1) + printf ("bar OK1\n"); + else if (foo1 == 0) + printf ("bar OK2\n"); + if (foo2 == 1) + printf ("bar OK3\n"); + else if (foo2 == 0) + printf ("bar OK4\n"); + foo1 = -1; + foo2 = -1; + xxx1 (); + xxx2 (); +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/dl4.list b/binutils-2.25/ld/testsuite/ld-elf/dl4.list new file mode 100644 index 0000000..e932e23 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/dl4.list @@ -0,0 +1,4 @@ +{ + foo1; + foo2; +}; diff --git a/binutils-2.25/ld/testsuite/ld-elf/dl4a.out b/binutils-2.25/ld/testsuite/ld-elf/dl4a.out new file mode 100644 index 0000000..871c5be --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/dl4a.out @@ -0,0 +1,6 @@ +bar OK1 +bar OK3 +DSO1 +DSO2 +OK1 +OK3 diff --git a/binutils-2.25/ld/testsuite/ld-elf/dl4b.out b/binutils-2.25/ld/testsuite/ld-elf/dl4b.out new file mode 100644 index 0000000..b838f5b --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/dl4b.out @@ -0,0 +1,6 @@ +bar OK1 +bar OK3 +MAIN1 +MAIN2 +OK1 +OK3 diff --git a/binutils-2.25/ld/testsuite/ld-elf/dl4main.c b/binutils-2.25/ld/testsuite/ld-elf/dl4main.c new file mode 100644 index 0000000..173450d --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/dl4main.c @@ -0,0 +1,34 @@ +#include <stdio.h> + +extern int foo1; +extern int foo2; +extern void bar (void); + +void +xxx1 (void) +{ + printf ("MAIN1\n"); +} + +void +xxx2 (void) +{ + printf ("MAIN2\n"); +} + +int +main (void) +{ + foo1 = 1; + foo2 = 1; + bar (); + if (foo1 == -1) + printf ("OK1\n"); + else if (foo1 == 1) + printf ("OK2\n"); + if (foo2 == -1) + printf ("OK3\n"); + else if (foo2 == 1) + printf ("OK4\n"); + return 0; +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/dl4xxx.c b/binutils-2.25/ld/testsuite/ld-elf/dl4xxx.c new file mode 100644 index 0000000..8180eb1 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/dl4xxx.c @@ -0,0 +1,13 @@ +#include <stdio.h> + +void +xxx1 (void) +{ + printf ("DSO1\n"); +} + +void +xxx2 (void) +{ + printf ("DSO2\n"); +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/dl4xxx.list b/binutils-2.25/ld/testsuite/ld-elf/dl4xxx.list new file mode 100644 index 0000000..f39ce14 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/dl4xxx.list @@ -0,0 +1,4 @@ +{ + xxx1; + xxx2; +}; diff --git a/binutils-2.25/ld/testsuite/ld-elf/dl5.cc b/binutils-2.25/ld/testsuite/ld-elf/dl5.cc new file mode 100644 index 0000000..cc40455 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/dl5.cc @@ -0,0 +1,61 @@ +#include <stdio.h> +#include <stdlib.h> +#include <new> + +int pass = 0; + +void * +operator new (size_t sz, const std::nothrow_t&) throw () +{ + void *p; + pass++; + p = malloc(sz); + return p; +} + +void * +operator new (size_t sz) throw (std::bad_alloc) +{ + void *p; + pass++; + p = malloc(sz); + return p; +} + +void +operator delete (void *ptr) throw () +{ + pass++; + if (ptr) + free (ptr); +} + +class A +{ +public: + A() {} + ~A() { } + int a; + int b; +}; + + +int +main (void) +{ + A *bb = new A[10]; + delete [] bb; + bb = new (std::nothrow) A [10]; + delete [] bb; + + if (pass == 4) + { + printf ("PASS\n"); + return 0; + } + else + { + printf ("FAIL\n"); + return 1; + } +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/dl5.out b/binutils-2.25/ld/testsuite/ld-elf/dl5.out new file mode 100644 index 0000000..7ef22e9 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/dl5.out @@ -0,0 +1 @@ +PASS diff --git a/binutils-2.25/ld/testsuite/ld-elf/dl6.c b/binutils-2.25/ld/testsuite/ld-elf/dl6.c new file mode 100644 index 0000000..f655ca6 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/dl6.c @@ -0,0 +1,14 @@ +#include <stdio.h> + +int bar = 10; + +void +foo (void) +{ + if (bar == 10) + printf ("bar is in DSO.\n"); + else if (bar == -20) + printf ("bar is in main.\n"); + else + printf ("FAIL\n"); +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/dl6a.out b/binutils-2.25/ld/testsuite/ld-elf/dl6a.out new file mode 100644 index 0000000..186e848 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/dl6a.out @@ -0,0 +1 @@ +bar is in main. diff --git a/binutils-2.25/ld/testsuite/ld-elf/dl6amain.c b/binutils-2.25/ld/testsuite/ld-elf/dl6amain.c new file mode 100644 index 0000000..9824224 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/dl6amain.c @@ -0,0 +1,33 @@ +#include <stdio.h> +#include <dlfcn.h> + +int bar = -20; + +int +main (void) +{ + int ret = 0; + void *handle; + void (*fcn) (void); + + handle = dlopen("./tmpdir/libdl6a.so", RTLD_GLOBAL|RTLD_LAZY); + if (!handle) + { + printf("dlopen ./tmpdir/libdl6a.so: %s\n", dlerror ()); + return 1; + } + + fcn = (void (*)(void)) dlsym(handle, "foo"); + if (!fcn) + { + printf("dlsym foo: %s\n", dlerror ()); + ret += 1; + } + else + { + (*fcn) (); + } + + dlclose (handle); + return ret; +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/dl6b.out b/binutils-2.25/ld/testsuite/ld-elf/dl6b.out new file mode 100644 index 0000000..8cc87f5 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/dl6b.out @@ -0,0 +1 @@ +bar is in DSO. diff --git a/binutils-2.25/ld/testsuite/ld-elf/dl6bmain.c b/binutils-2.25/ld/testsuite/ld-elf/dl6bmain.c new file mode 100644 index 0000000..df9dbcc --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/dl6bmain.c @@ -0,0 +1,33 @@ +#include <stdio.h> +#include <dlfcn.h> + +int bar = -20; + +int +main (void) +{ + int ret = 0; + void *handle; + void (*fcn) (void); + + handle = dlopen("./tmpdir/libdl6b.so", RTLD_GLOBAL|RTLD_LAZY); + if (!handle) + { + printf("dlopen ./tmpdir/libdl6b.so: %s\n", dlerror ()); + return 1; + } + + fcn = (void (*)(void)) dlsym(handle, "foo"); + if (!fcn) + { + printf("dlsym foo: %s\n", dlerror ()); + ret += 1; + } + else + { + (*fcn) (); + } + + dlclose (handle); + return ret; +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/dl6cmain.c b/binutils-2.25/ld/testsuite/ld-elf/dl6cmain.c new file mode 100644 index 0000000..f6c285c --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/dl6cmain.c @@ -0,0 +1,33 @@ +#include <stdio.h> +#include <dlfcn.h> + +int bar = -20; + +int +main (void) +{ + int ret = 0; + void *handle; + void (*fcn) (void); + + handle = dlopen("./tmpdir/libdl6c.so", RTLD_GLOBAL|RTLD_LAZY); + if (!handle) + { + printf("dlopen ./tmpdir/libdl6c.so: %s\n", dlerror ()); + return 1; + } + + fcn = (void (*)(void)) dlsym(handle, "foo"); + if (!fcn) + { + printf("dlsym foo: %s\n", dlerror ()); + ret += 1; + } + else + { + (*fcn) (); + } + + dlclose (handle); + return ret; +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/dl6dmain.c b/binutils-2.25/ld/testsuite/ld-elf/dl6dmain.c new file mode 100644 index 0000000..2e57eb7 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/dl6dmain.c @@ -0,0 +1,33 @@ +#include <stdio.h> +#include <dlfcn.h> + +int bar = -20; + +int +main (void) +{ + int ret = 0; + void *handle; + void (*fcn) (void); + + handle = dlopen("./tmpdir/libdl6d.so", RTLD_GLOBAL|RTLD_LAZY); + if (!handle) + { + printf("dlopen ./tmpdir/libdl6d.so: %s\n", dlerror ()); + return 1; + } + + fcn = (void (*)(void)) dlsym(handle, "foo"); + if (!fcn) + { + printf("dlsym foo: %s\n", dlerror ()); + ret += 1; + } + else + { + (*fcn) (); + } + + dlclose (handle); + return ret; +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/dummy.c b/binutils-2.25/ld/testsuite/ld-elf/dummy.c new file mode 100644 index 0000000..5c03287 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/dummy.c @@ -0,0 +1 @@ +/* An empty file. */ diff --git a/binutils-2.25/ld/testsuite/ld-elf/dwarf.exp b/binutils-2.25/ld/testsuite/ld-elf/dwarf.exp new file mode 100644 index 0000000..c313236 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/dwarf.exp @@ -0,0 +1,114 @@ +# Expect script for various DWARF tests. +# Copyright 2006, 2007 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) +# + +# Exclude non-ELF targets. + +if ![is_elf_format] { + return +} + +# The following tests require running the executable generated by ld. +if ![isnative] { + return +} + +# Check if compiler works +if { [which $CC] == 0 } { + return +} + +# Skip if -feliminate-dwarf2-dups isn't supported. +if ![ld_compile "$CC -g -feliminate-dwarf2-dups" $srcdir/$subdir/dummy.c tmpdir/dummy.o] { + return +} + +set build_tests { + {"Build libdwarf1.so" + "-s -shared" "-fPIC -g -feliminate-dwarf2-dups" + {dwarf1.c} {} "libdwarf1.so"} +} + +set run_tests { + {"Run with libdwarf1.so first" + "tmpdir/libdwarf1.so" "" + {dwarf1main.c} "dwarf1a" "dwarf1.out" + "-g -feliminate-dwarf2-dups"} + {"Run with libdwarf1.so last" + "tmpdir/dwarf1main.o tmpdir/libdwarf1.so" "" + {dummy.c} "dwarf1b" "dwarf1.out" + "-g -feliminate-dwarf2-dups"} +} + +run_cc_link_tests $build_tests +run_ld_link_exec_tests [] $run_tests + +proc strip_test {} { + global ld + global strip + global NM + + set test "libdwarf1c.so" + set test_name "Strip -s $test" + set prog $strip + + if ![ld_simple_link $ld tmpdir/$test "-shared tmpdir/dwarf1.o"] { + unresolved "$test_name" + return + } + + send_log "$NM -D tmpdir/$test > tmpdir/$test.exp\n" + catch "exec $NM -D tmpdir/$test > tmpdir/$test.exp" got + if ![string match "" $got] then { + send_log "$got\n" + unresolved "$test_name" + return + } + + send_log "$prog -s tmpdir/$test\n" + catch "exec $prog -s tmpdir/$test" got + if ![string match "" $got] then { + send_log "$got\n" + fail "$test_name" + return + } + + send_log "$NM -D tmpdir/$test > tmpdir/$test.out\n" + catch "exec $NM -D tmpdir/$test > tmpdir/$test.out" got + if ![string match "" $got] 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" +} + +strip_test diff --git a/binutils-2.25/ld/testsuite/ld-elf/dwarf1.c b/binutils-2.25/ld/testsuite/ld-elf/dwarf1.c new file mode 100644 index 0000000..2895d4c --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/dwarf1.c @@ -0,0 +1,10 @@ +#include <stdio.h> +#include "dwarf1.h" + +struct foo_s foo; + +void +doprintf (void) +{ + printf ("OK\n"); +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/dwarf1.h b/binutils-2.25/ld/testsuite/ld-elf/dwarf1.h new file mode 100644 index 0000000..3cd7918 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/dwarf1.h @@ -0,0 +1,6 @@ +struct foo_s +{ + int foo; +}; + +extern void doprintf (void); diff --git a/binutils-2.25/ld/testsuite/ld-elf/dwarf1.out b/binutils-2.25/ld/testsuite/ld-elf/dwarf1.out new file mode 100644 index 0000000..d86bac9 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/dwarf1.out @@ -0,0 +1 @@ +OK diff --git a/binutils-2.25/ld/testsuite/ld-elf/dwarf1main.c b/binutils-2.25/ld/testsuite/ld-elf/dwarf1main.c new file mode 100644 index 0000000..9045198 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/dwarf1main.c @@ -0,0 +1,10 @@ +#include "dwarf1.h" + +struct foo_s foo; + +int +main (void) +{ + doprintf (); + return 0; +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/dynamic1.d b/binutils-2.25/ld/testsuite/ld-elf/dynamic1.d new file mode 100644 index 0000000..6a8ba55 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/dynamic1.d @@ -0,0 +1,10 @@ +#ld: -shared -T dynamic1.ld +#readelf: -l --wide +#target: *-*-linux* *-*-gnu* + +#... + Section to Segment mapping: + Segment Sections... +#... + 0[1-9] .dynamic[ ]* +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/dynamic1.ld b/binutils-2.25/ld/testsuite/ld-elf/dynamic1.ld new file mode 100644 index 0000000..d110bf7 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/dynamic1.ld @@ -0,0 +1,8 @@ +SECTIONS +{ + . = SIZEOF_HEADERS; + .text : { *(.text) } + .data : { *(.data) } + .data1 : { KEEP (*(.data1)) } + .dynamic : { *(.dynamic) } +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/dynamic1.s b/binutils-2.25/ld/testsuite/ld-elf/dynamic1.s new file mode 100644 index 0000000..f1caf0e --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/dynamic1.s @@ -0,0 +1,2 @@ +.section .data1,"aw" +.balign 16 diff --git a/binutils-2.25/ld/testsuite/ld-elf/dynbss1.c b/binutils-2.25/ld/testsuite/ld-elf/dynbss1.c new file mode 100644 index 0000000..eb5f067 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/dynbss1.c @@ -0,0 +1,20 @@ +#include <stdio.h> +#include <stdlib.h> +#include "data1.h" + +int +main (void) +{ + if ((((long) (&a1)) & (ALIGNMENT1 - 1))) + abort (); + if ((((long) (&a2)) & (ALIGNMENT2 - 1))) + abort (); + if ((((long) (&a2)) & (ALIGNMENT3 - 1))) + abort (); + if ((((long) (&a3)) & (ALIGNMENT4 - 1))) + abort (); + + printf ("PASS\n"); + + return(0) ; +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/dynsym1.d b/binutils-2.25/ld/testsuite/ld-elf/dynsym1.d new file mode 100644 index 0000000..b354aae --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/dynsym1.d @@ -0,0 +1,8 @@ +#source: empty.s +#ld: -shared +#readelf: --dyn-syms +#target: *-*-linux* *-*-gnu* + +#... + +[0-9]+: +[0-9a-f]+ +[0-9]+ +FUNC +GLOBAL +DEFAULT +[1-9] _start +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/eh-frame-hdr.d b/binutils-2.25/ld/testsuite/ld-elf/eh-frame-hdr.d new file mode 100644 index 0000000..1122cba --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/eh-frame-hdr.d @@ -0,0 +1,9 @@ +#source: eh-frame-hdr.s +#ld: -e _start --eh-frame-hdr +#objdump: -hw +#target: cfi +#xfail: avr*-*-* +# avr doesn't support shared libraries. +#... + [0-9] .eh_frame_hdr 0*[12][048c] .* +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/eh-frame-hdr.s b/binutils-2.25/ld/testsuite/ld-elf/eh-frame-hdr.s new file mode 100644 index 0000000..e5d3318 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/eh-frame-hdr.s @@ -0,0 +1,6 @@ + .text + .global _start +_start: + .cfi_startproc + .skip 16 + .cfi_endproc diff --git a/binutils-2.25/ld/testsuite/ld-elf/eh-group.exp b/binutils-2.25/ld/testsuite/ld-elf/eh-group.exp new file mode 100644 index 0000000..6fe7058 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/eh-group.exp @@ -0,0 +1,72 @@ +# Expect script for .eh_frame entries to a removed section. +# Copyright 2008, 2009 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 Jan Kratochvil (jan.kratochvil@redhat.com) +# +# .eh_frame with relocations to a removed (group) section did result to: +# error in tmpdir/eh-group.o(.eh_frame); no .eh_frame_hdr table will be created. +# The purpose of this test is to merge two .o files with -r and then link this +# merged file (containing a discarded R_X86_64_NONE relocation) to the final +# executable trying to create .eh_frame_hdr. It needs a separate .exp file due +# to the requirement of two `ld' runs. + +# Exclude non-CFI (such as ia64) targets. + +if {![check_as_cfi]} { + return +} + +# The test uses ELF .section directive +if ![is_elf_format] { + return +} + +# alpha-linux-gnu does not support 64-bit relocations: +# relocation truncated to fit: REFLONG against `.gcc_except_table' +# arm-eabi does not support 64-bit relocations: +# bad relocation fixup type (1) +set testname "Guess the target size from eh-group1size.o" +if [ld_assemble $as "$srcdir/$subdir/eh-group1.s" "tmpdir/eh-group1size.o"] { + pass $testname +} else { + fail $testname +} + +set as_options "" +if [is_elf64 "tmpdir/eh-group1size.o"] { + set as_options "$as_options --defsym ELF64=1" +} + +set build_tests_ld [list \ + [list "Build eh-group1.o" \ + "-r" "" "$as_options" \ + {eh-group1.s eh-group2.s} {} "eh-group.o"] \ +] + +run_ld_link_tests $build_tests_ld + +set testname "Link eh-group.o to eh-group" +if [ld_simple_link $ld "tmpdir/eh-group" "-e _start tmpdir/eh-group.o"] { + pass $testname +} else { + fail $testname +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/eh-group1.s b/binutils-2.25/ld/testsuite/ld-elf/eh-group1.s new file mode 100644 index 0000000..d6fdb88 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/eh-group1.s @@ -0,0 +1,6 @@ + .section sect, "axG", %progbits, sectgroup, comdat + .global _start +_start: + .cfi_startproc + .skip 16 + .cfi_endproc diff --git a/binutils-2.25/ld/testsuite/ld-elf/eh-group2.s b/binutils-2.25/ld/testsuite/ld-elf/eh-group2.s new file mode 100644 index 0000000..49b59de --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/eh-group2.s @@ -0,0 +1,15 @@ + .section sect, "axG", %progbits, sectgroup, comdat + .cfi_startproc +# Test intention is that LSDA must be provided by the discarded FDE. +# DW_EH_PE_udata8 = 4 +# DW_EH_PE_udata4 = 3 + .ifdef ELF64 + .cfi_lsda 4, lsda + .else + .cfi_lsda 3, lsda + .endif + .skip 16 + .cfi_endproc + + .section .gcc_except_table, "a", %progbits +lsda: diff --git a/binutils-2.25/ld/testsuite/ld-elf/eh1.d b/binutils-2.25/ld/testsuite/ld-elf/eh1.d new file mode 100644 index 0000000..bdf84cc --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/eh1.d @@ -0,0 +1,34 @@ +#source: eh1.s +#source: eh1a.s +#as: --64 +#ld: -melf_x86_64 -Ttext 0x400078 +#readelf: -wf +#target: x86_64-*-* + +Contents of the .eh_frame section: + +0+0000 0+014 0+0000 CIE + Version: 1 + Augmentation: "" + Code alignment factor: 1 + Data alignment factor: -8 + Return address column: 16 + + DW_CFA_def_cfa: r7 \(rsp\) ofs 8 + DW_CFA_offset: r16 \(rip\) at cfa-8 + DW_CFA_nop + DW_CFA_nop + DW_CFA_nop + DW_CFA_nop + DW_CFA_nop + DW_CFA_nop + +0+0018 0+001c 0+001c FDE cie=0+0000 pc=0+400078..0+400078 + DW_CFA_advance_loc: 0 to 0+400078 + DW_CFA_def_cfa_offset: 16 + DW_CFA_offset: r6 \(rbp\) at cfa-16 + DW_CFA_advance_loc: 0 to 0+400078 + DW_CFA_def_cfa_register: r6 \(rbp\) + +0+0038 ZERO terminator + diff --git a/binutils-2.25/ld/testsuite/ld-elf/eh1.s b/binutils-2.25/ld/testsuite/ld-elf/eh1.s new file mode 100644 index 0000000..a605209 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/eh1.s @@ -0,0 +1,47 @@ + .text +.globl _start + .type _start, %function +_start: +.LFB2: +.LCFI0: +.LCFI1: +.LFE2: + .size _start, .-_start + .section .eh_frame,"a",%progbits +.Lframe1: + .long .LECIE1-.LSCIE1 +.LSCIE1: + .long 0x0 + .byte 0x1 + .string "" + .uleb128 0x1 + .sleb128 -8 + .byte 0x10 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x90 + .uleb128 0x1 + .align 8 +.LECIE1: +.LSFDE1: + .long .LEFDE1-.LASFDE1 +.LASFDE1: + .long .LASFDE1-.Lframe1 + .quad .LFB2 + .quad .LFE2-.LFB2 + .byte 0x4 + .long .LCFI0-.LFB2 + .byte 0xe + .uleb128 0x10 + .byte 0x86 + .uleb128 0x2 + .byte 0x4 + .long .LCFI1-.LCFI0 + .byte 0xd + .uleb128 0x6 + .byte 0x0 + .byte 0x0 + .byte 0x0 + .byte 0x0 +.LEFDE1: diff --git a/binutils-2.25/ld/testsuite/ld-elf/eh1a.s b/binutils-2.25/ld/testsuite/ld-elf/eh1a.s new file mode 100644 index 0000000..c644014 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/eh1a.s @@ -0,0 +1,3 @@ + .section .eh_frame,"a",%progbits + .align 8 + .zero 4 diff --git a/binutils-2.25/ld/testsuite/ld-elf/eh2.d b/binutils-2.25/ld/testsuite/ld-elf/eh2.d new file mode 100644 index 0000000..65ad448 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/eh2.d @@ -0,0 +1,34 @@ +#source: eh1.s +#source: eh2a.s +#as: --64 +#ld: -melf_x86_64 -Ttext 0x400078 +#readelf: -wf +#target: x86_64-*-* + +Contents of the .eh_frame section: + +0+0000 0+0014 0+0000 CIE + Version: 1 + Augmentation: "" + Code alignment factor: 1 + Data alignment factor: -8 + Return address column: 16 + + DW_CFA_def_cfa: r7 \(rsp\) ofs 8 + DW_CFA_offset: r16 \(rip\) at cfa-8 + DW_CFA_nop + DW_CFA_nop + DW_CFA_nop + DW_CFA_nop + DW_CFA_nop + DW_CFA_nop + +0+0018 0+001c 0+001c FDE cie=0+0000 pc=0+400078..0+400078 + DW_CFA_advance_loc: 0 to 0+400078 + DW_CFA_def_cfa_offset: 16 + DW_CFA_offset: r6 \(rbp\) at cfa-16 + DW_CFA_advance_loc: 0 to 0+400078 + DW_CFA_def_cfa_register: r6 \(rbp\) + +0+0038 ZERO terminator + diff --git a/binutils-2.25/ld/testsuite/ld-elf/eh2a.s b/binutils-2.25/ld/testsuite/ld-elf/eh2a.s new file mode 100644 index 0000000..2c024f8 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/eh2a.s @@ -0,0 +1,3 @@ + .section .eh_frame,"a",%progbits + .align 4 + .zero 4 diff --git a/binutils-2.25/ld/testsuite/ld-elf/eh3.d b/binutils-2.25/ld/testsuite/ld-elf/eh3.d new file mode 100644 index 0000000..2d322dd --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/eh3.d @@ -0,0 +1,34 @@ +#source: eh3.s +#source: eh3a.s +#as: --64 +#ld: -melf_x86_64 -Ttext 0x400078 +#readelf: -wf +#target: x86_64-*-* + +Contents of the .eh_frame section: + +0+0000 0+0014 0+0000 CIE + Version: 1 + Augmentation: "" + Code alignment factor: 1 + Data alignment factor: -8 + Return address column: 16 + + DW_CFA_def_cfa: r7 \(rsp\) ofs 8 + DW_CFA_offset: r16 \(rip\) at cfa-8 + DW_CFA_nop + DW_CFA_nop + DW_CFA_nop + DW_CFA_nop + DW_CFA_nop + DW_CFA_nop + +0+0018 0+001c 0+001c FDE cie=0+0000 pc=0+400078..0+400078 + DW_CFA_advance_loc: 0 to 0+400078 + DW_CFA_def_cfa_offset: 16 + DW_CFA_offset: r6 \(rbp\) at cfa-16 + DW_CFA_advance_loc: 0 to 0+400078 + DW_CFA_def_cfa_register: r6 \(rbp\) + +0+0038 ZERO terminator +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/eh3.s b/binutils-2.25/ld/testsuite/ld-elf/eh3.s new file mode 100644 index 0000000..24bd90d --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/eh3.s @@ -0,0 +1,48 @@ + .text +.globl _start + .type _start, %function +_start: +.LFB2: +.LCFI0: +.LCFI1: +.LFE2: + .size _start, .-_start + .section .eh_frame,"a",%progbits + .align 16 +.Lframe1: + .long .LECIE1-.LSCIE1 +.LSCIE1: + .long 0x0 + .byte 0x1 + .string "" + .uleb128 0x1 + .sleb128 -8 + .byte 0x10 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x90 + .uleb128 0x1 + .align 8 +.LECIE1: +.LSFDE1: + .long .LEFDE1-.LASFDE1 +.LASFDE1: + .long .LASFDE1-.Lframe1 + .quad .LFB2 + .quad .LFE2-.LFB2 + .byte 0x4 + .long .LCFI0-.LFB2 + .byte 0xe + .uleb128 0x10 + .byte 0x86 + .uleb128 0x2 + .byte 0x4 + .long .LCFI1-.LCFI0 + .byte 0xd + .uleb128 0x6 + .byte 0x0 + .byte 0x0 + .byte 0x0 + .byte 0x0 +.LEFDE1: diff --git a/binutils-2.25/ld/testsuite/ld-elf/eh3a.s b/binutils-2.25/ld/testsuite/ld-elf/eh3a.s new file mode 100644 index 0000000..c245871 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/eh3a.s @@ -0,0 +1,3 @@ + .section .eh_frame,"a",%progbits + .align 8 + .zero 8 diff --git a/binutils-2.25/ld/testsuite/ld-elf/eh4.d b/binutils-2.25/ld/testsuite/ld-elf/eh4.d new file mode 100644 index 0000000..b5eec2f --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/eh4.d @@ -0,0 +1,41 @@ +#source: eh4.s +#source: eh4a.s +#as: --64 +#ld: -melf_x86_64 -shared -Ttext 0x400 +#readelf: -wf +#target: x86_64-*-* + +Contents of the .eh_frame section: + +0+0000 0+0014 0+0000 CIE + Version: 1 + Augmentation: "zR" + Code alignment factor: 1 + Data alignment factor: -8 + Return address column: 16 + Augmentation data: 1b + + DW_CFA_def_cfa: r7 \(rsp\) ofs 8 + DW_CFA_offset: r16 \(rip\) at cfa-8 + DW_CFA_nop + DW_CFA_nop + +0+0018 0+0014 0+001c FDE cie=0+0000 pc=0+0400..0+0413 + DW_CFA_set_loc: 0+0404 + DW_CFA_def_cfa_offset: 80 + +0+0030 0+0014 0+0034 FDE cie=0+0000 pc=0+0413..0+0426 + DW_CFA_set_loc: 0+0417 + DW_CFA_def_cfa_offset: 80 + +0+0048 0+0024 0+004c FDE cie=0+0000 pc=[0-9a-f]+\.\.[0-9a-f]+ + DW_CFA_def_cfa_offset: 16 + DW_CFA_advance_loc: [0-9a-f]+ to [0-9a-f]+ + DW_CFA_def_cfa_offset: 24 + DW_CFA_advance_loc: [0-9a-f]+ to [0-9a-f]+ + DW_CFA_def_cfa_expression \(DW_OP_breg7 \(rsp\): 8; DW_OP_breg16 \(rip\): 0;.* + DW_CFA_nop +#... + +[0-9a-f]+ ZERO terminator +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/eh4.s b/binutils-2.25/ld/testsuite/ld-elf/eh4.s new file mode 100644 index 0000000..2714ad6 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/eh4.s @@ -0,0 +1,92 @@ + .text + .align 512 + .globl foo + .type foo, @function +foo: +.LFB1: + subq $72, %rsp +.LCFI1: + xorl %eax, %eax + movq %rsp, %rdi + call bar@PLT + addq $72, %rsp + ret +.LFE1: + .size foo, .-foo + .globl bar + .type bar, @function +bar: +.LFB2: + subq $72, %rsp +.LCFI2: + xorl %eax, %eax + movq %rsp, %rdi + call bar@PLT + addq $72, %rsp + ret +.LFE2: + .size bar, .-bar + .section .eh_frame,"a",@progbits +.Lframe1: + .long .LECIE1-.LSCIE1 # Length of Common Information Entry +.LSCIE1: + .long 0x0 # CIE Identifier Tag + .byte 0x1 # CIE Version + .ascii "zR\0" # CIE Augmentation + .uleb128 0x1 # CIE Code Alignment Factor + .sleb128 -8 # CIE Data Alignment Factor + .byte 0x10 # CIE RA Column + .uleb128 0x1 # Augmentation size + .byte 0x1b # FDE Encoding (pcrel sdata4) + .byte 0xc # DW_CFA_def_cfa + .uleb128 0x7 + .uleb128 0x8 + .byte 0x90 # DW_CFA_offset, column 0x10 + .uleb128 0x1 + .align 8 +.LECIE1: +.LSFDE1: + .long .LEFDE1-.LASFDE1 # FDE Length +.LASFDE1: + .long .LASFDE1-.Lframe1 # FDE CIE offset + .long .LFB1-. # FDE initial location + .long .LFE1-.LFB1 # FDE address range + .uleb128 0x0 # Augmentation size + .byte 0x1 # DW_CFA_set_loc + .long .LCFI1-. + .byte 0xe # DW_CFA_def_cfa_offset + .uleb128 0x50 + .align 8 +.LEFDE1: +.Lframe2: + .long .LECIE2-.LSCIE2 # Length of Common Information Entry +.LSCIE2: + .long 0x0 # CIE Identifier Tag + .byte 0x1 # CIE Version + .ascii "zR\0" # CIE Augmentation + .uleb128 0x1 # CIE Code Alignment Factor + .sleb128 -8 # CIE Data Alignment Factor + .byte 0x10 # CIE RA Column + .uleb128 0x1 # Augmentation size + .byte 0x1b # FDE Encoding (pcrel sdata4) + .byte 0xc # DW_CFA_def_cfa + .uleb128 0x7 + .uleb128 0x8 + .byte 0x90 # DW_CFA_offset, column 0x10 + .uleb128 0x1 + .align 8 +.LECIE2: +.LSFDE2: + .long .LEFDE2-.LASFDE2 # FDE Length +.LASFDE2: + .long .LASFDE2-.Lframe2 # FDE CIE offset + .long .LFB2-. # FDE initial location + .long .LFE2-.LFB2 # FDE address range + .uleb128 0x0 # Augmentation size + .byte 0x1 # DW_CFA_set_loc + .long .LCFI2-. + .byte 0xe # DW_CFA_def_cfa_offset + .uleb128 0x50 + .align 8 +.LEFDE2: + .section .note.GNU-stack,"",@progbits diff --git a/binutils-2.25/ld/testsuite/ld-elf/eh4a.s b/binutils-2.25/ld/testsuite/ld-elf/eh4a.s new file mode 100644 index 0000000..c245871 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/eh4a.s @@ -0,0 +1,3 @@ + .section .eh_frame,"a",%progbits + .align 8 + .zero 8 diff --git a/binutils-2.25/ld/testsuite/ld-elf/eh5.d b/binutils-2.25/ld/testsuite/ld-elf/eh5.d new file mode 100644 index 0000000..9fea117 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/eh5.d @@ -0,0 +1,162 @@ +#source: eh5.s +#source: eh5a.s +#source: eh5b.s +#ld: +#readelf: -wf +#target: cfi +#notarget: alpha* hppa64* tile* + +Contents of the .eh_frame section: + +0+0000 0+001[04] 0+0000 CIE + Version: 1 + Augmentation: "zR" + Code alignment factor: .* + Data alignment factor: .* + Return address column: .* + Augmentation data: (0b|1b) + + DW_CFA_nop + DW_CFA_nop + DW_CFA_nop +#... +0+001[48] 0+0014 0+001[8c] FDE cie=0+0000 pc=.* + DW_CFA_advance_loc: 4 to .* + DW_CFA_def_cfa: r0( \([er]ax\)|) ofs 16 + DW_CFA_nop + DW_CFA_nop + DW_CFA_nop + +0+00(2c|30) 0+0014 0+0000 CIE + Version: 1 + Augmentation: "zPR" + Code alignment factor: .* + Data alignment factor: .* + Return address column: .* + Augmentation data: 03 .. .. .. .. (0b|1b) + + DW_CFA_nop + +0+004[48] 0+0014 0+001c FDE cie=0+00(2c|30) pc=.* + DW_CFA_advance_loc: 4 to .* + DW_CFA_def_cfa: r0( \([er]ax\)|) ofs 16 + DW_CFA_nop + DW_CFA_nop + DW_CFA_nop + +0+00(5c|60) 0+0014 0+006[04] FDE cie=0+0000 pc=.* + DW_CFA_advance_loc: 4 to .* + DW_CFA_def_cfa: r0( \([er]ax\)|) ofs 16 + DW_CFA_nop + DW_CFA_nop + DW_CFA_nop + +0+007[48] 0+001[8c] 0+0000 CIE + Version: 1 + Augmentation: "zPLR" + Code alignment factor: .* + Data alignment factor: .* + Return address column: .* + Augmentation data: 03 .. .. .. .. 0c (0b|1b) + + DW_CFA_nop + DW_CFA_nop + DW_CFA_nop +#... +0+009[08] 0+001c 0+002[04] FDE cie=0+007[48] pc=.* + Augmentation data: (ef be ad de 00 00 00 00|00 00 00 00 de ad be ef) + + DW_CFA_advance_loc: 4 to .* + DW_CFA_def_cfa: r0( \([er]ax\)|) ofs 16 + DW_CFA_nop + DW_CFA_nop + DW_CFA_nop + +0+00b[08] 0+001[04] 0+0000 CIE + Version: 1 + Augmentation: "zR" + Code alignment factor: .* + Data alignment factor: .* + Return address column: .* + Augmentation data: (0b|1b) + + DW_CFA_def_cfa: r0( \([er]ax\)|) ofs 16 +#... +0+00(c4|d0) 0+001[04] 0+001[8c] FDE cie=0+00b[08] pc=.* + DW_CFA_nop + DW_CFA_nop + DW_CFA_nop +#... +0+00[de]8 0+0014 0+0000 CIE + Version: 1 + Augmentation: "zPR" + Code alignment factor: .* + Data alignment factor: .* + Return address column: .* + Augmentation data: 03 .. .. .. .. (0b|1b) + + DW_CFA_nop + +0+0(0f|10)0 0+0014 0+001c FDE cie=0+00[de]8 pc=.* + DW_CFA_advance_loc: 4 to .* + DW_CFA_def_cfa: r0( \([er]ax\)|) ofs 16 + DW_CFA_nop + DW_CFA_nop + DW_CFA_nop + +0+01[01]8 0+001[04] 0+00(5c|64) FDE cie=0+00b[08] pc=.* + DW_CFA_nop + DW_CFA_nop + DW_CFA_nop +#... +0+01(1c|30) 0+001[8c] 0+0000 CIE + Version: 1 + Augmentation: "zPLR" + Code alignment factor: .* + Data alignment factor: .* + Return address column: .* + Augmentation data: 03 .. .. .. .. 0c (0b|1b) + + DW_CFA_nop + DW_CFA_nop + DW_CFA_nop +#... +0+01(38|50) 0+001c 0+002[04] FDE cie=0+01(1c|30) pc=.* + Augmentation data: (ef be ad de 00 00 00 00|00 00 00 00 de ad be ef) + + DW_CFA_advance_loc: 4 to .* + DW_CFA_def_cfa: r0( \([er]ax\)|) ofs 16 + DW_CFA_nop + DW_CFA_nop + DW_CFA_nop + +0+01(58|70) 0+0014 0+01(5c|74) FDE cie=0+0000 pc=.* + DW_CFA_advance_loc: 4 to .* + DW_CFA_def_cfa: r0( \([er]ax\)|) ofs 16 + DW_CFA_nop + DW_CFA_nop + DW_CFA_nop +#... +0+01(70|88) 0+0014 0+0(01c|148|15c) FDE cie=0+0(02c|030|170) pc=.* + DW_CFA_advance_loc: 4 to .* + DW_CFA_def_cfa: r0( \([er]ax\)|) ofs 16 + DW_CFA_nop + DW_CFA_nop + DW_CFA_nop + +0+01(88|a0) 0+0014 0+01(8c|a4) FDE cie=0+0000 pc=.* + DW_CFA_advance_loc: 4 to .* + DW_CFA_def_cfa: r0( \([er]ax\)|) ofs 16 + DW_CFA_nop + DW_CFA_nop + DW_CFA_nop +#... +0+01(a0|b8|d4) 0+001c 0+0(020|130|144) FDE cie=0+0(074|078|1b8) pc=.* + Augmentation data: (ef be ad de 00 00 00 00|00 00 00 00 de ad be ef) + + DW_CFA_advance_loc: 4 to .* + DW_CFA_def_cfa: r0( \([er]ax\)|) ofs 16 + DW_CFA_nop + DW_CFA_nop + DW_CFA_nop + diff --git a/binutils-2.25/ld/testsuite/ld-elf/eh5.s b/binutils-2.25/ld/testsuite/ld-elf/eh5.s new file mode 100644 index 0000000..6af48c2 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/eh5.s @@ -0,0 +1,29 @@ + .text + .cfi_startproc simple + .long 0 + .cfi_def_cfa 0, 16 + .long 0 + .cfi_endproc + + .cfi_startproc simple + .cfi_personality 3, my_personality_v0 + .long 0 + .cfi_def_cfa 0, 16 + .cfi_endproc + + .cfi_startproc simple + .long 0 + .cfi_def_cfa 0, 16 + .long 0 + .cfi_endproc + + .cfi_startproc simple + .cfi_personality 3, my_personality_v0 + .cfi_lsda 12, 0xdeadbeef + .long 0 + .cfi_def_cfa 0, 16 + .cfi_endproc + + .globl my_personality_v0 +my_personality_v0: + .long 0 diff --git a/binutils-2.25/ld/testsuite/ld-elf/eh5a.s b/binutils-2.25/ld/testsuite/ld-elf/eh5a.s new file mode 100644 index 0000000..a74b2cc --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/eh5a.s @@ -0,0 +1,27 @@ + .text + .cfi_startproc simple + .cfi_def_cfa 0, 16 + .long 0 + .cfi_endproc + + .cfi_startproc simple + .cfi_personality 3, my_personality_v1 + .long 0 + .cfi_def_cfa 0, 16 + .cfi_endproc + + .cfi_startproc simple + .cfi_def_cfa 0, 16 + .long 0 + .cfi_endproc + + .cfi_startproc simple + .cfi_personality 3, my_personality_v1 + .cfi_lsda 12, 0xdeadbeef + .long 0 + .cfi_def_cfa 0, 16 + .cfi_endproc + + .globl my_personality_v1 +my_personality_v1: + .long 0 diff --git a/binutils-2.25/ld/testsuite/ld-elf/eh5b.s b/binutils-2.25/ld/testsuite/ld-elf/eh5b.s new file mode 100644 index 0000000..fa27edd --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/eh5b.s @@ -0,0 +1,35 @@ + .text + .cfi_startproc simple + .long 0 + .cfi_def_cfa 0, 16 + .long 0 + .cfi_endproc + + .cfi_startproc simple + .cfi_personality 3, my_personality_v0 + .long 0 + .cfi_def_cfa 0, 16 + .cfi_endproc + + .cfi_startproc simple + .long 0 + .cfi_def_cfa 0, 16 + .long 0 + .cfi_endproc + + .cfi_startproc simple + .cfi_personality 3, my_personality_v0 + .cfi_lsda 12, 0xdeadbeef + .long 0 + .cfi_def_cfa 0, 16 + .cfi_endproc + + .globl main + .globl start + .globl _start + .globl __start +main: +start: +_start: +__start: + .long 0 diff --git a/binutils-2.25/ld/testsuite/ld-elf/eh6.d b/binutils-2.25/ld/testsuite/ld-elf/eh6.d new file mode 100644 index 0000000..7812af2 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/eh6.d @@ -0,0 +1,17 @@ +#source: eh6.s +#ld: --gc-sections -shared +#readelf: -wf +#target: x86_64-*-linux-gnu* i?86-*-linux-gnu i?86-*-gnu* + +Contents of the .eh_frame section: + +0+0000 0+001[4c] 0+0000 CIE + Version: 1 + Augmentation: "zPR" + Code alignment factor: 1 + Data alignment factor: .* + Return address column: .* + Augmentation data: 9[bc] .* 1b + + DW_CFA_nop +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/eh6.s b/binutils-2.25/ld/testsuite/ld-elf/eh6.s new file mode 100644 index 0000000..bdc7dd1 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/eh6.s @@ -0,0 +1,17 @@ + .section .text.foo, "ax", @progbits + .globl foo + .type foo, @function +foo: + .cfi_startproc simple + .cfi_personality 0x80, indirect_ptr + ret + .cfi_endproc + .size foo, . - foo + + .section .data.rel.ro, "a", @progbits +indirect_ptr: + .long my_personality_v0 + + .globl my_personality_v0 +my_personality_v0: + .long 0 diff --git a/binutils-2.25/ld/testsuite/ld-elf/ehdr_start.d b/binutils-2.25/ld/testsuite/ld-elf/ehdr_start.d new file mode 100644 index 0000000..52e5b54 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/ehdr_start.d @@ -0,0 +1,8 @@ +#source: ehdr_start.s +#ld: -e _start +#nm: -n +#target: *-*-linux* *-*-gnu* *-*-nacl* + +#... +[0-9a-f]*000 [Adrt] __ehdr_start +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/ehdr_start.s b/binutils-2.25/ld/testsuite/ld-elf/ehdr_start.s new file mode 100644 index 0000000..2efe8a6 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/ehdr_start.s @@ -0,0 +1,10 @@ + .text + .globl _start +_start: + .space 16 + + .section .rodata,"a" + .globl foo +foo: + .weak __ehdr_start + .dc.a __ehdr_start diff --git a/binutils-2.25/ld/testsuite/ld-elf/elf.exp b/binutils-2.25/ld/testsuite/ld-elf/elf.exp new file mode 100644 index 0000000..236e15b --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/elf.exp @@ -0,0 +1,193 @@ +# Expect script for various ELF tests. +# Copyright 2002, 2003, 2005, 2007, 2009, 2010, 2011, 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. +# + +# Exclude non-ELF targets. + +if ![is_elf_format] { + return +} + +set old_ldflags $LDFLAGS +if { [istarget spu*-*-*] } { + set LDFLAGS "$LDFLAGS --local-store 0:0" +} +if { [istarget alpha*-*-* ] } { + # The compress1 test is written expecting 32-bit addresses; force the + # executable down into the low address space to match. + # ??? How can we adjust just the one testcase? + set LDFLAGS "$LDFLAGS -Ttext-segment 0x1000000" +} + +if { [istarget "*-*-nacl*"] } { + # The eh[1-4] cases are written to expect ELFCLASS64 layout on x86-64. + # But the target default is ELFCLASS32. So the cases explicitly use + # -melf_x86_64 to select that, but NaCl needs a different emulation name. + set options_regsub(ld) {-melf_x86_64 -melf_x86_64_nacl} +} + +if { [istarget "*-*-solaris*"] } { + # Same for Solaris + set options_regsub(ld) {-melf_x86_64 -melf_x86_64_sol2} +} + +if { [is_remote host] } then { + remote_download host merge.ld +} + +if { ![istarget hppa64*-hpux*] } { + run_ld_link_tests { + {"Build symbol3.a" + "" "" "" + {symbol3.s} {} "symbol3.a"} + {"Build symbol3w.a" + "" "" "" + {symbol3w.s} {} "symbol3w.a"} + } + + if { [check_shared_lib_support] } then { + run_ld_link_tests { + {"Build pr14170a.o" "" "" "" "pr14170a.s" {} "pr14170.a" } + } + setup_xfail "tic6x-*-*" + run_ld_link_tests { + {"Build shared library for pr14170" + "-shared" "" "" "pr14170b.s" {} "pr14170.so" } + {"PR ld/14170" + "tmpdir/pr14170a.o tmpdir/pr14170.so" "" "" "pr14170c.s" + { } "pr14170" } + } + } +} + +# Run a test to check linking a shared library with a broken linker +# script that accidentally marks dynamic sections as notes. The +# resulting executable is not expected to work, but the linker +# should not seg-fault whilst creating the binary. +# +# Only run the test on targets thats support creating shared libraries. +if { [check_shared_lib_support] } then { + setup_xfail "tic6x-*-*" + run_ld_link_tests { + {"Build shared library for next test" + "-shared" "" "" "note-3.s" {} "note-3.so" } + {"Link using broken linker script" + "--script note-3.t tmpdir/note-3.so" "" "" "" + { { ld "note-3.l" } } + "a.out" } + } +} + +set test_list [lsort [glob -nocomplain $srcdir/$subdir/*.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] +} + +if { [istarget *-*-linux*] + || [istarget *-*-nacl*] + || [istarget *-*-gnu*] } { + run_ld_link_tests { + {"Weak symbols in dynamic objects 1 (support)" + "-shared" "" "" {weak-dyn-1a.s} + {} + "libweakdyn1a.so"} + {"Weak symbols in dynamic objects 1 (main test)" + "-shared tmpdir/libweakdyn1a.so -Tweak-dyn-1.ld" "" "" {weak-dyn-1b.s} + {{readelf {--relocs --wide} weak-dyn-1.rd}} + "libweakdyn1b.so"} + } +} + +#v850 gas complains about .tbss.var section attributes. +if { [check_gc_sections_available] && ![istarget "v850-*-*"] } { + run_ld_link_tests { + {"--gc-sections on tls variable" + "--gc-section" "" "" {tls_gc.s} {} "tls_gc"} + } +} + +if { [istarget *-*-*linux*] + || [istarget *-*-nacl*] + || [istarget *-*-gnu*] } { + run_ld_link_tests { + {"stack exec" "-z execstack" "" "" {stack.s} + {{readelf {-Wl} stack-exec.rd}} "stack-exec.exe"} + {"stack size" "-z stack-size=0x123400" "" "" {stack.s} + {{readelf {-Wl} stack-size.rd}} "stack-size.exe"} + } +} + +set LDFLAGS $old_ldflags + +# The following tests require running the executable generated by ld. +if ![isnative] { + return +} + +if [check_gc_sections_available] { + run_cc_link_tests { + {"PR ld/13195" "-Wl,--gc-sections" "" + {pr13195.c} {} "pr13195"} + } +} + +set array_tests { + {"preinit array" "" "" {preinit.c} "preinit" "preinit.out"} + {"init array" "" "" {init.c} "init" "init.out"} + {"fini array" "" "" {fini.c} "fini" "fini.out"} + {"init array mixed" "" "" {init-mixed.c} "init-mixed" "init-mixed.out" "-I."} +} +set array_tests_pie { + {"PIE preinit array" "-pie" "" {preinit.c} "preinit" "preinit.out" "-fPIE" } + {"PIE init array" "-pie" "" {init.c} "init" "init.out" "-fPIE"} + {"PIE fini array" "-pie" "" {fini.c} "fini" "fini.out" "-fPIE"} + {"PIE init array mixed" "-pie" "" {init-mixed.c} "init-mixed" "init-mixed.out" "-I. -fPIE"} + {"PIE PR ld/14525" "-pie" "" {pr14525.c} "pr14525" "pr14525.out" "-fPIE"} +} +set array_tests_static { + {"static preinit array" "-static" "" {preinit.c} "preinit" "preinit.out"} + {"static init array" "-static" "" {init.c} "init" "init.out"} + {"static fini array" "-static" "" {fini.c} "fini" "fini.out"} + {"static init array mixed" "-static" "" {init-mixed.c} "init-mixed" "init-mixed.out" "-I."} +} + +# NetBSD ELF systems do not currently support the .*_array sections. +set xfails [list "*-*-netbsdelf*"] +run_ld_link_exec_tests $xfails $array_tests + +if { [istarget *-*-linux*] + || [istarget *-*-nacl*] + || [istarget *-*-gnu*] } { + run_ld_link_exec_tests $xfails $array_tests_pie +} + +# Be cautious to not XFAIL for *-*-linux-gnu*, *-*-kfreebsd-gnu*, etc. +switch -regexp $target_triplet { + ^\[^-\]*-\[^-\]*-gnu.*$ { + # <http://www.gnu.org/software/hurd/open_issues/binutils.html#static> + lappend xfails "*-*-*" + } +} +run_ld_link_exec_tests $xfails $array_tests_static + +catch "exec rm -f tmpdir/preinit tmpdir/init tmpdir/fini tmpdir/init-mixed" status diff --git a/binutils-2.25/ld/testsuite/ld-elf/empty.d b/binutils-2.25/ld/testsuite/ld-elf/empty.d new file mode 100644 index 0000000..836206e --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/empty.d @@ -0,0 +1,7 @@ +#source: empty.s +#ld: +#readelf: -s + +#... + +[0-9]+: +[0-9a-f]+ +[0-9]+ +FUNC +GLOBAL +DEFAULT +[1-9] _start +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/empty.s b/binutils-2.25/ld/testsuite/ld-elf/empty.s new file mode 100644 index 0000000..8c2d0e6 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/empty.s @@ -0,0 +1,16 @@ + .section .bss +bar: + .text + .type start,"function" + .global start +start: + .type _start,"function" + .global _start +_start: + .type __start,"function" + .global __start +__start: + .type main,"function" + .global main +main: + .long 0 diff --git a/binutils-2.25/ld/testsuite/ld-elf/empty2.d b/binutils-2.25/ld/testsuite/ld-elf/empty2.d new file mode 100644 index 0000000..d91569e --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/empty2.d @@ -0,0 +1,11 @@ +#source: empty2.s +#ld: +#readelf: -s + +#... +[ ]+[0-9]+:[ ]+0+[ ]+0[ ]+FILE[ ]+LOCAL[ ]+DEFAULT[ ]+ABS empty2.s +#... +[ ]+[0-9]+:[ ]+0*12345678[ ]+0[ ]+NOTYPE[ ]+LOCAL[ ]+DEFAULT[ ]+ABS constant +#... +[ ]+[0-9]+:[ ]+[0-9a-f]+[ ]+[0-9]+[ ]+FUNC[ ]+GLOBAL[ ]+DEFAULT[ ]+[1-9] _start +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/empty2.s b/binutils-2.25/ld/testsuite/ld-elf/empty2.s new file mode 100644 index 0000000..deed318 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/empty2.s @@ -0,0 +1,18 @@ + .file "empty2.s" + .equiv constant, 0x12345678 + .section .bss +bar: + .text + .type start,"function" + .global start +start: + .type _start,"function" + .global _start +_start: + .type __start,"function" + .global __start +__start: + .type main,"function" + .global main +main: + .long constant diff --git a/binutils-2.25/ld/testsuite/ld-elf/end.c b/binutils-2.25/ld/testsuite/ld-elf/end.c new file mode 100644 index 0000000..f7b681a --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/end.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +void +foo () +{ + printf ("TEST1\n"); +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/endhidden.c b/binutils-2.25/ld/testsuite/ld-elf/endhidden.c new file mode 100644 index 0000000..2cab97a --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/endhidden.c @@ -0,0 +1,8 @@ +#include <stdio.h> + +__attribute__ ((visibility ("hidden"))) +void +foo () +{ + printf ("TEST1\n"); +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/endprotected.c b/binutils-2.25/ld/testsuite/ld-elf/endprotected.c new file mode 100644 index 0000000..b6b39ea --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/endprotected.c @@ -0,0 +1,8 @@ +#include <stdio.h> + +__attribute__ ((visibility ("protected"))) +void +foo () +{ + printf ("TEST1\n"); +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/exclude.exp b/binutils-2.25/ld/testsuite/ld-elf/exclude.exp new file mode 100644 index 0000000..28a34ab --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/exclude.exp @@ -0,0 +1,148 @@ +# Expect script for --exclude-libs tests +# Copyright 2004, 2005, 2007 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. + +# Make sure that ld can hide symbols from libraries when building a shared +# library. + +# This test can only be run on ELF platforms. +if ![is_elf_format] { + return +} + +# No shared lib support on this target. +if { [istarget "mcore-*-*"] } { + return +} + +set as_opt "" + +# This target requires extra as options when building code for shared +# libraries. +if { [istarget "tic6x-*-*"] } { + set as_opt "-mpic -mpid=near" +} + +global ar +global as +global ld +global nm +global nm_output + +set test1 "ld link shared library" +set test2 "ld export symbols from archive" +set test3 "ld link shared library with --exclude-libs" +set test4 "ld exclude symbols from archive - --exclude-libs libexclude" +set test5 "ld exclude symbols from archive - --exclude-libs libexclude.a" +set test6 "ld exclude symbols from archive - --exclude-libs ALL" +set test7 "ld exclude symbols from archive - --exclude-libs foo:libexclude.a" +set test8 "ld exclude symbols from archive - --exclude-libs foo,libexclude.a" +set test9 "ld don't exclude symbols from archive - --exclude-libs foo:bar" + +if { ![ld_assemble_flags $as $as_opt $srcdir/$subdir/exclude1.s tmpdir/exclude1.o ] + || ![ld_assemble_flags $as $as_opt $srcdir/$subdir/exclude2.s tmpdir/exclude2.o] } { + unresolved $test1 + return +} + +remote_file host delete "tmpdir/libexclude.a" +set catch_output [run_host_cmd "$ar" "cq tmpdir/libexclude.a tmpdir/exclude2.o"] +if {![string match "" $catch_output]} { + unresolved $test1 + return +} + +# Test that the symbol is normally exported. + +if { [ld_simple_link $ld tmpdir/exclude.so "--shared tmpdir/exclude1.o -Ltmpdir -lexclude"] } { + pass $test1 +} else { + if [string match "*shared not supported*" $link_output] { + unsupported "$test1 - -shared is not supported by this target" + } else { + fail $test1 + } + return +} + +if ![ld_nm $nm "-D" tmpdir/exclude.so] { + unresolved $test2 +} elseif { [info exists nm_output(exclude_sym)] } { + pass $test2 +} else { + fail $test2 +} + +# Test --exclude-libs libexclude + +if { [ld_simple_link $ld tmpdir/exclude.so "--exclude-libs libexclude --shared tmpdir/exclude1.o -Ltmpdir -lexclude"] } { + pass $test3 +} else { + fail $test3 +} + +if ![ld_nm $nm "-D" tmpdir/exclude.so] { + unresolved $test4 +} elseif { ! [info exists nm_output(exclude_sym)] } { + pass $test4 +} else { + fail $test4 +} + +# Test alternate spellings of --exclude-libs + +if { [ld_simple_link $ld tmpdir/exclude.so "--exclude-libs libexclude.a --shared tmpdir/exclude1.o -Ltmpdir -lexclude"] + && [ld_nm $nm "-D" tmpdir/exclude.so] + && ! [info exists nm_output(exclude_sym)] } { + pass $test5 +} else { + fail $test5 +} + +if { [ld_simple_link $ld tmpdir/exclude.so "--exclude-libs ALL --shared tmpdir/exclude1.o -Ltmpdir -lexclude"] + && [ld_nm $nm "-D" tmpdir/exclude.so] + && ! [info exists nm_output(exclude_sym)] } { + pass $test6 +} else { + fail $test6 +} + +if { [ld_simple_link $ld tmpdir/exclude.so "--exclude-libs foo:libexclude.a --shared tmpdir/exclude1.o -Ltmpdir -lexclude"] + && [ld_nm $nm "-D" tmpdir/exclude.so] + && ! [info exists nm_output(exclude_sym)] } { + pass $test7 +} else { + fail $test7 +} + +if { [ld_simple_link $ld tmpdir/exclude.so "--exclude-libs foo,libexclude.a --shared tmpdir/exclude1.o -Ltmpdir -lexclude"] + && [ld_nm $nm "-D" tmpdir/exclude.so] + && ! [info exists nm_output(exclude_sym)] } { + pass $test8 +} else { + fail $test8 +} + +if { [ld_simple_link $ld tmpdir/exclude.so "--exclude-libs foo:bar --shared tmpdir/exclude1.o -Ltmpdir -lexclude"] + && [ld_nm $nm "-D" tmpdir/exclude.so] + && [info exists nm_output(exclude_sym)] } { + pass $test9 +} else { + fail $test9 +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/exclude1.s b/binutils-2.25/ld/testsuite/ld-elf/exclude1.s new file mode 100644 index 0000000..99efc7e --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/exclude1.s @@ -0,0 +1,4 @@ + .globl include_sym + .data +include_sym: + .dc.a exclude_sym diff --git a/binutils-2.25/ld/testsuite/ld-elf/exclude2.s b/binutils-2.25/ld/testsuite/ld-elf/exclude2.s new file mode 100644 index 0000000..e9b5819 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/exclude2.s @@ -0,0 +1,4 @@ + .globl exclude_sym + .data +exclude_sym: + .long 0 diff --git a/binutils-2.25/ld/testsuite/ld-elf/exclude3.s b/binutils-2.25/ld/testsuite/ld-elf/exclude3.s new file mode 100644 index 0000000..475088f --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/exclude3.s @@ -0,0 +1,16 @@ + .text + .type start,"function" + .global start +start: + .type _start,"function" + .global _start +_start: + .type __start,"function" + .global __start +__start: + .type main,"function" + .global main +main: + .long 0 + .section .foo1,"e", %progbits + .byte 0,0,0,0 diff --git a/binutils-2.25/ld/testsuite/ld-elf/exclude3a.d b/binutils-2.25/ld/testsuite/ld-elf/exclude3a.d new file mode 100644 index 0000000..2647cce --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/exclude3a.d @@ -0,0 +1,8 @@ +#source: exclude3.s +#ld: +#readelf: -S --wide + +#failif +#... +[ ]*\[.*\][ ]+\.foo1[ ]+.* +#... diff --git a/binutils-2.25/ld/testsuite/ld-elf/exclude3b.d b/binutils-2.25/ld/testsuite/ld-elf/exclude3b.d new file mode 100644 index 0000000..553c30b --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/exclude3b.d @@ -0,0 +1,9 @@ +#source: exclude3.s +#ld: --shared +#readelf: -S --wide +#target: *-*-linux* *-*-gnu* + +#failif +#... +[ ]*\[.*\][ ]+\.foo1[ ]+.* +#... diff --git a/binutils-2.25/ld/testsuite/ld-elf/exclude3c.d b/binutils-2.25/ld/testsuite/ld-elf/exclude3c.d new file mode 100644 index 0000000..57311c8 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/exclude3c.d @@ -0,0 +1,7 @@ +#source: exclude3.s +#ld: -r +#readelf: -S --wide + +#... +[ ]*\[.*\][ ]+\.foo1[ ]+PROGBITS.*[ ]+E[ ]+.* +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/export-class-def.s b/binutils-2.25/ld/testsuite/ld-elf/export-class-def.s new file mode 100644 index 0000000..90f908f --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/export-class-def.s @@ -0,0 +1,25 @@ + .data + .balign 32 + .xdef protected_bar + .protected protected_bar +protected_bar: + .balign 32 + .xdef protected_foo + .protected protected_foo +protected_foo: + .balign 32 + .xdef hidden_bar + .hidden hidden_bar +hidden_bar: + .balign 32 + .xdef hidden_foo + .hidden hidden_foo +hidden_foo: + .balign 32 + .xdef internal_bar + .internal internal_bar +internal_bar: + .balign 32 + .xdef internal_foo + .internal internal_foo +internal_foo: diff --git a/binutils-2.25/ld/testsuite/ld-elf/export-class-dep.s b/binutils-2.25/ld/testsuite/ld-elf/export-class-dep.s new file mode 100644 index 0000000..e987898 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/export-class-dep.s @@ -0,0 +1,25 @@ + .data + .balign 16 + .dc.a protected_foo + .balign 16 + .dc.a protected_bar + .balign 16 + .dc.a hidden_foo + .balign 16 + .dc.a hidden_bar + .balign 16 + .dc.a internal_foo + .balign 16 + .dc.a internal_bar + .balign 32 + .xdef protected_baz + .protected protected_baz +protected_baz: + .balign 32 + .xdef hidden_baz + .hidden hidden_baz +hidden_baz: + .balign 32 + .xdef internal_baz + .internal internal_baz +internal_baz: diff --git a/binutils-2.25/ld/testsuite/ld-elf/export-class-lib.s b/binutils-2.25/ld/testsuite/ld-elf/export-class-lib.s new file mode 100644 index 0000000..b3f3f05 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/export-class-lib.s @@ -0,0 +1,10 @@ + .data + .balign 16 + .xdef protected_foo +protected_foo: + .balign 16 + .xdef hidden_foo +hidden_foo: + .balign 16 + .xdef internal_foo +internal_foo: diff --git a/binutils-2.25/ld/testsuite/ld-elf/export-class-lib.ver b/binutils-2.25/ld/testsuite/ld-elf/export-class-lib.ver new file mode 100644 index 0000000..a9dbfdc --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/export-class-lib.ver @@ -0,0 +1 @@ +GCC_3.0 { global: *_foo; }; diff --git a/binutils-2.25/ld/testsuite/ld-elf/export-class-ref.s b/binutils-2.25/ld/testsuite/ld-elf/export-class-ref.s new file mode 100644 index 0000000..4e45c02 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/export-class-ref.s @@ -0,0 +1,7 @@ + .data + .balign 16 + .dc.a protected_baz + .balign 16 + .dc.a hidden_baz + .balign 16 + .dc.a internal_baz diff --git a/binutils-2.25/ld/testsuite/ld-elf/export-class.exp b/binutils-2.25/ld/testsuite/ld-elf/export-class.exp new file mode 100644 index 0000000..38c635c --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/export-class.exp @@ -0,0 +1,87 @@ +# Expect script for symbol export classes. +# +# Copyright 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 Maciej W. Rozycki <macro@codesourcery.com> +# + +# Exclude non-ELF targets. +if { ![is_elf_format] } { + return +} + +# Exclude some more targets; feel free to include your favorite one +# if you like. +if { ![istarget *-*-linux*] + && ![istarget *-*-nacl*] + && ![istarget *-*-gnu*] } { + return +} + +set testname "Symbol export class test" + +# Build an auxiliary shared object with conflicting versioned symbol +# definitions. +run_ld_link_tests [list \ + [list \ + "$testname (auxiliary shared object)" \ + "-shared -version-script export-class-lib.ver" "" \ + "" \ + { export-class-lib.s } \ + {} \ + "export-class-lib.so" \ + ] \ +] + +# Build a static object that pulls symbol definitions. It has to come +# first before the auxiliary shared object and other static objects on +# the linker's command line and hence we need to build it separately. +run_ld_link_tests [list \ + [list \ + "$testname (initial static object)" \ + "-r" "" \ + "" \ + { export-class-ref.s } \ + {} \ + "export-class-ref-r.o" \ + ] \ +] + +# Build static objects that satisfy symbol dependencies and preempt +# shared-object symbol definitions, and link all the objects built into +# the final shared object. The command-line order of objects linked is +# important to make sure the linker correctly preempts versioned symbols +# from the auxiliary shared object and is as follows: ref, lib, dep, def. +# Get a dump to make sure symbol dependencies are resolved internally. +run_ld_link_tests [list \ + [list \ + "$testname (final shared object)" \ + "-shared -Tdata=0x12340000 tmpdir/export-class-ref-r.o tmpdir/export-class-lib.so" "" \ + "" \ + { export-class-dep.s export-class-def.s } \ + { \ + { readelf -s export-class.sd } \ + { readelf -V export-class.vd } \ + } \ + "export-class.so" \ + ] \ +] diff --git a/binutils-2.25/ld/testsuite/ld-elf/export-class.sd b/binutils-2.25/ld/testsuite/ld-elf/export-class.sd new file mode 100644 index 0000000..bd5c549 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/export-class.sd @@ -0,0 +1,32 @@ +Symbol table '\.dynsym' contains [0-9]+ entries: + * Num: * Value * Size * Type * Bind * Vis * Ndx * Name +#... + * [0-9a-f]+: * 0*123400a0 * 0 * NOTYPE * GLOBAL * PROTECTED * [0-9]+ * protected_foo +#... + * [0-9a-f]+: * 0*123400a0 * 0 * NOTYPE * GLOBAL * PROTECTED * [0-9]+ * protected_bar +#... + * [0-9a-f]+: * 0*123400a0 * 0 * NOTYPE * GLOBAL * PROTECTED * [0-9]+ * protected_baz +#... +Symbol table '\.symtab' contains [0-9]+ entries: + * Num: * Value * Size * Type * Bind * Vis * Ndx * Name +#... + * [0-9a-f]+: * 0*12340000 * 0 * SECTION * LOCAL * DEFAULT * [0-9]+ * +#... + * [0-9a-f]+: * 0*123400a0 * 0 * NOTYPE * LOCAL * DEFAULT * [0-9]+ * hidden_foo +#... + * [0-9a-f]+: * 0*123400a0 * 0 * NOTYPE * LOCAL * DEFAULT * [0-9]+ * internal_baz +#... + * [0-9a-f]+: * 0*123400a0 * 0 * NOTYPE * LOCAL * DEFAULT * [0-9]+ * internal_bar +#... + * [0-9a-f]+: * 0*123400a0 * 0 * NOTYPE * LOCAL * DEFAULT * [0-9]+ * internal_foo +#... + * [0-9a-f]+: * 0*123400a0 * 0 * NOTYPE * LOCAL * DEFAULT * [0-9]+ * hidden_bar +#... + * [0-9a-f]+: * 0*123400a0 * 0 * NOTYPE * LOCAL * DEFAULT * [0-9]+ * hidden_baz +#... + * [0-9a-f]+: * 0*123400a0 * 0 * NOTYPE * GLOBAL * PROTECTED * [0-9]+ * protected_foo +#... + * [0-9a-f]+: * 0*123400a0 * 0 * NOTYPE * GLOBAL * PROTECTED * [0-9]+ * protected_bar +#... + * [0-9a-f]+: * 0*123400a0 * 0 * NOTYPE * GLOBAL * PROTECTED * [0-9]+ * protected_baz +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/export-class.vd b/binutils-2.25/ld/testsuite/ld-elf/export-class.vd new file mode 100644 index 0000000..1a87494 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/export-class.vd @@ -0,0 +1 @@ +No version information found in this file\. diff --git a/binutils-2.25/ld/testsuite/ld-elf/expr1.d b/binutils-2.25/ld/testsuite/ld-elf/expr1.d new file mode 100644 index 0000000..7bf5d22 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/expr1.d @@ -0,0 +1,2 @@ +# ld: -T expr1.t +# error: expr1.t:3: nonconstant expression for load base diff --git a/binutils-2.25/ld/testsuite/ld-elf/expr1.s b/binutils-2.25/ld/testsuite/ld-elf/expr1.s new file mode 100644 index 0000000..998bbc0 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/expr1.s @@ -0,0 +1,4 @@ + .section .bar,"ax","progbits" + .byte 0 + .section .foo,"aw","progbits" + .byte 0 diff --git a/binutils-2.25/ld/testsuite/ld-elf/expr1.t b/binutils-2.25/ld/testsuite/ld-elf/expr1.t new file mode 100644 index 0000000..9670e25 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/expr1.t @@ -0,0 +1,6 @@ +SECTIONS +{ + .bar : AT ((ADDR(.foo) + 4095) & ~(4095)) { *(.bar) } + .foo : { *(.foo) } + /DISCARD/ : { *(.*) } +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/extract-symbol-1.ld b/binutils-2.25/ld/testsuite/ld-elf/extract-symbol-1.ld new file mode 100644 index 0000000..53e95c6 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/extract-symbol-1.ld @@ -0,0 +1,18 @@ +ENTRY(_entry) +PHDRS +{ + data PT_LOAD AT (0); +} +SECTIONS +{ + . = 0x10000; + .foo : { *(.foo) } :data + + . = 0x20000; + .bar : { *(.bar) } :data + + /DISCARD/ : { *(*) } + + _entry = 0x30000; + linker_symbol = 0x40000; +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/extract-symbol-1.s b/binutils-2.25/ld/testsuite/ld-elf/extract-symbol-1.s new file mode 100644 index 0000000..0971500 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/extract-symbol-1.s @@ -0,0 +1,15 @@ + .globl B + .globl C + + .section .foo,"awx",%progbits + .4byte 1,2,3,4 +B: + .4byte 5,6,7 + + .section .bar,"ax",%nobits + .space 0x123 +C: + .space 0x302 + + .globl D + .equ D,0x12345678 diff --git a/binutils-2.25/ld/testsuite/ld-elf/extract-symbol-1sec.d b/binutils-2.25/ld/testsuite/ld-elf/extract-symbol-1sec.d new file mode 100644 index 0000000..57a5662 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/extract-symbol-1sec.d @@ -0,0 +1,14 @@ +#name: --extract-symbol test 1 (sections) +#source: extract-symbol-1.s +#ld: -Textract-symbol-1.ld +#objcopy_linked_file: --extract-symbol +#objdump: --headers +#xfail: "hppa*-*-*" "rx-*-*" +# FAILS on the RX because the linker has to set LMA == VMA for the Renesas loader. +#... +Sections: + *Idx +Name +Size +VMA +LMA .* + *0 +\.foo +0+ +0+10000 +0+10000 .* + *CONTENTS, ALLOC, LOAD, CODE + *1 +\.bar +0+ +0+20000 +0+10000 .* + *ALLOC, READONLY, CODE diff --git a/binutils-2.25/ld/testsuite/ld-elf/extract-symbol-1sym.d b/binutils-2.25/ld/testsuite/ld-elf/extract-symbol-1sym.d new file mode 100644 index 0000000..4069191 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/extract-symbol-1sym.d @@ -0,0 +1,17 @@ +#name: --extract-symbol test 1 (symbols) +#source: extract-symbol-1.s +#ld: -Textract-symbol-1.ld +#objcopy_linked_file: --extract-symbol +#nm: -n +#xfail: "hppa*-*-*" +#... +0*00010010 T B +#... +0*00020123 T C +#... +0*00030000 A _entry +#... +0*00040000 A linker_symbol +#... +0*12345678 A D +#pass
\ No newline at end of file diff --git a/binutils-2.25/ld/testsuite/ld-elf/fini.c b/binutils-2.25/ld/testsuite/ld-elf/fini.c new file mode 100644 index 0000000..cb60655 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/fini.c @@ -0,0 +1,34 @@ +#include <stdio.h> + +static void +fini_0 (void) +{ + printf ("fini array 0\n"); +} + +static void +fini_1 (void) +{ + printf ("fini array 1\n"); +} + +static void +fini_2 (void) +{ + printf ("fini array 2\n"); +} + +void (*const fini_array []) (void) + __attribute__ ((section (".fini_array"), + aligned (sizeof (void *)))) = +{ + &fini_0, + &fini_1, + &fini_2 +}; + +int +main (void) +{ + return 0; +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/fini.out b/binutils-2.25/ld/testsuite/ld-elf/fini.out new file mode 100644 index 0000000..2bab6e6 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/fini.out @@ -0,0 +1,3 @@ +fini array 2 +fini array 1 +fini array 0 diff --git a/binutils-2.25/ld/testsuite/ld-elf/fini0.s b/binutils-2.25/ld/testsuite/ld-elf/fini0.s new file mode 100644 index 0000000..45e327c --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/fini0.s @@ -0,0 +1,16 @@ + .text + .global start /* Used by SH targets. */ +start: + .global _start +_start: + .global __start +__start: + .global main /* Used by HPPA targets. */ +main: + .dc.a 0 + + .section .fini, "a" + .p2align 2 + .global foo + .type foo,%function +foo: diff --git a/binutils-2.25/ld/testsuite/ld-elf/fini1.s b/binutils-2.25/ld/testsuite/ld-elf/fini1.s new file mode 100644 index 0000000..804f554 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/fini1.s @@ -0,0 +1,6 @@ + .section .fini, "a" + .p2align 2 + .type foo1,%function +foo1: + .dc.a 0x0 + .size foo1,.-foo1 diff --git a/binutils-2.25/ld/testsuite/ld-elf/fini2.s b/binutils-2.25/ld/testsuite/ld-elf/fini2.s new file mode 100644 index 0000000..9d87530 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/fini2.s @@ -0,0 +1,6 @@ + .section .fini, "a" + .p2align 6 + .type foo2,%function +foo2: + .dc.a 0x0 + .size foo2,.-foo2 diff --git a/binutils-2.25/ld/testsuite/ld-elf/fini3.s b/binutils-2.25/ld/testsuite/ld-elf/fini3.s new file mode 100644 index 0000000..eb8535a --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/fini3.s @@ -0,0 +1,6 @@ + .section .fini, "a" + .p2align 4 + .type foo3,%function +foo3: + .dc.a 0x0 + .size foo3,.-foo3 diff --git a/binutils-2.25/ld/testsuite/ld-elf/finin.s b/binutils-2.25/ld/testsuite/ld-elf/finin.s new file mode 100644 index 0000000..c23ff79 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/finin.s @@ -0,0 +1,6 @@ + .section .fini, "a" + .p2align 8 + .type last,%function +last: + .dc.a 0x0 + .size last,.-last diff --git a/binutils-2.25/ld/testsuite/ld-elf/flags1.d b/binutils-2.25/ld/testsuite/ld-elf/flags1.d new file mode 100644 index 0000000..63c2e3a --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/flags1.d @@ -0,0 +1,23 @@ +#name: --set-section-flags test 1 (sections) +#ld: -Tflags1.ld +#objcopy_linked_file: --set-section-flags .post_text_reserve=contents,alloc,load,readonly,code +#readelf: -l --wide +#xfail: "avr-*-*" "dlx-*-*" "h8300-*-*" "i960-*-*" "ip2k-*-*" "m32r-*-*" +#xfail: "moxie-*-*" "mt-*-*" "*-*-nacl*" +#xfail: "*-*-hpux*" "hppa*64*-*-*" +# Fails on the AVR, DLX, H8300, I960, IP2K, M32R, MOXIE, MT, +# and all NaCl targets, +# because the two sections are not merged into one segment. +# (There is no good reason why they have to be). +# Fails on HPUX systems because the .type pseudo-op behaves differently. +# Fails on hppa64 because a PHDR is always added. + +#... +Program Headers: + Type.* + LOAD +0x[0-9a-f]+ 0x0*0 0x0*0 0x0*01(6[1-9a-f]|70) 0x0*01(6[1-9a-f]|70) RWE 0x[0-9a-f]+ + +#... + Segment Sections... + 00[ \t]+.text .post_text_reserve[ \t]* +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/flags1.ld b/binutils-2.25/ld/testsuite/ld-elf/flags1.ld new file mode 100644 index 0000000..a94cbe8 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/flags1.ld @@ -0,0 +1,12 @@ +SECTIONS +{ + .text : + { + *(.text) + } =0 + .post_text_reserve : + { + . += 0x160; + } + /DISCARD/ : { *(.*) } +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/flags1.s b/binutils-2.25/ld/testsuite/ld-elf/flags1.s new file mode 100644 index 0000000..bb47536 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/flags1.s @@ -0,0 +1,5 @@ + .text + .globl start + .type start, %function +start: + .byte 0 diff --git a/binutils-2.25/ld/testsuite/ld-elf/foo.c b/binutils-2.25/ld/testsuite/ld-elf/foo.c new file mode 100644 index 0000000..c84baee --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/foo.c @@ -0,0 +1,11 @@ +#include <stdio.h> + +void +foo (void) +{ + printf ("TEST2\n"); +} + +static void (*const init_array []) (void) + __attribute__ ((used, section (".init_array"), aligned (sizeof (void *)))) + = { foo }; diff --git a/binutils-2.25/ld/testsuite/ld-elf/foo.map b/binutils-2.25/ld/testsuite/ld-elf/foo.map new file mode 100644 index 0000000..6b993de --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/foo.map @@ -0,0 +1,4 @@ +FOO { + global: foo; + local: *; +}; diff --git a/binutils-2.25/ld/testsuite/ld-elf/foo0.s b/binutils-2.25/ld/testsuite/ld-elf/foo0.s new file mode 100644 index 0000000..8104970 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/foo0.s @@ -0,0 +1,16 @@ + .text + .global start /* Used by SH targets. */ +start: + .global _start +_start: + .global __start +__start: + .global main /* Used by HPPA targets. */ +main: + .dc.a 0 + + .section .foo,"ax",%progbits + .p2align 2 + .global foo + .type foo,%function +foo: diff --git a/binutils-2.25/ld/testsuite/ld-elf/foo1.s b/binutils-2.25/ld/testsuite/ld-elf/foo1.s new file mode 100644 index 0000000..7a88188 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/foo1.s @@ -0,0 +1,6 @@ + .section .foo,"ax",%progbits + .p2align 2 + .type foo1,%function +foo1: + .dc.a 0x0 + .size foo1,.-foo1 diff --git a/binutils-2.25/ld/testsuite/ld-elf/foo2.s b/binutils-2.25/ld/testsuite/ld-elf/foo2.s new file mode 100644 index 0000000..433a7cc --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/foo2.s @@ -0,0 +1,6 @@ + .section .foo,"ax",%progbits + .p2align 6 + .type foo2,%function +foo2: + .dc.a 0x0 + .size foo2,.-foo2 diff --git a/binutils-2.25/ld/testsuite/ld-elf/foo3.s b/binutils-2.25/ld/testsuite/ld-elf/foo3.s new file mode 100644 index 0000000..24c3005 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/foo3.s @@ -0,0 +1,6 @@ + .section .foo,"ax",%progbits + .p2align 4 + .type foo3,%function +foo3: + .dc.a 0x0 + .size foo3,.-foo3 diff --git a/binutils-2.25/ld/testsuite/ld-elf/foon.s b/binutils-2.25/ld/testsuite/ld-elf/foon.s new file mode 100644 index 0000000..9aa3b85 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/foon.s @@ -0,0 +1,6 @@ + .section .foo,"ax",%progbits + .p2align 8 + .type last,%function +last: + .dc.a 0x0 + .size last,.-last diff --git a/binutils-2.25/ld/testsuite/ld-elf/frame.exp b/binutils-2.25/ld/testsuite/ld-elf/frame.exp new file mode 100644 index 0000000..b9307d4 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/frame.exp @@ -0,0 +1,90 @@ +# Expect script for frame section tests +# Copyright 2004, 2005, 2007 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 ld correctly handles frame sections in ELF. + +# This test can only be run on ELF platforms. +if ![is_elf_format] { + return +} + +# No shared lib support on this target. +if { [istarget "mcore-*-*"] } { + return +} + +# Too small MAXPAGESIZE on this target. +if { [istarget "sh*-*-elf*"] } { + return +} + +# ??? These targets have their own .tbss section, with different meaning +# to the usual ELF .tbss. +if { [istarget "hppa64-*-*"] || [istarget "v850*-*-*"] } { + return +} + +set as_opt "" + +# This target requires extra as options when building code for shared +# libraries. +if { [istarget "tic6x-*-*"] } { + set as_opt "-mpic -mpid=near" +} + +set test1 "read-only .eh_frame section" +set test2 "read-only .gcc_except_table section" + +global as +global ld + +if { ![ld_assemble_flags $as $as_opt $srcdir/$subdir/tbss.s tmpdir/tbss.o ] + || ![ld_assemble_flags $as $as_opt $srcdir/$subdir/frame.s tmpdir/frame.o] } { + unresolved "$test1" + return +} + +if { [ld_simple_link $ld tmpdir/frame.so "--shared tmpdir/frame.o tmpdir/tbss.o"] } { + pass "$test1" +} else { + if [string match "*shared not supported*" $link_output] { + unsupported "-shared is not supported by this target" + } else { + fail "$test1" + } +} + +if ![ld_assemble_flags $as $as_opt $srcdir/$subdir/table.s tmpdir/table.o ] { + unresolved "$test2" + return +} + +if { [ld_simple_link $ld tmpdir/table.so "--shared tmpdir/table.o tmpdir/tbss.o"] } { + pass "$test2" +} else { + if [string match "*shared not supported*" $link_output] { + unsupported "-shared is not supported by this target" + } else { + fail "$test2" + } +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/frame.s b/binutils-2.25/ld/testsuite/ld-elf/frame.s new file mode 100644 index 0000000..c752263 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/frame.s @@ -0,0 +1,2 @@ + .section .eh_frame,"a",%progbits + .4byte 0 diff --git a/binutils-2.25/ld/testsuite/ld-elf/func1.c b/binutils-2.25/ld/testsuite/ld-elf/func1.c new file mode 100644 index 0000000..99443e4 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/func1.c @@ -0,0 +1,2 @@ +void foo (void) { } +void bar (void) { } diff --git a/binutils-2.25/ld/testsuite/ld-elf/global1.d b/binutils-2.25/ld/testsuite/ld-elf/global1.d new file mode 100644 index 0000000..eae7f0d --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/global1.d @@ -0,0 +1,8 @@ +#source: start.s +#ld: -shared -z global +#readelf: -d +#target: *-*-linux* *-*-gnu* + +#... + 0x0*6ffffffb \(FLAGS_1\) *Flags: GLOBAL +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/group.ld b/binutils-2.25/ld/testsuite/ld-elf/group.ld new file mode 100644 index 0000000..123ab26 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/group.ld @@ -0,0 +1,6 @@ +SECTIONS +{ + . = 0x1000; + .text : { *(.text) *(.rodata.brlt) } + /DISCARD/ : { *(.dropme) *(.reginfo) } +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/group1.d b/binutils-2.25/ld/testsuite/ld-elf/group1.d new file mode 100644 index 0000000..6ee74cb --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/group1.d @@ -0,0 +1,12 @@ +#source: group1a.s +#source: group1b.s +#ld: -T group.ld +#readelf: -s +#xfail: arc-*-* d30v-*-* dlx-*-* i960-*-* or32-*-* pj*-*-* +# generic linker targets don't comply with all symbol merging rules + +Symbol table '.symtab' contains .* entries: +#... +.*: 0+1000 +0 +(NOTYPE|OBJECT) +WEAK +DEFAULT +. foo +.*: 0+0000 +0 +(NOTYPE|OBJECT) +GLOBAL +DEFAULT +UND bar +#... diff --git a/binutils-2.25/ld/testsuite/ld-elf/group10.d b/binutils-2.25/ld/testsuite/ld-elf/group10.d new file mode 100644 index 0000000..6fcf83f --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/group10.d @@ -0,0 +1,11 @@ +#source: group10.s +#ld: -r -T group.ld +#readelf: -Sg --wide + +#... +group section \[[ 0-9]+\] `\.group' \[foo_group\] contains 4 sections: + \[Index\] Name + \[[ 0-9]+\] \.text.* + \[[ 0-9]+\] \.rodata\.str.* + \[[ 0-9]+\] \.data.* + \[[ 0-9]+\] \.keepme.* diff --git a/binutils-2.25/ld/testsuite/ld-elf/group10.s b/binutils-2.25/ld/testsuite/ld-elf/group10.s new file mode 100644 index 0000000..57704b4 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/group10.s @@ -0,0 +1,14 @@ + .section .text.foo,"axG",%progbits,foo_group + .word 0 + + .section .rodata.str.1,"aMSG",%progbits,1,foo_group + .asciz "abc" + + .section .data.foo,"waG",%progbits,foo_group + .word 1 + + .section .dropme,"G",%progbits,foo_group + .word 2 + + .section .keepme,"G",%progbits,foo_group + .word 3 diff --git a/binutils-2.25/ld/testsuite/ld-elf/group1a.s b/binutils-2.25/ld/testsuite/ld-elf/group1a.s new file mode 100644 index 0000000..296e76e --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/group1a.s @@ -0,0 +1,4 @@ + .section .text,"axG",%progbits,foo_group,comdat + .weak foo +foo: + .word 0 diff --git a/binutils-2.25/ld/testsuite/ld-elf/group1b.s b/binutils-2.25/ld/testsuite/ld-elf/group1b.s new file mode 100644 index 0000000..b66cba9 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/group1b.s @@ -0,0 +1,6 @@ + .section .text,"axG",%progbits,foo_group,comdat + .global foo + .global bar +foo: + .word 0 +bar: diff --git a/binutils-2.25/ld/testsuite/ld-elf/group2.d b/binutils-2.25/ld/testsuite/ld-elf/group2.d new file mode 100644 index 0000000..664c49a --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/group2.d @@ -0,0 +1,20 @@ +#source: ../../../binutils/testsuite/binutils-all/group.s +#ld: -r +#readelf: -Sg --wide +#xfail: cr16-*-* crx-*-* xstormy*-*-* +# cr16 and crx use non-standard scripts with memory regions, which don't play +# well with unique group sections under ld -r. +# xstormy also uses a non-standard script, putting .data before .text. + +#... + \[[ 0-9]+\] \.group[ \t]+GROUP[ \t]+.* +#... + \[[ 0-9]+\] \.text.*[ \t]+PROGBITS[ \t0-9a-f]+AXG.* +#... + \[[ 0-9]+\] \.data.*[ \t]+PROGBITS[ \t0-9a-f]+WAG.* +#... +COMDAT group section \[[ 0-9]+\] `\.group' \[foo_group\] contains 2 sections: + \[Index\] Name + \[[ 0-9]+\] .text.* + \[[ 0-9]+\] .data.* +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/group3a.d b/binutils-2.25/ld/testsuite/ld-elf/group3a.d new file mode 100644 index 0000000..10c0cf2 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/group3a.d @@ -0,0 +1,8 @@ +#source: group3a.s +#source: group3b.s +#ld: -T group.ld +#readelf: -s +Symbol table '.symtab' contains .* entries: +#... +.*: 0+1000 +0 +OBJECT +GLOBAL +HIDDEN +. foo +#... diff --git a/binutils-2.25/ld/testsuite/ld-elf/group3a.s b/binutils-2.25/ld/testsuite/ld-elf/group3a.s new file mode 100644 index 0000000..5e6a686 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/group3a.s @@ -0,0 +1,5 @@ + .section .data,"awG",%progbits,foo_group,comdat + .globl foo + .type foo,%object +foo: + .word 0 diff --git a/binutils-2.25/ld/testsuite/ld-elf/group3b.d b/binutils-2.25/ld/testsuite/ld-elf/group3b.d new file mode 100644 index 0000000..1b8a2a2 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/group3b.d @@ -0,0 +1,11 @@ +#source: group3b.s +#source: group3a.s +#ld: -T group.ld +#readelf: -s +#xfail: arc-*-* d30v-*-* dlx-*-* i960-*-* or32-*-* pj*-*-* +# generic linker targets don't comply with all symbol merging rules + +Symbol table '.symtab' contains .* entries: +#... +.*: 0+1000 +0 +OBJECT +GLOBAL +HIDDEN +. foo +#... diff --git a/binutils-2.25/ld/testsuite/ld-elf/group3b.s b/binutils-2.25/ld/testsuite/ld-elf/group3b.s new file mode 100644 index 0000000..6c101bc --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/group3b.s @@ -0,0 +1,6 @@ + .section .data,"awG",%progbits,foo_group,comdat + .hidden foo + .globl foo + .type foo,%object +foo: + .word 0 diff --git a/binutils-2.25/ld/testsuite/ld-elf/group4.d b/binutils-2.25/ld/testsuite/ld-elf/group4.d new file mode 100644 index 0000000..af4ca4d --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/group4.d @@ -0,0 +1,20 @@ +#source: ../../../binutils/testsuite/binutils-all/group-2.s +#ld: -r +#readelf: -Sg --wide +#xfail: cr16-*-* crx-*-* xstormy*-*-* +# cr16 and crx use non-standard scripts with memory regions, which don't play +# well with unique group sections under ld -r. +# xstormy also uses a non-standard script, putting .data before .text. + +#... + \[[ 0-9]+\] .group[ \t]+GROUP[ \t]+.* +#... + \[[ 0-9]+\] \.text.*[ \t]+PROGBITS[ \t0-9a-f]+AXG[ \t]+.* +#... + \[[ 0-9]+\] \.data.*[ \t]+PROGBITS[ \t0-9a-f]+WAG[ \t]+.* +#... +COMDAT group section \[[ 0-9]+\] `.group' \[.text.foo\] contains 2 sections: + \[Index\] Name + \[[ 0-9]+\] .text.* + \[[ 0-9]+\] .data.* +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/group5.d b/binutils-2.25/ld/testsuite/ld-elf/group5.d new file mode 100644 index 0000000..5102f81 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/group5.d @@ -0,0 +1,20 @@ +#source: ../../../binutils/testsuite/binutils-all/group-3.s +#ld: -r +#readelf: -Sg --wide +#xfail: cr16-*-* crx-*-* xstormy*-*-* +# cr16 and crx use non-standard scripts with memory regions, which don't play +# well with unique group sections under ld -r. +# xstormy also uses a non-standard script, putting .data before .text. + +#... + \[[ 0-9]+\] .group[ \t]+GROUP[ \t]+.* +#... + \[[ 0-9]+\] \.text.*[ \t]+PROGBITS[ \t0-9a-f]+AXG[ \t]+.* +#... + \[[ 0-9]+\] \.data.*[ \t]+PROGBITS[ \t0-9a-f]+WAG[ \t]+.* +#... +COMDAT group section \[[ 0-9]+\] `.group' \[foo3\] contains 2 sections: + \[Index\] Name + \[[ 0-9]+\] .text.* + \[[ 0-9]+\] .data.* +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/group6.d b/binutils-2.25/ld/testsuite/ld-elf/group6.d new file mode 100644 index 0000000..0e8441f --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/group6.d @@ -0,0 +1,20 @@ +#source: ../../../binutils/testsuite/binutils-all/group-4.s +#ld: -r +#readelf: -Sg --wide +#xfail: cr16-*-* crx-*-* xstormy*-*-* +# cr16 and crx use non-standard scripts with memory regions, which don't play +# well with unique group sections under ld -r. +# xstormy also uses a non-standard script, putting .data before .text. + +#... + \[[ 0-9]+\] .group[ \t]+GROUP[ \t]+.* +#... + \[[ 0-9]+\] \.text.*[ \t]+PROGBITS[ \t0-9a-f]+AXG[ \t]+.* +#... + \[[ 0-9]+\] \.data.*[ \t]+PROGBITS[ \t0-9a-f]+WAG[ \t]+.* +#... +COMDAT group section \[[ 0-9]+\] `.group' \[foo4\] contains 2 sections: + \[Index\] Name + \[[ 0-9]+\] .text.* + \[[ 0-9]+\] .data.* +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/group7.d b/binutils-2.25/ld/testsuite/ld-elf/group7.d new file mode 100644 index 0000000..602a4c8 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/group7.d @@ -0,0 +1,31 @@ +#source: ../../../binutils/testsuite/binutils-all/group.s +#source: ../../../binutils/testsuite/binutils-all/group-2.s +#source: ../../../binutils/testsuite/binutils-all/group-3.s +#source: ../../../binutils/testsuite/binutils-all/group-4.s +#ld: -r +#readelf: -g --wide +#xfail: cr16-*-* crx-*-* +# cr16 and crx use non-standard scripts with memory regions, which don't play +# well with unique group sections under ld -r. + +#... +COMDAT group section \[[ 0-9]+\] `\.group' \[foo_group\] contains 2 sections: + \[Index\] Name + \[[ 0-9]+\] .text.foo + \[[ 0-9]+\] .data.foo +#... +COMDAT group section \[[ 0-9]+\] `.group' \[.text.foo\] contains 2 sections: + \[Index\] Name + \[[ 0-9]+\] .text.foo + \[[ 0-9]+\] .data.bar +#... +COMDAT group section \[[ 0-9]+\] `.group' \[foo3\] contains 2 sections: + \[Index\] Name + \[[ 0-9]+\] .text.foo3 + \[[ 0-9]+\] .data.bar3 +#... +COMDAT group section \[[ 0-9]+\] `.group' \[foo4\] contains 2 sections: + \[Index\] Name + \[[ 0-9]+\] .text.foo4 + \[[ 0-9]+\] .data.foo4 +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/group8.s b/binutils-2.25/ld/testsuite/ld-elf/group8.s new file mode 100644 index 0000000..7766c6c --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/group8.s @@ -0,0 +1,10 @@ + .section .text.foo,"axG",%progbits,foo,comdat + .globl foo + .type foo,%function +foo: + .byte 0 + .section .text.bar,"axG",%progbits,bar,comdat + .globl bar + .type bar,%function +bar: + .byte 0 diff --git a/binutils-2.25/ld/testsuite/ld-elf/group8a.d b/binutils-2.25/ld/testsuite/ld-elf/group8a.d new file mode 100644 index 0000000..bad4123 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/group8a.d @@ -0,0 +1,13 @@ +#source: group8.s +#ld: -r --gc-sections --entry foo +#readelf: -g --wide +#notarget: arc-*-* d30v-*-* dlx-*-* i960-*-* or32-*-* pj*-*-* +#notarget: hppa64-*-* i370-*-* i860-*-* ia64-*-* mep-*-* mn10200-*-* +#xfail: cr16-*-* crx-*-* +# generic linker targets don't support --gc-sections, nor do a bunch of others +# cr16 and crx use non-standard scripts with memory regions, which don't play +# well with unique group sections under ld -r. + +COMDAT group section \[[ 0-9]+\] `.group' \[foo\] contains 1 sections: + \[Index\] Name + \[[ 0-9]+\] .text.foo diff --git a/binutils-2.25/ld/testsuite/ld-elf/group8b.d b/binutils-2.25/ld/testsuite/ld-elf/group8b.d new file mode 100644 index 0000000..fb37198 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/group8b.d @@ -0,0 +1,13 @@ +#source: group8.s +#ld: -r --gc-sections --entry bar +#readelf: -g --wide +#notarget: arc-*-* d30v-*-* dlx-*-* i960-*-* or32-*-* pj*-*-* +#notarget: hppa64-*-* i370-*-* i860-*-* ia64-*-* mep-*-* mn10200-*-* +#xfail: cr16-*-* crx-*-* +# generic linker targets don't support --gc-sections, nor do a bunch of others +# cr16 and crx use non-standard scripts with memory regions, which don't play +# well with unique group sections under ld -r. + +COMDAT group section \[[ 0-9]+\] `.group' \[bar\] contains 1 sections: + \[Index\] Name + \[[ 0-9]+\] .text.bar diff --git a/binutils-2.25/ld/testsuite/ld-elf/group9.s b/binutils-2.25/ld/testsuite/ld-elf/group9.s new file mode 100644 index 0000000..933c9f9 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/group9.s @@ -0,0 +1,15 @@ + .section .text.foo,"axG",%progbits,foo,comdat + .globl foo + .type foo,%function +foo: + .byte 0 + .section .data.foo,"axG",%progbits,foo,comdat + .globl foo.data + .type foo,%object +foo.data: + .byte 0 + .section .text.bar,"axG",%progbits,bar,comdat + .globl bar + .type bar,%function +bar: + .long foo.data diff --git a/binutils-2.25/ld/testsuite/ld-elf/group9a.d b/binutils-2.25/ld/testsuite/ld-elf/group9a.d new file mode 100644 index 0000000..fd04c48 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/group9a.d @@ -0,0 +1,14 @@ +#source: group9.s +#ld: -r --gc-sections --entry foo +#readelf: -g --wide +#notarget: arc-*-* d30v-*-* dlx-*-* i960-*-* or32-*-* pj*-*-* +#notarget: alpha-*-* hppa64-*-* i370-*-* i860-*-* ia64-*-* mep-*-* mn10200-*-* +#xfail: cr16-*-* crx-*-* +# generic linker targets don't support --gc-sections, nor do a bunch of others +# cr16 and crx use non-standard scripts with memory regions, which don't play +# well with unique group sections under ld -r. + +COMDAT group section \[[ 0-9]+\] `.group' \[foo\] contains 2 sections: + \[Index\] Name + \[[ 0-9]+\] .text.foo + \[[ 0-9]+\] .data.foo diff --git a/binutils-2.25/ld/testsuite/ld-elf/group9b.d b/binutils-2.25/ld/testsuite/ld-elf/group9b.d new file mode 100644 index 0000000..3f19fd6 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/group9b.d @@ -0,0 +1,18 @@ +#source: group9.s +#ld: -r --gc-sections --entry bar +#readelf: -g --wide +#notarget: arc-*-* d30v-*-* dlx-*-* i960-*-* or32-*-* pj*-*-* +#notarget: alpha-*-* hppa64-*-* i370-*-* i860-*-* ia64-*-* mep-*-* mn10200-*-* +#xfail: cr16-*-* crx-*-* +# generic linker targets don't support --gc-sections, nor do a bunch of others +# cr16 and crx use non-standard scripts with memory regions, which don't play +# well with unique group sections under ld -r. + +COMDAT group section \[[ 0-9]+\] `.group' \[foo\] contains 2 sections: + \[Index\] Name + \[[ 0-9]+\] .text.foo + \[[ 0-9]+\] .data.foo + +COMDAT group section \[[ 0-9]+\] `.group' \[bar\] contains 1 sections: + \[Index\] Name + \[[ 0-9]+\] .text.bar diff --git a/binutils-2.25/ld/testsuite/ld-elf/hash.d b/binutils-2.25/ld/testsuite/ld-elf/hash.d new file mode 100644 index 0000000..473cd4d --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/hash.d @@ -0,0 +1,17 @@ +#source: start.s +#readelf: -d -s -D +#ld: -shared --hash-style=gnu +#target: *-*-linux* *-*-gnu* +#notarget: mips*-*-* + +#... + +0x[0-9a-z]+ +\(GNU_HASH\) +0x[0-9a-z]+ +#... + +[0-9]+ +[0-9]+: +[0-9a-f]+ +[0-9]+ +NOTYPE +GLOBAL +DEFAULT +[1-9] _start +#... + +[0-9]+ +[0-9]+: +[0-9a-f]+ +[0-9]+ +NOTYPE +GLOBAL +DEFAULT +[1-9] main +#... + +[0-9]+ +[0-9]+: +[0-9a-f]+ +[0-9]+ +NOTYPE +GLOBAL +DEFAULT +[1-9] start +#... + +[0-9]+ +[0-9]+: +[0-9a-f]+ +[0-9]+ +NOTYPE +GLOBAL +DEFAULT +[1-9] __start +#... diff --git a/binutils-2.25/ld/testsuite/ld-elf/header.d b/binutils-2.25/ld/testsuite/ld-elf/header.d new file mode 100644 index 0000000..be3722d --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/header.d @@ -0,0 +1,5 @@ +# target: *-*-linux* *-*-gnu* *-*-vxworks +# ld: -T header.t -z max-page-size=0x100 +# objdump: -hpw + +#... diff --git a/binutils-2.25/ld/testsuite/ld-elf/header.s b/binutils-2.25/ld/testsuite/ld-elf/header.s new file mode 100644 index 0000000..38f2228 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/header.s @@ -0,0 +1,8 @@ + .text + .globl main +main: + .rept 0x40 - 0x15 + .long 0xfedcba98 + .endr + .data + .long 0x76543210 diff --git a/binutils-2.25/ld/testsuite/ld-elf/header.t b/binutils-2.25/ld/testsuite/ld-elf/header.t new file mode 100644 index 0000000..c378fbe --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/header.t @@ -0,0 +1,8 @@ +ENTRY(main) + +SECTIONS +{ + . = 0x100 + SIZEOF_HEADERS; + .text : { *(.text) } + .data : { *(.data) } +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/hidden.out b/binutils-2.25/ld/testsuite/ld-elf/hidden.out new file mode 100644 index 0000000..7ad7cbe --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/hidden.out @@ -0,0 +1,3 @@ +TEST2 +TEST1 +MAIN diff --git a/binutils-2.25/ld/testsuite/ld-elf/indirect.exp b/binutils-2.25/ld/testsuite/ld-elf/indirect.exp new file mode 100644 index 0000000..d5d3abc --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/indirect.exp @@ -0,0 +1,137 @@ +# Expect script for various indirect symbol tests. +# Copyright 2012 Free Software Foundation, Inc. +# +# 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 2 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) +# + +# Exclude non-ELF targets. + +if ![is_elf_format] { + return +} + +# Skip target where -shared is not supported + +if ![check_shared_lib_support] { + return +} + +# Check if compiler works +if { [which $CC] == 0 } { + return +} + +# Some bare-metal targets don't support shared libs or PIC. +if { ![run_host_cmd_yesno $CC "-shared -fPIC $srcdir/$subdir/dummy.c -o tmpdir/t.so"] } { + return +} + +proc check_link_message { cmd string testname } { + send_log "$cmd\n" + verbose "$cmd" + catch "exec $cmd" exec_output + send_log "$exec_output\n" + verbose "$exec_output" + + foreach str $string { + if [string match "*$str*" $exec_output] { + pass "$testname: $str" + } else { + fail "$testname: $str" + } + } +} + +if { ![ld_compile $CC $srcdir/$subdir/indirect1a.c tmpdir/indirect1a.o] + || ![ld_compile $CC $srcdir/$subdir/indirect1b.c tmpdir/indirect1b.o] + || ![ld_compile "$CC -fPIC" $srcdir/$subdir/indirect2.c tmpdir/indirect2.o] + || ![ld_compile $CC $srcdir/$subdir/indirect3a.c tmpdir/indirect3a.o] + || ![ld_compile $CC $srcdir/$subdir/indirect3b.c tmpdir/indirect3b.o] + || ![ld_compile $CC $srcdir/$subdir/indirect4a.c tmpdir/indirect4a.o] + || ![ld_compile $CC $srcdir/$subdir/indirect4b.c tmpdir/indirect4b.o] } { + unresolved "Indirect symbol tests" + return +} + +set build_tests { + {"Build libindirect1c.so" + "-shared" "-fPIC" + {indirect1c.c} {} "libindirect1c.so"} + {"Build libindirect3c.so" + "-shared" "-fPIC" + {indirect3c.c} {} "libindirect3c.so"} + {"Build libindirect4c.so" + "-shared" "-fPIC" + {indirect4c.c} {} "libindirect4c.so"} +} + +run_cc_link_tests $build_tests + +global ld + +set string ": final link failed: Bad value" +set string1 ": local symbol \`foo\' in tmpdir/indirect1b.o is referenced by DSO" + +set testname "Indirect symbol 1a" +set cmd "$ld -e start -o tmpdir/indirect1 tmpdir/indirect1a.o tmpdir/indirect1b.o tmpdir/libindirect1c.so" +check_link_message "$cmd" [list $string1 $string] "$testname" + +set testname "Indirect symbol 1b" +set cmd "$ld -e start -o tmpdir/indirect1 tmpdir/indirect1a.o tmpdir/libindirect1c.so tmpdir/indirect1b.o" +check_link_message "$cmd" [list $string1 $string] "$testname" + +set string ": final link failed: Nonrepresentable section on output" +set string2 ": No symbol version section for versioned symbol \`foo@FOO\'" +set testname "Indirect symbol 2" +set cmd "$ld -shared -o tmpdir/indirect2.so tmpdir/indirect2.o" +check_link_message "$cmd" [list $string2 $string] "$testname" + +# The following tests require running the executable generated by ld. +if ![isnative] { + return +} + +set run_tests { + {"Run with libindirect3c.so 1" + "tmpdir/indirect3a.o tmpdir/indirect3b.o tmpdir/libindirect3c.so" "" + {dummy.c} "indirect3a" "indirect3.out"} + {"Run with libindirect3c.so 2" + "tmpdir/indirect3a.o tmpdir/libindirect3c.so tmpdir/indirect3b.o" "" + {dummy.c} "indirect3b" "indirect3.out"} + {"Run with libindirect3c.so 3" + "tmpdir/indirect3b.o tmpdir/libindirect3c.so tmpdir/indirect3a.o" "" + {dummy.c} "indirect3c" "indirect3.out"} + {"Run with libindirect3c.so 4" + "tmpdir/libindirect3c.so tmpdir/indirect3b.o tmpdir/indirect3a.o" "" + {dummy.c} "indirect3d" "indirect3.out"} + {"Run with libindirect4c.so 1" + "tmpdir/indirect4a.o tmpdir/indirect4b.o tmpdir/libindirect4c.so" "" + {dummy.c} "indirect4a" "indirect4.out"} + {"Run with libindirect4c.so 2" + "tmpdir/indirect4a.o tmpdir/libindirect4c.so tmpdir/indirect4b.o" "" + {dummy.c} "indirect4b" "indirect4.out"} + {"Run with libindirect4c.so 3" + "tmpdir/indirect4b.o tmpdir/libindirect4c.so tmpdir/indirect4a.o" "" + {dummy.c} "indirect4c" "indirect4.out"} + {"Run with libindirect4c.so 4" + "tmpdir/libindirect4c.so tmpdir/indirect4b.o tmpdir/indirect4a.o" "" + {dummy.c} "indirect4d" "indirect4.out"} +} + +run_ld_link_exec_tests [] $run_tests diff --git a/binutils-2.25/ld/testsuite/ld-elf/indirect1a.c b/binutils-2.25/ld/testsuite/ld-elf/indirect1a.c new file mode 100644 index 0000000..6931542 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/indirect1a.c @@ -0,0 +1,8 @@ +extern void bar (void); + +int +start (void) +{ + bar (); + return 0; +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/indirect1b.c b/binutils-2.25/ld/testsuite/ld-elf/indirect1b.c new file mode 100644 index 0000000..51740f9 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/indirect1b.c @@ -0,0 +1,6 @@ +void +foo (void) +{ +} + +asm (".symver foo,foo@FOO"); diff --git a/binutils-2.25/ld/testsuite/ld-elf/indirect1c.c b/binutils-2.25/ld/testsuite/ld-elf/indirect1c.c new file mode 100644 index 0000000..eae278d --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/indirect1c.c @@ -0,0 +1,7 @@ +extern void foo (void); + +void +bar (void) +{ + foo (); +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/indirect2.c b/binutils-2.25/ld/testsuite/ld-elf/indirect2.c new file mode 100644 index 0000000..6df29be --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/indirect2.c @@ -0,0 +1,9 @@ +extern void foo (void); + +asm (".symver foo,foo@@@FOO"); + +void +bar (void) +{ + foo (); +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/indirect3.out b/binutils-2.25/ld/testsuite/ld-elf/indirect3.out new file mode 100644 index 0000000..482e981 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/indirect3.out @@ -0,0 +1,2 @@ +MAIN +DSO diff --git a/binutils-2.25/ld/testsuite/ld-elf/indirect3a.c b/binutils-2.25/ld/testsuite/ld-elf/indirect3a.c new file mode 100644 index 0000000..0f6ddc8 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/indirect3a.c @@ -0,0 +1,10 @@ +extern void bar (void); +extern void foo (void); + +int +main (void) +{ + foo (); + bar (); + return 0; +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/indirect3b.c b/binutils-2.25/ld/testsuite/ld-elf/indirect3b.c new file mode 100644 index 0000000..dbb37c3 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/indirect3b.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +void +foo (void) +{ + printf ("MAIN\n"); +} + +asm (".symver foo,foo@FOO"); diff --git a/binutils-2.25/ld/testsuite/ld-elf/indirect3c.c b/binutils-2.25/ld/testsuite/ld-elf/indirect3c.c new file mode 100644 index 0000000..b52cb95 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/indirect3c.c @@ -0,0 +1,15 @@ +#include <stdio.h> + +extern void foo (void); + +void +foo (void) +{ + printf ("DSO\n"); +} + +void +bar (void) +{ + foo (); +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/indirect4.out b/binutils-2.25/ld/testsuite/ld-elf/indirect4.out new file mode 100644 index 0000000..3b34ee4 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/indirect4.out @@ -0,0 +1,2 @@ +MAIN2 +MAIN2 diff --git a/binutils-2.25/ld/testsuite/ld-elf/indirect4a.c b/binutils-2.25/ld/testsuite/ld-elf/indirect4a.c new file mode 100644 index 0000000..0f6ddc8 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/indirect4a.c @@ -0,0 +1,10 @@ +extern void bar (void); +extern void foo (void); + +int +main (void) +{ + foo (); + bar (); + return 0; +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/indirect4b.c b/binutils-2.25/ld/testsuite/ld-elf/indirect4b.c new file mode 100644 index 0000000..b8db9d0 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/indirect4b.c @@ -0,0 +1,17 @@ +#include <stdio.h> + +void +foo2 (void) +{ + printf ("MAIN2\n"); +} + +asm (".symver foo2,foo@@FOO2"); + +void +foo1 (void) +{ + printf ("MAIN1\n"); +} + +asm (".symver foo1,foo@FOO1"); diff --git a/binutils-2.25/ld/testsuite/ld-elf/indirect4c.c b/binutils-2.25/ld/testsuite/ld-elf/indirect4c.c new file mode 100644 index 0000000..b52cb95 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/indirect4c.c @@ -0,0 +1,15 @@ +#include <stdio.h> + +extern void foo (void); + +void +foo (void) +{ + printf ("DSO\n"); +} + +void +bar (void) +{ + foo (); +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/init-fini-arrays.d b/binutils-2.25/ld/testsuite/ld-elf/init-fini-arrays.d new file mode 100644 index 0000000..46b536c --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/init-fini-arrays.d @@ -0,0 +1,13 @@ +#source: init-fini-arrays.s +#ld: -r +#readelf: -S --wide +#xfail: cr16-*-* crx-*-* msp430-*-* +# msp430 puts the init_array and fini_array inside the .rodata section. +# cr16 and crx use non-standard scripts with memory regions, which don't play +# well with unique group sections under ld -r. + +#... + \[[ 0-9]+\] \.init_array\.01000[ \t]+PROGBITS[ \t0-9a-f]+WA?.* +#... + \[[ 0-9]+\] \.fini_array\.01000[ \t]+PROGBITS[ \t0-9a-f]+WA?.* +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/init-fini-arrays.s b/binutils-2.25/ld/testsuite/ld-elf/init-fini-arrays.s new file mode 100644 index 0000000..8f7a3f7 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/init-fini-arrays.s @@ -0,0 +1,6 @@ + .section .init_array.01000,"aw",%progbits + .align 4 + .word 0 + .section .fini_array.01000,"aw",%progbits + .align 4 + .word 0 diff --git a/binutils-2.25/ld/testsuite/ld-elf/init-mixed.c b/binutils-2.25/ld/testsuite/ld-elf/init-mixed.c new file mode 100644 index 0000000..f401ded --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/init-mixed.c @@ -0,0 +1,125 @@ +#include "config.h" +#include <stdio.h> +#include <stdlib.h> + +#ifdef HAVE_INITFINI_ARRAY +static int count; + +static void +init1005 () +{ + if (count != 0) + abort (); + count = 1005; +} +void (*const init_array1005[]) () + __attribute__ ((section (".init_array.01005"), aligned (sizeof (void *)))) + = { init1005 }; +static void +fini1005 () +{ + if (count != 1005) + abort (); +} +void (*const fini_array1005[]) () + __attribute__ ((section (".fini_array.01005"), aligned (sizeof (void *)))) + = { fini1005 }; + +static void +ctor1007a () +{ + if (count != 1005) + abort (); + count = 1006; +} +static void +ctor1007b () +{ + if (count != 1006) + abort (); + count = 1007; +} +void (*const ctors1007[]) () + __attribute__ ((section (".ctors.64528"), aligned (sizeof (void *)))) + = { ctor1007b, ctor1007a }; +static void +dtor1007a () +{ + if (count != 1006) + abort (); + count = 1005; +} +static void +dtor1007b () +{ + if (count != 1007) + abort (); + count = 1006; +} +void (*const dtors1007[]) () + __attribute__ ((section (".dtors.64528"), aligned (sizeof (void *)))) + = { dtor1007b, dtor1007a }; + +static void +init65530 () +{ + if (count != 1007) + abort (); + count = 65530; +} +void (*const init_array65530[]) () + __attribute__ ((section (".init_array.65530"), aligned (sizeof (void *)))) + = { init65530 }; +static void +fini65530 () +{ + if (count != 65530) + abort (); + count = 1007; +} +void (*const fini_array65530[]) () + __attribute__ ((section (".fini_array.65530"), aligned (sizeof (void *)))) + = { fini65530 }; + +static void +ctor65535a () +{ + if (count != 65530) + abort (); + count = 65535; +} +static void +ctor65535b () +{ + if (count != 65535) + abort (); + count = 65536; +} +void (*const ctors65535[]) () + __attribute__ ((section (".ctors"), aligned (sizeof (void *)))) + = { ctor65535b, ctor65535a }; +static void +dtor65535b () +{ + if (count != 65536) + abort (); + count = 65535; +} +static void +dtor65535a () +{ + if (count != 65535) + abort (); + count = 65530; +} +void (*const dtors65535[]) () + __attribute__ ((section (".dtors"), aligned (sizeof (void *)))) + = { dtor65535b, dtor65535a }; +#endif + +int +main () +{ + printf ("OK\n"); + return 0; +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/init-mixed.out b/binutils-2.25/ld/testsuite/ld-elf/init-mixed.out new file mode 100644 index 0000000..d86bac9 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/init-mixed.out @@ -0,0 +1 @@ +OK diff --git a/binutils-2.25/ld/testsuite/ld-elf/init.c b/binutils-2.25/ld/testsuite/ld-elf/init.c new file mode 100644 index 0000000..3b1ffb1 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/init.c @@ -0,0 +1,34 @@ +#include <stdio.h> + +static void +init_0 (void) +{ + printf ("init array 0\n"); +} + +static void +init_1 (void) +{ + printf ("init array 1\n"); +} + +static void +init_2 (void) +{ + printf ("init array 2\n"); +} + +void (*const init_array []) (void) + __attribute__ ((section (".init_array"), + aligned (sizeof (void *)))) = +{ + &init_0, + &init_1, + &init_2 +}; + +int +main (void) +{ + return 0; +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/init.out b/binutils-2.25/ld/testsuite/ld-elf/init.out new file mode 100644 index 0000000..f988b84 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/init.out @@ -0,0 +1,3 @@ +init array 0 +init array 1 +init array 2 diff --git a/binutils-2.25/ld/testsuite/ld-elf/init0.s b/binutils-2.25/ld/testsuite/ld-elf/init0.s new file mode 100644 index 0000000..903f0b0 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/init0.s @@ -0,0 +1,16 @@ + .text + .global start /* Used by SH targets. */ +start: + .global _start +_start: + .global __start +__start: + .global main /* Used by HPPA targets. */ +main: + .dc.a 0 + + .section .init, "a" + .p2align 2 + .global foo + .type foo,%function +foo: diff --git a/binutils-2.25/ld/testsuite/ld-elf/init1.s b/binutils-2.25/ld/testsuite/ld-elf/init1.s new file mode 100644 index 0000000..b1d6cd7 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/init1.s @@ -0,0 +1,6 @@ + .section .init, "a" + .p2align 2 + .type foo1,%function +foo1: + .dc.a 0x0 + .size foo1,.-foo1 diff --git a/binutils-2.25/ld/testsuite/ld-elf/init2.s b/binutils-2.25/ld/testsuite/ld-elf/init2.s new file mode 100644 index 0000000..0185148 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/init2.s @@ -0,0 +1,6 @@ + .section .init, "a" + .p2align 6 + .type foo2,%function +foo2: + .dc.a 0x0 + .size foo2,.-foo2 diff --git a/binutils-2.25/ld/testsuite/ld-elf/init3.s b/binutils-2.25/ld/testsuite/ld-elf/init3.s new file mode 100644 index 0000000..71696c0 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/init3.s @@ -0,0 +1,6 @@ + .section .init, "a" + .p2align 4 + .type foo3,%function +foo3: + .dc.a 0x0 + .size foo3,.-foo3 diff --git a/binutils-2.25/ld/testsuite/ld-elf/initn.s b/binutils-2.25/ld/testsuite/ld-elf/initn.s new file mode 100644 index 0000000..3d0990e --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/initn.s @@ -0,0 +1,6 @@ + .section .init, "a" + .p2align 8 + .type last,%function +last: + .dc.a 0x0 + .size last,.-last diff --git a/binutils-2.25/ld/testsuite/ld-elf/libbarw.rd b/binutils-2.25/ld/testsuite/ld-elf/libbarw.rd new file mode 100644 index 0000000..c650c17 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/libbarw.rd @@ -0,0 +1,3 @@ +#... + \[[ 0-9]+\] \.gnu.warning.foo[ \t]+PROGBITS[ \t0-9a-f]+.* +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/linkonce1.d b/binutils-2.25/ld/testsuite/ld-elf/linkonce1.d new file mode 100644 index 0000000..c0e331f --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/linkonce1.d @@ -0,0 +1,12 @@ +#source: linkonce1a.s +#source: linkonce1b.s +#ld: -r +#objdump: -r + +.*: file format .* + +RELOCATION RECORDS FOR \[.debug_frame\]: +OFFSET[ ]+TYPE[ ]+VALUE[ ]* +.*(NONE|unused|UNUSED).*\*ABS\* + +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/linkonce1a.s b/binutils-2.25/ld/testsuite/ld-elf/linkonce1a.s new file mode 100644 index 0000000..5c2d8c2 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/linkonce1a.s @@ -0,0 +1,3 @@ + .section .gnu.linkonce.d.dummy,"aw" +bar: + .long 0 diff --git a/binutils-2.25/ld/testsuite/ld-elf/linkonce1b.s b/binutils-2.25/ld/testsuite/ld-elf/linkonce1b.s new file mode 100644 index 0000000..fd45cec --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/linkonce1b.s @@ -0,0 +1,17 @@ + .globl main + .globl start + .globl _start + .globl __start + .text +main: +start: +_start: +__start: + .long 0 + + .section .gnu.linkonce.d.dummy,"aw" + .long 0 +foo: + .long 0 + .section .debug_frame,"",%progbits + .long foo diff --git a/binutils-2.25/ld/testsuite/ld-elf/linkonce2.d b/binutils-2.25/ld/testsuite/ld-elf/linkonce2.d new file mode 100644 index 0000000..0cbb3ad --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/linkonce2.d @@ -0,0 +1,14 @@ +#source: linkonce1a.s +#source: linkonce1b.s +#ld: -emit-relocs +#objdump: -r +#notarget: arc-*-* d30v-*-* dlx-*-* i960-*-* or32-*-* pj*-*-* +# generic elf targets don't emit relocs + +.*: file format .* + +RELOCATION RECORDS FOR \[.debug_frame\]: +OFFSET[ ]+TYPE[ ]+VALUE[ ]* +.*(NONE|unused|UNUSED).*\*ABS\* + +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/linkoncerdiff.d b/binutils-2.25/ld/testsuite/ld-elf/linkoncerdiff.d new file mode 100644 index 0000000..06d08c1 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/linkoncerdiff.d @@ -0,0 +1,7 @@ +#source: linkoncerdiff1.s +#source: linkoncerdiff2.s +#ld: -r +#readelf: -r +#notarget: hppa64*-*-hpux* +There are no relocations in this file. +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/linkoncerdiff1.s b/binutils-2.25/ld/testsuite/ld-elf/linkoncerdiff1.s new file mode 100644 index 0000000..9e8e17e --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/linkoncerdiff1.s @@ -0,0 +1,7 @@ + .section .gnu.linkonce.t.foo, "a", %progbits + .globl symfoo +symfoo: + + .section .gnu.linkonce.t.bar, "a", %progbits + .globl symbar +symbar: diff --git a/binutils-2.25/ld/testsuite/ld-elf/linkoncerdiff2.s b/binutils-2.25/ld/testsuite/ld-elf/linkoncerdiff2.s new file mode 100644 index 0000000..1e8c2ba --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/linkoncerdiff2.s @@ -0,0 +1,22 @@ + .section .gnu.linkonce.t.foo, "a", %progbits +1: + .globl symfoo +symfoo: + .long 0 + + .section .gnu.linkonce.t.bar, "a", %progbits +2: + .globl symbar +symbar: + .long 0 + + .section .gnu.linkonce.r.foo, "a", %progbits + .long 1b + .long symfoo +/* ld currently incorrectly silently discards this relocation. Just such + relocations are never produced by g++-3.4 so this suppressed error message + is not a problem: + #error: `.gnu.linkonce.t.bar' referenced in section `.gnu.linkonce.r.foo' of tmpdir/dump1.o: defined in discarded section `.gnu.linkonce.t.bar' of tmpdir/dump1.o + */ + .long 2b + .long symbar diff --git a/binutils-2.25/ld/testsuite/ld-elf/lma.lnk b/binutils-2.25/ld/testsuite/ld-elf/lma.lnk new file mode 100644 index 0000000..7aac6d0 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/lma.lnk @@ -0,0 +1,6 @@ +SECTIONS +{ + . = -0x100000; + .text : AT(ADDR(.text) + 0x100000) { *(.text) } + /DISCARD/ : { *(*) } +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/lma.s b/binutils-2.25/ld/testsuite/ld-elf/lma.s new file mode 100644 index 0000000..039d26b --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/lma.s @@ -0,0 +1,4 @@ + .text + .global _start +_start: + .long 0 diff --git a/binutils-2.25/ld/testsuite/ld-elf/loadaddr.s b/binutils-2.25/ld/testsuite/ld-elf/loadaddr.s new file mode 100644 index 0000000..0a14169 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/loadaddr.s @@ -0,0 +1,20 @@ + .text + .globl main + .globl start + .globl _start + .globl __start +main: +start: +_start: +__start: + .byte 0,0,0,0,0,0,0,0 + .byte 0,0,0,0,0,0,0,0 + .section .bar,"ax","progbits" + .byte 0,0,0,0,0,0,0,0 + .byte 0,0,0,0,0,0,0,0 + .section .foo,"aw","progbits" + .byte 0,0,0,0,0,0,0,0 + .byte 0,0,0,0,0,0,0,0 + .data + .byte 0,0,0,0,0,0,0,0 + .byte 0,0,0,0,0,0,0,0 diff --git a/binutils-2.25/ld/testsuite/ld-elf/loadaddr.t b/binutils-2.25/ld/testsuite/ld-elf/loadaddr.t new file mode 100644 index 0000000..91e9ef2 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/loadaddr.t @@ -0,0 +1,10 @@ +SECTIONS +{ + . = -0x7ff00000; + .text : {*(.text .text.*)} + . = ALIGN(64); + .foo : { *(.foo) } + . = ALIGN(8192); + .data : AT (ADDR(.data)) { *(.data) } + /DISCARD/ : { *(.*) } +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/loadaddr1.d b/binutils-2.25/ld/testsuite/ld-elf/loadaddr1.d new file mode 100644 index 0000000..0fd96a7 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/loadaddr1.d @@ -0,0 +1,10 @@ +#source: loadaddr.s +#ld: -T loadaddr1.t -T loadaddr.t -z max-page-size=0x200000 +#readelf: -l --wide +#target: *-*-linux* *-*-gnu* + +#... + LOAD +0x000000 0xf*80000000 0xf*80000000 0x100050 0x100050 RWE 0x200000 + LOAD +0x200000 0xf*ff600000 0xf*80101000 0x0*10 0x0*10 R E 0x200000 + LOAD +0x302000 0xf*80102000 0xf*80102000 0x0*10 0x0*10 RW 0x200000 +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/loadaddr1.t b/binutils-2.25/ld/testsuite/ld-elf/loadaddr1.t new file mode 100644 index 0000000..5037b4f --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/loadaddr1.t @@ -0,0 +1,7 @@ +SECTIONS +{ + .bar -0xa00000 : AT ((LOADADDR(.foo) + SIZEOF(.foo) + 4095) & ~(4095)) + { *(.bar) } + . = LOADADDR(.bar) + 4096; +} +INSERT AFTER .foo; diff --git a/binutils-2.25/ld/testsuite/ld-elf/loadaddr2.d b/binutils-2.25/ld/testsuite/ld-elf/loadaddr2.d new file mode 100644 index 0000000..5825fe8 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/loadaddr2.d @@ -0,0 +1,10 @@ +#source: loadaddr.s +#ld: -T loadaddr2.t -T loadaddr.t -z max-page-size=0x200000 +#readelf: -l --wide +#target: *-*-linux* *-*-gnu* + +#... + LOAD +0x000000 0xf*80000000 0xf*80000000 0x100050 0x100050 RWE 0x200000 + LOAD +0x110000 0xf*80110000 0xf*80101000 0x0*10 0x0*10 R E 0x200000 + LOAD +0x302000 0xf*80302000 0xf*80302000 0x0*10 0x0*10 RW 0x200000 +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/loadaddr2.t b/binutils-2.25/ld/testsuite/ld-elf/loadaddr2.t new file mode 100644 index 0000000..0ad16df --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/loadaddr2.t @@ -0,0 +1,7 @@ +SECTIONS +{ + .bar -0x7fef0000 : AT ((LOADADDR(.foo) + SIZEOF(.foo) + 4095) & ~(4095)) + { *(.bar) } + . = LOADADDR(.bar) + 0x200000; +} +INSERT BEFORE .data; diff --git a/binutils-2.25/ld/testsuite/ld-elf/loadaddr3.t b/binutils-2.25/ld/testsuite/ld-elf/loadaddr3.t new file mode 100644 index 0000000..789f61e --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/loadaddr3.t @@ -0,0 +1,16 @@ + +MEMORY +{ + rom (rx) : ORIGIN = 0x100, LENGTH = 0x100 + ram (rwx) : ORIGIN = 0x200, LENGTH = 0x100 + +} + +SECTIONS +{ + .text : {*(.text .text.*)} >rom + .data : {data_load = LOADADDR (.data); + data_start = ADDR (.data); + *(.data .data.*)} >ram AT>rom + /DISCARD/ : { *(.*) } +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/loadaddr3a.d b/binutils-2.25/ld/testsuite/ld-elf/loadaddr3a.d new file mode 100644 index 0000000..10cb9a5 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/loadaddr3a.d @@ -0,0 +1,9 @@ +#source: loadaddr.s +#ld: -T loadaddr3.t -z max-page-size=0x200000 +#readelf: -l --wide +#target: *-*-linux* *-*-gnu* + +#... + LOAD +0x000000 0x0*00000000 0x0*00000000 0x0*0110 0x0*0110 R E 0x.* + LOAD +0x000200 0x0*00000200 0x0*00000110 0x0*0010 0x0*0010 RW 0x.* +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/loadaddr3b.d b/binutils-2.25/ld/testsuite/ld-elf/loadaddr3b.d new file mode 100644 index 0000000..63efa71 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/loadaddr3b.d @@ -0,0 +1,13 @@ +#source: loadaddr.s +#ld: -T loadaddr3.t -z max-page-size=0x200000 +#objdump: -t +#target: *-*-linux* *-*-gnu* + +#... +0+0000100 l d .text 0+0000000 .text +0+0000200 l d .data 0+0000000 .data +#... +0+0000110 g \*ABS\* 0+0000000 data_load +#... +0+0000200 g .data 0+0000000 data_start +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/local1.d b/binutils-2.25/ld/testsuite/ld-elf/local1.d new file mode 100644 index 0000000..3025d41 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/local1.d @@ -0,0 +1,7 @@ +#ld: -shared --version-script local1.map +#readelf: -s --wide +#target: *-*-linux* *-*-gnu* + +#... + .*: [0-9a-f]* +[0-9a-f]+ +OBJECT +LOCAL +DEFAULT +[0-9] +foo +#... diff --git a/binutils-2.25/ld/testsuite/ld-elf/local1.map b/binutils-2.25/ld/testsuite/ld-elf/local1.map new file mode 100644 index 0000000..1e2aa8c --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/local1.map @@ -0,0 +1,6 @@ +{ +global: + *; +local: + foo; +}; diff --git a/binutils-2.25/ld/testsuite/ld-elf/local1.s b/binutils-2.25/ld/testsuite/ld-elf/local1.s new file mode 100644 index 0000000..0122efa --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/local1.s @@ -0,0 +1,6 @@ + .globl foo + .protected foo + .type foo,%object + .data +foo: + .long 0 diff --git a/binutils-2.25/ld/testsuite/ld-elf/main.c b/binutils-2.25/ld/testsuite/ld-elf/main.c new file mode 100644 index 0000000..24f9dcc --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/main.c @@ -0,0 +1,8 @@ +#include <stdio.h> + +int +main (void) +{ + printf ("MAIN\n"); + return 0; +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/maxpage1.d b/binutils-2.25/ld/testsuite/ld-elf/maxpage1.d new file mode 100644 index 0000000..f776257 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/maxpage1.d @@ -0,0 +1,9 @@ +#source: maxpage1.s +#ld: -z max-page-size=0x200000 +#readelf: -l --wide +#target: *-*-linux* *-*-gnu* + +#... + LOAD+.*0x200000 + LOAD+.*0x200000 +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/maxpage1.s b/binutils-2.25/ld/testsuite/ld-elf/maxpage1.s new file mode 100644 index 0000000..1a7735a --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/maxpage1.s @@ -0,0 +1,13 @@ + .globl main + .globl start + .globl _start + .globl __start + .text +main: +start: +_start: +__start: + .long 0 + + .data + .long 0 diff --git a/binutils-2.25/ld/testsuite/ld-elf/maxpage2.d b/binutils-2.25/ld/testsuite/ld-elf/maxpage2.d new file mode 100644 index 0000000..7d732eb --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/maxpage2.d @@ -0,0 +1,9 @@ +#source: maxpage1.s +#ld: -z max-page-size=0x100000 +#readelf: -l --wide +#target: *-*-linux* *-*-gnu* + +#... + LOAD+.*0x100000 + LOAD+.*0x100000 +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/maxpage3.t b/binutils-2.25/ld/testsuite/ld-elf/maxpage3.t new file mode 100644 index 0000000..556dcd5 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/maxpage3.t @@ -0,0 +1,7 @@ +SECTIONS +{ + .text : {*(.text)} + . = ALIGN(CONSTANT (MAXPAGESIZE)); + .data : {*(.data)} + /DISCARD/ : {*(*)} +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/maxpage3a.d b/binutils-2.25/ld/testsuite/ld-elf/maxpage3a.d new file mode 100644 index 0000000..7d6f2d8 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/maxpage3a.d @@ -0,0 +1,11 @@ +#source: maxpage1.s +#ld: -z max-page-size=0x10000000 -T maxpage3.t +#readelf: -lS --wide +#target: *-*-linux* *-*-gnu* + +#... + \[[ 0-9]+\] \.data[ \t]+PROGBITS[ \t]+0*10000000[ \t]+[ \t0-9a-f]+WA?.* +#... + LOAD+.*0x10000000 + LOAD+.*0x10000000 +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/maxpage3b.d b/binutils-2.25/ld/testsuite/ld-elf/maxpage3b.d new file mode 100644 index 0000000..4bee0ec --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/maxpage3b.d @@ -0,0 +1,10 @@ +#source: maxpage1.s +#ld: -T maxpage3.t -z max-page-size=0x10000000 +#readelf: -lS --wide +#target: x86_64-*-linux* + +#... + \[[ 0-9]+\] \.data[ \t]+PROGBITS[ \t]+0*200000[ \t]+[ \t0-9a-f]+WA?.* +#... + LOAD+.*0x10000000 +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/maxpage3c.d b/binutils-2.25/ld/testsuite/ld-elf/maxpage3c.d new file mode 100644 index 0000000..354a8b9 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/maxpage3c.d @@ -0,0 +1,12 @@ +#source: maxpage1.s +#as: --32 +#ld: -m elf_i386 -z max-page-size=0x10000000 -T maxpage3.t +#readelf: -lS --wide +#target: x86_64-*-linux* i?86-*-linux-gnu i?86-*-gnu* + +#... + \[[ 0-9]+\] \.data[ \t]+PROGBITS[ \t]+0*10000000[ \t]+[ \t0-9a-f]+WA?.* +#... + LOAD+.*0x10000000 + LOAD+.*0x10000000 +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/maxpage4.d b/binutils-2.25/ld/testsuite/ld-elf/maxpage4.d new file mode 100644 index 0000000..a08e856 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/maxpage4.d @@ -0,0 +1,9 @@ +#source: maxpage1.s +#as: --32 +#ld: -z max-page-size=0x200000 -T maxpage4.t +#readelf: -l --wide +#target: x86_64-*-linux* i?86-*-linux-gnu i?86-*-gnu* + +#... + LOAD+.*0x200000 +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/maxpage4.t b/binutils-2.25/ld/testsuite/ld-elf/maxpage4.t new file mode 100644 index 0000000..42089e3 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/maxpage4.t @@ -0,0 +1,9 @@ +OUTPUT_FORMAT("elf32-i386") +OUTPUT_ARCH(i386) +ENTRY(_start) +SECTIONS +{ + .text : {*(.text)} + .data : {*(.data)} + /DISCARD/ : {*(*)} +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/maxpage5.d b/binutils-2.25/ld/testsuite/ld-elf/maxpage5.d new file mode 100644 index 0000000..9d9b57a --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/maxpage5.d @@ -0,0 +1,18 @@ +#source: maxpage5.s +#as: --32 +#ld: -z max-page-size=0x200000 -T maxpage5.t +#objcopy_linked_file: -R .foo +#readelf: -l --wide +#target: x86_64-*-linux* i?86-*-linux-gnu i?86-*-gnu* + +#... +Program Headers: + Type.* + LOAD +0x[0-9a-f]+ .*0x200000 + NOTE +0x[0-9a-f]+ .* + +#... + Segment Sections... + 00[ \t]+.text * + 01[ \t]+.note * +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/maxpage5.s b/binutils-2.25/ld/testsuite/ld-elf/maxpage5.s new file mode 100644 index 0000000..93d6b36 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/maxpage5.s @@ -0,0 +1,8 @@ + .globl _entry + .text +_entry: + .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + .section .foo,"awx",%progbits + .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + .section .note,"",%note + .byte 0 diff --git a/binutils-2.25/ld/testsuite/ld-elf/maxpage5.t b/binutils-2.25/ld/testsuite/ld-elf/maxpage5.t new file mode 100644 index 0000000..7f19343 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/maxpage5.t @@ -0,0 +1,15 @@ +OUTPUT_FORMAT("elf32-i386") +OUTPUT_ARCH(i386) +ENTRY(_entry) +PHDRS +{ + data PT_LOAD; + note PT_NOTE; +} +SECTIONS +{ + .text : { *(.text) } :data + .foo : { *(.foo) } :data + .note : { *(.note) } :note + /DISCARD/ : { *(*) } +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/merge.d b/binutils-2.25/ld/testsuite/ld-elf/merge.d new file mode 100644 index 0000000..c50de10 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/merge.d @@ -0,0 +1,17 @@ +#source: merge.s +#ld: -T merge.ld +#objdump: -s +#xfail: "arc-*-*" "avr-*-*" "bfin-*-*" "cr16-*-*" "cris*-*-*" "crx-*-*" "d10v-*-*" "d30v-*-*" +#xfail: "dlx-*-*" "fr30-*-*" "frv-*-*" "hppa*64*-*-*" "h8300-*-*" "score-*-*" +#xfail: "i370-*-*" "i860-*-*" "i960-*-*" "ip2k-*-*" "iq2000-*-*" "lm32-*-*" +#xfail: "mcore-*-*" "mn102*-*-*" "mips*-*-*" "ms1-*-*" "mep-*-*" +#xfail: "or32-*-*" "pj-*-*" "sparc*-*-*" "tic6x-*-*" "vax-*-*" "xstormy16-*-*" +#xfail: "xtensa*-*-*" "metag-*-*" + +.*: file format .*elf.* + +Contents of section .text: + 1000 (1010)?0000(1010)? (1210)?0000(1012)? (0c)?000000(0c)? (0e)?000000(0e)? .* +Contents of section .rodata: + 1010 61626300 .* +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/merge.ld b/binutils-2.25/ld/testsuite/ld-elf/merge.ld new file mode 100644 index 0000000..dce91bb --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/merge.ld @@ -0,0 +1,7 @@ +SECTIONS +{ + . = 0x1000; + .text : { *(.text .text.* .gnu.linkonce.t.*) } + .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } + .junk : { *(*) } +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/merge.s b/binutils-2.25/ld/testsuite/ld-elf/merge.s new file mode 100644 index 0000000..1e6e0e3 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/merge.s @@ -0,0 +1,14 @@ + .section .rodata.str,"aMS","progbits",1 +.LC0: + .asciz "abc" +.LC1: + .asciz "c" + + .text + .global _start +_start: + .long .LC0 +.LT0: + .long .LC1 + .long .LC0-.LT0 + .long .LC1-.LT0 diff --git a/binutils-2.25/ld/testsuite/ld-elf/merge2.d b/binutils-2.25/ld/testsuite/ld-elf/merge2.d new file mode 100644 index 0000000..4770621 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/merge2.d @@ -0,0 +1,17 @@ +#source: merge2.s +#ld: -T merge.ld +#objdump: -s +#xfail: "arc-*-*" "d30v-*-*" "dlx-*-*" "hppa64-*-*" +#xfail: "i960-*-*" "ip2k-*-*" "or32-*-*" "pj-*-*" + +.*: file format .*elf.* + +Contents of section .text: + 1000 (3010)?0000(1030)? (3210)?0000(1032)? (3110)?0000(1031)? (3410)?0000(1034)? .* + 1010 (4010)?0000(1040)? (3810)?0000(1038)? (4810)?0000(1048)? (3c10)?0000(103c)? .* + 1020 (5010)?0000(1050)? (5410)?0000(1054)? (5810)?0000(1058)? (5010)?0000(1050)? .* +Contents of section .rodata: + 1030 61626300 62000000 (78563412|12345678) 99999999 .* + 1040 (78563412|12345678) 00000000 99999999 00000000 .* + 1050 (78563412|12345678) 99999999 00000000 .* +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/merge2.s b/binutils-2.25/ld/testsuite/ld-elf/merge2.s new file mode 100644 index 0000000..41d066a --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/merge2.s @@ -0,0 +1,58 @@ + .section .rodata.str,"aMS","progbits",1 +.LC0: + .asciz "abc" +.LC1: + .asciz "c" +.LC2: + .asciz "bc" +.LC3: + .asciz "b" + + + .section .rodata.str2,"aMS","progbits",4 + .p2align 2 +.LC4: + .long 0x12345678 + .long 0 +.LC5: + .long 0x12345678 + .long 0x99999999 + .long 0x12345678 + .long 0 +.LC6: + .long 0x99999999 + .long 0 +.LC7: + .long 0x99999999 + .long 0x12345678 + .long 0 + + + .section .rodata.m,"aM","progbits",4 + .p2align 2 +.LC8: + .long 0x12345678 +.LC9: + .long 0x99999999 +.LC10: + .long 0 +.LC11: + .long 0x12345678 + + + .text + .global _start +_start: + .long .LC0 +.LT0: + .long .LC1 + .long .LC2 + .long .LC3 + .long .LC4 + .long .LC5 + .long .LC6 + .long .LC7 + .long .LC8 + .long .LC9 + .long .LC10 + .long .LC11 diff --git a/binutils-2.25/ld/testsuite/ld-elf/multibss1.d b/binutils-2.25/ld/testsuite/ld-elf/multibss1.d new file mode 100644 index 0000000..89b94ad --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/multibss1.d @@ -0,0 +1,11 @@ +#source: multibss1.s +#ld: -e 0 +#readelf: -l --wide +#target: *-*-linux* *-*-gnu* +#xfail: hppa64-*-* +# hppa64 default script add 16 bytes at start of .data giving 0x500010 p_memsz + +#... + +LOAD +0x[^ ]+ +0x[^ ]+ +0x[^ ]+ +0x[^ ]+ +0x500000 .* +# p_offset p_vaddr p_paddr p_filesz +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/multibss1.s b/binutils-2.25/ld/testsuite/ld-elf/multibss1.s new file mode 100644 index 0000000..94b84f9 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/multibss1.s @@ -0,0 +1,11 @@ + .macro makebss + .section .bss_\@,"aw",%nobits + .space 0x10000 + .endm + + .rept 80 + makebss + .endr + + .text + .space 0x10 diff --git a/binutils-2.25/ld/testsuite/ld-elf/needed1.out b/binutils-2.25/ld/testsuite/ld-elf/needed1.out new file mode 100644 index 0000000..2c94e48 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/needed1.out @@ -0,0 +1,2 @@ +OK +OK diff --git a/binutils-2.25/ld/testsuite/ld-elf/needed1a.c b/binutils-2.25/ld/testsuite/ld-elf/needed1a.c new file mode 100644 index 0000000..8b23ec8 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/needed1a.c @@ -0,0 +1,7 @@ +extern void bar (void); + +void +foo (void) +{ + bar (); +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/needed1b.c b/binutils-2.25/ld/testsuite/ld-elf/needed1b.c new file mode 100644 index 0000000..1b9b393 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/needed1b.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +void +bar (void) +{ + printf ("OK\n"); +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/needed1c.c b/binutils-2.25/ld/testsuite/ld-elf/needed1c.c new file mode 100644 index 0000000..e03c380 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/needed1c.c @@ -0,0 +1,10 @@ +extern void foo (void); +extern void bar (void); + +int +main () +{ + foo (); + bar (); + return 0; +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/new.cc b/binutils-2.25/ld/testsuite/ld-elf/new.cc new file mode 100644 index 0000000..513cf2f --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/new.cc @@ -0,0 +1,47 @@ +#include <new> + +using std::bad_alloc; + +extern "C" void *malloc (std::size_t); +extern "C" void abort (void); + +void * +operator new (std::size_t sz, const std::nothrow_t&) throw() +{ + void *p; + + /* malloc (0) is unpredictable; avoid it. */ + if (sz == 0) + sz = 1; + p = (void *) malloc (sz); + return p; +} + +void * +operator new (std::size_t sz) throw (std::bad_alloc) +{ + void *p; + + /* malloc (0) is unpredictable; avoid it. */ + if (sz == 0) + sz = 1; + p = (void *) malloc (sz); + while (p == 0) + { + ::abort(); + } + + return p; +} + +void* +operator new[] (std::size_t sz) throw (std::bad_alloc) +{ + return ::operator new(sz); +} + +void * +operator new[] (std::size_t sz, const std::nothrow_t& nothrow) throw() +{ + return ::operator new(sz, nothrow); +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/nobits-1.d b/binutils-2.25/ld/testsuite/ld-elf/nobits-1.d new file mode 100644 index 0000000..89f0e10 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/nobits-1.d @@ -0,0 +1,9 @@ +#ld: -Tnobits-1.t +#readelf: -l --wide +#xfail: hppa64-*-* +# hppa64 adds PHDR + +#... + Section to Segment mapping: + Segment Sections... + 00 .foo .bar diff --git a/binutils-2.25/ld/testsuite/ld-elf/nobits-1.s b/binutils-2.25/ld/testsuite/ld-elf/nobits-1.s new file mode 100644 index 0000000..8fb1365 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/nobits-1.s @@ -0,0 +1,6 @@ + .globl _entry + .section .foo,"awx",%progbits +_entry: + .byte 0 + .section .bar,"ax",%nobits + .byte 0 diff --git a/binutils-2.25/ld/testsuite/ld-elf/nobits-1.t b/binutils-2.25/ld/testsuite/ld-elf/nobits-1.t new file mode 100644 index 0000000..2004330 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/nobits-1.t @@ -0,0 +1,13 @@ +ENTRY(_entry) +PHDRS +{ + data PT_LOAD; +} +SECTIONS +{ + . = 0x1000000; + .foo : { *(.foo) } :data + . = 0x2000000; + .bar : { *(.bar) } :data + /DISCARD/ : { *(*) } +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/noload-1.d b/binutils-2.25/ld/testsuite/ld-elf/noload-1.d new file mode 100644 index 0000000..7cae479 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/noload-1.d @@ -0,0 +1,7 @@ +#source: noload-1.s +#ld: -T noload-1.t +#readelf: -S --wide + +#... + \[[ 0-9]+\] TEST[ \t]+NOBITS[ \t0-9a-f]+WA.* +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/noload-1.s b/binutils-2.25/ld/testsuite/ld-elf/noload-1.s new file mode 100644 index 0000000..ad0479e --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/noload-1.s @@ -0,0 +1,2 @@ + .section TEST,"aw",%progbits + .byte 0 diff --git a/binutils-2.25/ld/testsuite/ld-elf/noload-1.t b/binutils-2.25/ld/testsuite/ld-elf/noload-1.t new file mode 100644 index 0000000..1efd06c --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/noload-1.t @@ -0,0 +1,8 @@ +SECTIONS +{ + TEST (NOLOAD) : + { + *(TEST) + } + /DISCARD/ : { *(.*) } +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/noload-2.d b/binutils-2.25/ld/testsuite/ld-elf/noload-2.d new file mode 100644 index 0000000..0e25d9b --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/noload-2.d @@ -0,0 +1,8 @@ +#source: noload-1.s +#ld: -T noload-1.t -z max-page-size=0x200000 +#readelf: -Sl --wide +#target: *-*-linux* *-*-gnu* + +#... + +LOAD +0x200000 +0x0+ +0x0+ +0x0+ +0x0+1 +RW +0x200000 +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/noload-3.d b/binutils-2.25/ld/testsuite/ld-elf/noload-3.d new file mode 100644 index 0000000..84b27d7 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/noload-3.d @@ -0,0 +1,7 @@ +#ld: -T noload-3.t +#objdump: -s -j .foo1 + +#... +Contents of section .foo1: + [0-9a-f]+ [0-9a-f]+ [0-9a-f]+ [0-9a-f]+ [0-9a-f]+[ \t]+This is a test.* +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/noload-3.s b/binutils-2.25/ld/testsuite/ld-elf/noload-3.s new file mode 100644 index 0000000..84aa2e2 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/noload-3.s @@ -0,0 +1,6 @@ + .section .foo2,"aw",%progbits + .byte 1 + .section .foo1,"w",%progbits + .string "This is a test." + .section .foo,"aw",%progbits + .space 16 diff --git a/binutils-2.25/ld/testsuite/ld-elf/noload-3.t b/binutils-2.25/ld/testsuite/ld-elf/noload-3.t new file mode 100644 index 0000000..fbb5166 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/noload-3.t @@ -0,0 +1,7 @@ +SECTIONS +{ + .foo2 : { *(.foo2) } + .foo1 : { *(.foo1) } + .foo (NOLOAD) : { *(.foo) } + /DISCARD/ : { *(*) } +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/normal.out b/binutils-2.25/ld/testsuite/ld-elf/normal.out new file mode 100644 index 0000000..3b721f0 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/normal.out @@ -0,0 +1,3 @@ +TEST1 +TEST1 +MAIN diff --git a/binutils-2.25/ld/testsuite/ld-elf/note-1.d b/binutils-2.25/ld/testsuite/ld-elf/note-1.d new file mode 100644 index 0000000..345a2bb --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/note-1.d @@ -0,0 +1,10 @@ +#ld: -Tnote-1.t +#readelf: -l --wide +#xfail: hppa64-*-* +# hppa64 adds PHDR + +#... + Section to Segment mapping: + Segment Sections... + 00 .foo + 01 .note diff --git a/binutils-2.25/ld/testsuite/ld-elf/note-1.s b/binutils-2.25/ld/testsuite/ld-elf/note-1.s new file mode 100644 index 0000000..844188b --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/note-1.s @@ -0,0 +1,6 @@ + .globl _entry + .section .foo,"awx",%progbits +_entry: + .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + .section .note,"",%note + .byte 0 diff --git a/binutils-2.25/ld/testsuite/ld-elf/note-1.t b/binutils-2.25/ld/testsuite/ld-elf/note-1.t new file mode 100644 index 0000000..031fe82 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/note-1.t @@ -0,0 +1,14 @@ +ENTRY(_entry) +PHDRS +{ + data PT_LOAD; + note PT_NOTE; +} +SECTIONS +{ + . = 0x1000000; + .foo : { *(.foo) } :data + . = 0x2000000; + .note : { *(.note) } :note + /DISCARD/ : { *(*) } +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/note-2.d b/binutils-2.25/ld/testsuite/ld-elf/note-2.d new file mode 100644 index 0000000..289134e --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/note-2.d @@ -0,0 +1,17 @@ +#ld: -Tnote-2.t +#objcopy_linked_file: -R .foo +#readelf: -l --wide +#xfail: hppa64-*-* +# hppa64 adds PHDR + +#... +Program Headers: + Type.* + LOAD +0x[0-9a-f]+ .* + NOTE +0x[0-9a-f]+ .* + +#... + Segment Sections... + 00[ \t]+.text * + 01[ \t]+.note * +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/note-2.s b/binutils-2.25/ld/testsuite/ld-elf/note-2.s new file mode 100644 index 0000000..93d6b36 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/note-2.s @@ -0,0 +1,8 @@ + .globl _entry + .text +_entry: + .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + .section .foo,"awx",%progbits + .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + .section .note,"",%note + .byte 0 diff --git a/binutils-2.25/ld/testsuite/ld-elf/note-2.t b/binutils-2.25/ld/testsuite/ld-elf/note-2.t new file mode 100644 index 0000000..a507da9 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/note-2.t @@ -0,0 +1,13 @@ +ENTRY(_entry) +PHDRS +{ + data PT_LOAD; + note PT_NOTE; +} +SECTIONS +{ + .text : { *(.text) } :data + .foo : { *(.foo) } :data + .note : { *(.note) } :note + /DISCARD/ : { *(*) } +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/note-3.l b/binutils-2.25/ld/testsuite/ld-elf/note-3.l new file mode 100644 index 0000000..551ebaa --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/note-3.l @@ -0,0 +1,2 @@ +.*warning: section '.hash' is being made into a note +.* diff --git a/binutils-2.25/ld/testsuite/ld-elf/note-3.s b/binutils-2.25/ld/testsuite/ld-elf/note-3.s new file mode 100644 index 0000000..3a1d190 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/note-3.s @@ -0,0 +1,10 @@ + .globl _entry + .text +_entry: + .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + .global foo +foo: + .byte 9 + + .section .note,"",%note + .byte 0 diff --git a/binutils-2.25/ld/testsuite/ld-elf/note-3.t b/binutils-2.25/ld/testsuite/ld-elf/note-3.t new file mode 100644 index 0000000..13324ae --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/note-3.t @@ -0,0 +1,22 @@ +PHDRS +{ + text PT_LOAD FILEHDR PHDRS ; + note PT_NOTE; +} +SECTIONS +{ + . = . + SIZEOF_HEADERS ; + .text : { *(.text) *(.rodata) } :text + .note : { *(.note) } :note :text + + /* BUG: This linker script is broken here. It has not reset the + output segment for the following sections, so they are all + treated as notes... */ + + .hash : { *(.hash) } + + .dynstr : { *(.dynstr) } + .dynsym : { *(.dynsym) } + .got.plt : { *(.got.plt) *(.igot.plt) } + /DISCARD/ : { *(*) } +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/now-1.d b/binutils-2.25/ld/testsuite/ld-elf/now-1.d new file mode 100644 index 0000000..9c7d5fa --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/now-1.d @@ -0,0 +1,9 @@ +#source: start.s +#readelf: -d -W +#ld: -shared -z now --enable-new-dtags +#target: *-*-linux* *-*-gnu* + +#failif +#... + 0x[0-9a-f]+ +\(BIND_NOW\) + +#... diff --git a/binutils-2.25/ld/testsuite/ld-elf/now-2.d b/binutils-2.25/ld/testsuite/ld-elf/now-2.d new file mode 100644 index 0000000..1430bc4 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/now-2.d @@ -0,0 +1,8 @@ +#source: start.s +#readelf: -d -W +#ld: -shared -z now --enable-new-dtags +#target: *-*-linux* *-*-gnu* + +#... + 0x[0-9a-f]+ +\(FLAGS\) +BIND_NOW +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/now-3.d b/binutils-2.25/ld/testsuite/ld-elf/now-3.d new file mode 100644 index 0000000..687885a --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/now-3.d @@ -0,0 +1,9 @@ +#source: start.s +#readelf: -d -W +#ld: -shared -z now +#target: *-*-linux* *-*-gnu* + +#failif +#... + 0x[0-9a-f]+ +\(FLAGS\) +BIND_NOW +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/now-4.d b/binutils-2.25/ld/testsuite/ld-elf/now-4.d new file mode 100644 index 0000000..8d9d02f --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/now-4.d @@ -0,0 +1,8 @@ +#source: start.s +#readelf: -d -W +#ld: -shared -z now +#target: *-*-linux* *-*-gnu* + +#... + 0x[0-9a-f]+ +\(BIND_NOW\) + +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/orphan-region.d b/binutils-2.25/ld/testsuite/ld-elf/orphan-region.d new file mode 100644 index 0000000..bf65356 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/orphan-region.d @@ -0,0 +1,21 @@ +#source: orphan-region.s +#ld: -T orphan-region.ld -N -z stack-size=0 +#readelf: -S -l --wide +#xfail: arc-*-* d30v-*-* dlx-*-* fr30-*-* frv-*-elf i860-*-* i960-*-* +#xfail: iq*-*-* mn10200-*-* moxie-*-* msp*-*-* mt-*-* or32-*-* pj*-*-* +#xfail: spu-*-* hppa*64*-*-* *-*-nacl* +# if not using elf32.em, you don't get fancy orphan handling +# spu twiddles LOAD range, hppa64 adds PHDR, nacl splits to two segments + +#... + \[[ 0-9]+\] \.text[ \t]+PROGBITS[ \t]+0*40000000[ \t]+.* + \[[ 0-9]+\] \.rodata[ \t]+PROGBITS[ \t]+0*400000[0-9a-f]+[ \t]+.* + \[[ 0-9]+\] \.moredata[ \t]+PROGBITS[ \t]+0*400000[0-9a-f]+[ \t]+.* +#... +Program Headers: + Type.* + LOAD[ \t]+0x[0-9a-f]+ 0x0*40000000 0x0*40000000 0x[0-9a-f]+ 0x[0-9a-f]+ RWE 0x[0-9a-f]+ + + Section to Segment mapping: + Segment Sections... + 00 .text .rodata .moredata * diff --git a/binutils-2.25/ld/testsuite/ld-elf/orphan-region.ld b/binutils-2.25/ld/testsuite/ld-elf/orphan-region.ld new file mode 100644 index 0000000..b7dfdba --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/orphan-region.ld @@ -0,0 +1,11 @@ +MEMORY +{ + region : ORIGIN = 0x40000000, LENGTH = 8M +} + +SECTIONS +{ + .text : ALIGN (4) { *(.text) } > region + .rodata : ALIGN (4) { *(.rodata) } > region + /DISCARD/ : { *(.reginfo) *(.trampolines) } +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/orphan-region.s b/binutils-2.25/ld/testsuite/ld-elf/orphan-region.s new file mode 100644 index 0000000..0268686 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/orphan-region.s @@ -0,0 +1,8 @@ + .text + .long 0 + .section ".rodata", "a", %progbits + .long 0 + .section ".moredata", "a", %progbits + .long 0 + .section ".notdata", "", %progbits + .long 0 diff --git a/binutils-2.25/ld/testsuite/ld-elf/orphan.d b/binutils-2.25/ld/testsuite/ld-elf/orphan.d new file mode 100644 index 0000000..7955c8b --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/orphan.d @@ -0,0 +1,16 @@ +#source: orphan.s +#ld: -T orphan.ld +#readelf: -S --wide +#xfail: arc-*-* d30v-*-* dlx-*-* fr30-*-* frv-*-elf i860-*-* i960-*-* +#xfail: iq*-*-* mn10200-*-* moxie-*-* msp*-*-* mt-*-* or32-*-* pj*-*-* +# if not using elf32.em, you don't get fancy orphan handling + +#... + \[[ 0-9]+\] \.(text|notbad)[ \t]+PROGBITS[ \t0-9a-f]+AX?.* +#... + \[[ 0-9]+\] \.(text|notbad)[ \t]+PROGBITS[ \t0-9a-f]+AX?.* + \[[ 0-9]+\] \.data[ \t]+PROGBITS[ \t0-9a-f]+WA.* +#... + \[[ 0-9]+\] \.note[ \t]+NOTE[ \t0-9a-f]+A.* + \[[ 0-9]+\] \.note.bar[ \t]+NOTE[ \t0-9a-f]+A.* +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/orphan.ld b/binutils-2.25/ld/testsuite/ld-elf/orphan.ld new file mode 100644 index 0000000..d23222b --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/orphan.ld @@ -0,0 +1,8 @@ +SECTIONS +{ + .text : { *(.text) } + .data : { *(.data) } + .bss : { *(.bss) *(COMMON) } + .note : { *(.note) } + /DISCARD/ : { *(.reginfo) *(.trampolines) } +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/orphan.s b/binutils-2.25/ld/testsuite/ld-elf/orphan.s new file mode 100644 index 0000000..d46f21d --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/orphan.s @@ -0,0 +1,10 @@ + .text + .long 0 + .data + .long 0 + .section .note,"a","note" + .long 0 + .section .notbad,"a","progbits" + .long 0 + .section .note.bar,"a","note" + .long 0 diff --git a/binutils-2.25/ld/testsuite/ld-elf/orphan2.d b/binutils-2.25/ld/testsuite/ld-elf/orphan2.d new file mode 100644 index 0000000..ddf69c7 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/orphan2.d @@ -0,0 +1,11 @@ +#source: orphan2.s +#ld: -r +#readelf: -S --wide +#xfail: xstormy*-*-* +# xstormy uses a non-standard script, resulting is unexpected section order + +#... + \[[ 0-9]+\] \.text[ \t]+PROGBITS[ \t0-9a-f]+AX?.* +#... + \[[ 0-9]+\] \.modinfo[ \t]+PROGBITS[ \t0-9a-f]+A.* +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/orphan2.s b/binutils-2.25/ld/testsuite/ld-elf/orphan2.s new file mode 100644 index 0000000..bed8dcd --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/orphan2.s @@ -0,0 +1,4 @@ + .text + .long 0 + .section .modinfo,"a","progbits" + .long 0 diff --git a/binutils-2.25/ld/testsuite/ld-elf/orphan3.d b/binutils-2.25/ld/testsuite/ld-elf/orphan3.d new file mode 100644 index 0000000..ea600d3 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/orphan3.d @@ -0,0 +1,21 @@ +#source: orphan3a.s +#source: orphan3b.s +#source: orphan3c.s +#source: orphan3d.s +#source: orphan3e.s +#source: orphan3f.s +#ld: +#readelf: -S --wide +#xfail: "arc-*-*" "d30v-*-*" "dlx-*-*" "fr30-*-*" "frv-*-elf" +#xfail: "i860-*-*" "i960-*-*" "iq2000-*-*" "mn10200-*-*" "msp430-*-*" "mt-*-*" +#xfail: "or32-*-*" "pj-*-*" +#xfail: "xstormy16-*-*" + +#... + \[[ 0-9]+\] \.foo +PROGBITS +[0-9a-f]+ +[0-9a-f]+ +0+20 +0+ +A +0 +0 +[0-9]+ +#... + \[[ 0-9]+\] \.foo +NOBITS +[0-9a-f]+ +[0-9a-f]+ +0+20 +0+ +A +0 +0 +[0-9]+ +#... + \[[ 0-9]+\] \.foo +PROGBITS +0+ +[0-9a-f]+ +0+20 +0+ +0 +0 +[0-9]+ + \[[ 0-9]+\] [._][^f].* +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/orphan3a.s b/binutils-2.25/ld/testsuite/ld-elf/orphan3a.s new file mode 100644 index 0000000..bc3023b --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/orphan3a.s @@ -0,0 +1,12 @@ + .globl main + .globl start + .globl _start + .globl __start + .text +main: +start: +_start: +__start: + + .section .foo,"a",%nobits + .space 16 diff --git a/binutils-2.25/ld/testsuite/ld-elf/orphan3b.s b/binutils-2.25/ld/testsuite/ld-elf/orphan3b.s new file mode 100644 index 0000000..c475eb1 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/orphan3b.s @@ -0,0 +1,2 @@ + .section .foo,"a",%progbits + .long 1,1,1,1 diff --git a/binutils-2.25/ld/testsuite/ld-elf/orphan3c.s b/binutils-2.25/ld/testsuite/ld-elf/orphan3c.s new file mode 100644 index 0000000..209570c --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/orphan3c.s @@ -0,0 +1,2 @@ + .section .foo,"",%progbits + .long 2,2,2,2 diff --git a/binutils-2.25/ld/testsuite/ld-elf/orphan3d.s b/binutils-2.25/ld/testsuite/ld-elf/orphan3d.s new file mode 100644 index 0000000..7f57443 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/orphan3d.s @@ -0,0 +1,2 @@ + .section .foo,"a",%nobits + .space 16 diff --git a/binutils-2.25/ld/testsuite/ld-elf/orphan3e.s b/binutils-2.25/ld/testsuite/ld-elf/orphan3e.s new file mode 100644 index 0000000..405d9e2 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/orphan3e.s @@ -0,0 +1,2 @@ + .section .foo,"a",%progbits + .long 4,4,4,4 diff --git a/binutils-2.25/ld/testsuite/ld-elf/orphan3f.s b/binutils-2.25/ld/testsuite/ld-elf/orphan3f.s new file mode 100644 index 0000000..3ef1b9e --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/orphan3f.s @@ -0,0 +1,2 @@ + .section .foo,"",%progbits + .long 5,5,5,5 diff --git a/binutils-2.25/ld/testsuite/ld-elf/orphan4.d b/binutils-2.25/ld/testsuite/ld-elf/orphan4.d new file mode 100644 index 0000000..72d77d6 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/orphan4.d @@ -0,0 +1,7 @@ +#source: orphan4.s +#ld: -T orphan4.ld +#objdump: -h + +#... + . \.foo 0+1 0+1000 0+1000 .* 2\*\*0 +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/orphan4.ld b/binutils-2.25/ld/testsuite/ld-elf/orphan4.ld new file mode 100644 index 0000000..ab9bc9c --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/orphan4.ld @@ -0,0 +1,13 @@ +/* The .foo section doesn't specify *any* objects, but the object + we're linking has sections named ".foo". Make sure these sections + are linked into the .foo output section anyway. The bug that was + fixed was that a new .foo output section would be created at + address 0. */ + +SECTIONS { + .foo 0x00001000 : { + } + .text 0x00002000 : { + *(.text); + } +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/orphan4.s b/binutils-2.25/ld/testsuite/ld-elf/orphan4.s new file mode 100644 index 0000000..1f07646 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/orphan4.s @@ -0,0 +1,4 @@ + .section ".foo", "ax" + .byte 45 + .text + .byte 15 diff --git a/binutils-2.25/ld/testsuite/ld-elf/overlay.d b/binutils-2.25/ld/testsuite/ld-elf/overlay.d new file mode 100644 index 0000000..00d25d5 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/overlay.d @@ -0,0 +1,12 @@ +# ld: -T overlay.t -u __load_start_text1 -u __load_start_text2 -u __load_stop_text1 -u __load_stop_text2 +#readelf: -s + +#... +[ ]+[0-9]+:[ ]+0*4000[ ]+0[ ]+NOTYPE[ ]+GLOBAL[ ]+DEFAULT[ ]+ABS __load_start_text1 +#... +[ ]+[0-9]+:[ ]+0*4010[ ]+0[ ]+NOTYPE[ ]+GLOBAL[ ]+DEFAULT[ ]+ABS __load_start_text2 +#... +[ ]+[0-9]+:[ ]+0*4030[ ]+0[ ]+NOTYPE[ ]+GLOBAL[ ]+DEFAULT[ ]+ABS __load_stop_text2 +#... +[ ]+[0-9]+:[ ]+0*4010[ ]+0[ ]+NOTYPE[ ]+GLOBAL[ ]+DEFAULT[ ]+ABS __load_stop_text1 +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/overlay.s b/binutils-2.25/ld/testsuite/ld-elf/overlay.s new file mode 100644 index 0000000..f153044 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/overlay.s @@ -0,0 +1,6 @@ + .section .text1,"ax",%progbits + .space 0x10 + .section .text2,"ax",%progbits + .space 0x20 + .text + .space 0x30 diff --git a/binutils-2.25/ld/testsuite/ld-elf/overlay.t b/binutils-2.25/ld/testsuite/ld-elf/overlay.t new file mode 100644 index 0000000..bdb33c8 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/overlay.t @@ -0,0 +1,10 @@ +SECTIONS +{ + .text : { *(.text) } + OVERLAY 0x1000 : AT (0x4000) + { + .text1 {*(.text1)} + .text2 {*(.text2)} + } + /DISCARD/ : { *(.*) } +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/pass.out b/binutils-2.25/ld/testsuite/ld-elf/pass.out new file mode 100644 index 0000000..7ef22e9 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pass.out @@ -0,0 +1 @@ +PASS diff --git a/binutils-2.25/ld/testsuite/ld-elf/pr11138-1.c b/binutils-2.25/ld/testsuite/ld-elf/pr11138-1.c new file mode 100644 index 0000000..2aab815 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pr11138-1.c @@ -0,0 +1,13 @@ +#include <stdio.h> + +void +bar (void) +{ + printf ("DSO bar\n"); +} + +void +foo (void) +{ + bar (); +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/pr11138-1.map b/binutils-2.25/ld/testsuite/ld-elf/pr11138-1.map new file mode 100644 index 0000000..8676b1f --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pr11138-1.map @@ -0,0 +1,4 @@ +VERS_1 { + global: bar; foo; + local: *; +}; diff --git a/binutils-2.25/ld/testsuite/ld-elf/pr11138-2.c b/binutils-2.25/ld/testsuite/ld-elf/pr11138-2.c new file mode 100644 index 0000000..ccca280 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pr11138-2.c @@ -0,0 +1,17 @@ +#include <stdio.h> + +extern void foo (void); + +void +bar (void) +{ + printf ("MAIN bar\n"); +} + +int +main (void) +{ + bar (); + foo (); + return 0; +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/pr11138-2.map b/binutils-2.25/ld/testsuite/ld-elf/pr11138-2.map new file mode 100644 index 0000000..1f8fb15 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pr11138-2.map @@ -0,0 +1,4 @@ +{ + global: main; + local: *; +}; diff --git a/binutils-2.25/ld/testsuite/ld-elf/pr11138.out b/binutils-2.25/ld/testsuite/ld-elf/pr11138.out new file mode 100644 index 0000000..6dbdc49 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pr11138.out @@ -0,0 +1,2 @@ +MAIN bar +DSO bar diff --git a/binutils-2.25/ld/testsuite/ld-elf/pr11304.d b/binutils-2.25/ld/testsuite/ld-elf/pr11304.d new file mode 100644 index 0000000..d0b8408 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pr11304.d @@ -0,0 +1,11 @@ +#source: pr11304a.s +#source: pr11304b.s +#ld: -e 0 --section-start .zzz=0x800000 +#readelf: -S --wide + +#failif +#... + \[[ 0-9]+\] \.zzz[ \t]+PROGBITS[ \t0-9a-f]+AX?.* +#... + \[[ 0-9]+\] \.zzz[ \t]+PROGBITS[ \t0-9a-f]+AX?.* +#... diff --git a/binutils-2.25/ld/testsuite/ld-elf/pr11304a.s b/binutils-2.25/ld/testsuite/ld-elf/pr11304a.s new file mode 100644 index 0000000..75fcd37 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pr11304a.s @@ -0,0 +1,4 @@ + .section .zzz,"ax",%progbits + .long 0 + .text + .long 0 diff --git a/binutils-2.25/ld/testsuite/ld-elf/pr11304b.s b/binutils-2.25/ld/testsuite/ld-elf/pr11304b.s new file mode 100644 index 0000000..75fcd37 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pr11304b.s @@ -0,0 +1,4 @@ + .section .zzz,"ax",%progbits + .long 0 + .text + .long 0 diff --git a/binutils-2.25/ld/testsuite/ld-elf/pr12851.d b/binutils-2.25/ld/testsuite/ld-elf/pr12851.d new file mode 100644 index 0000000..fb61c5a --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pr12851.d @@ -0,0 +1,11 @@ +#source: pr12851.s +#source: start.s +#ld: --gc-sections +#readelf: -s --wide +#notarget: arc-*-* d30v-*-* dlx-*-* i960-*-* or32-*-* pj*-*-* +#notarget: hppa64-*-* i370-*-* i860-*-* ia64-*-* mep-*-* mn10200-*-* +# generic linker targets don't support --gc-sections, nor do a bunch of others + +#... + +.* _.stapsdt.base +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/pr12851.s b/binutils-2.25/ld/testsuite/ld-elf/pr12851.s new file mode 100644 index 0000000..784b91f --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pr12851.s @@ -0,0 +1,5 @@ + .section .note.stapsdt,"?","note" + .dc.a _.stapsdt.base + .section .stapsdt.base,"a","progbits" +_.stapsdt.base: .space 1 + .size _.stapsdt.base,1 diff --git a/binutils-2.25/ld/testsuite/ld-elf/pr12975.d b/binutils-2.25/ld/testsuite/ld-elf/pr12975.d new file mode 100644 index 0000000..b361cc2 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pr12975.d @@ -0,0 +1,11 @@ +#ld: --gc-sections -shared -version-script pr12975.t +#readelf: -s --wide +#target: *-*-linux* *-*-gnu* +#notarget: arc-*-* d30v-*-* dlx-*-* i960-*-* or32-*-* pj*-*-* +#notarget: hppa64-*-* i370-*-* i860-*-* ia64-*-* mep-*-* mn10200-*-* +# generic linker targets don't support --gc-sections, nor do a bunch of others + +#failif +#... + +[0-9]+: +[0-9a-f]+ +[0-9]+ +FUNC +LOCAL +DEFAULT +[1-9]+ bar +#... diff --git a/binutils-2.25/ld/testsuite/ld-elf/pr12975.s b/binutils-2.25/ld/testsuite/ld-elf/pr12975.s new file mode 100644 index 0000000..7429121 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pr12975.s @@ -0,0 +1,10 @@ + .section .text.foo,"ax",%progbits + .globl foo + .type foo, %function +foo: + .byte 0 + .section .text.bar,"ax",%progbits + .type bar, %function + .globl bar +bar: + .byte 0 diff --git a/binutils-2.25/ld/testsuite/ld-elf/pr12975.t b/binutils-2.25/ld/testsuite/ld-elf/pr12975.t new file mode 100644 index 0000000..902c1f7 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pr12975.t @@ -0,0 +1,6 @@ +{ +global: + foo; +local: + *; +}; diff --git a/binutils-2.25/ld/testsuite/ld-elf/pr13177.d b/binutils-2.25/ld/testsuite/ld-elf/pr13177.d new file mode 100644 index 0000000..e56e865 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pr13177.d @@ -0,0 +1,12 @@ +#source: pr13177.s +#ld: --gc-sections -shared +#readelf: -s -D --wide +#target: *-*-linux* *-*-gnu* +#notarget: arc-*-* d30v-*-* dlx-*-* i960-*-* or32-*-* pj*-*-* +#notarget: hppa64-*-* i370-*-* i860-*-* ia64-*-* mep-*-* mn10200-*-* +# generic linker targets don't support --gc-sections, nor do a bunch of others + +#failif +#... +.*: 0+0 +0 +NOTYPE +GLOBAL +DEFAULT +UND bar +#... diff --git a/binutils-2.25/ld/testsuite/ld-elf/pr13177.s b/binutils-2.25/ld/testsuite/ld-elf/pr13177.s new file mode 100644 index 0000000..d7caad3 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pr13177.s @@ -0,0 +1,9 @@ + .section .text.foo,"ax",%progbits + .globl foo + .type foo, %function +foo: + .byte 0 + .section .data.opt_out,"aw",%progbits + .type opt_out, %object +opt_out: + .dc.a bar diff --git a/binutils-2.25/ld/testsuite/ld-elf/pr13195.c b/binutils-2.25/ld/testsuite/ld-elf/pr13195.c new file mode 100644 index 0000000..a9bce4a --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pr13195.c @@ -0,0 +1,5 @@ +int +main () +{ + return 0; +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/pr13195.d b/binutils-2.25/ld/testsuite/ld-elf/pr13195.d new file mode 100644 index 0000000..796102b --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pr13195.d @@ -0,0 +1,10 @@ +#ld: --gc-sections -shared -version-script pr13195.t +#readelf: -s --wide -D +#target: *-*-linux* *-*-gnu* +#notarget: arc-*-* d30v-*-* dlx-*-* i960-*-* or32-*-* pj*-*-* +#notarget: hppa64-*-* i370-*-* i860-*-* ia64-*-* mep-*-* mn10200-*-* +# generic linker targets don't support --gc-sections, nor do a bunch of others + +#... + +[0-9]+ +[0-9]+: +[0-9a-f]+ +[0-9]+ +FUNC +GLOBAL +DEFAULT +[1-9]+ foo +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/pr13195.s b/binutils-2.25/ld/testsuite/ld-elf/pr13195.s new file mode 100644 index 0000000..409b5af --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pr13195.s @@ -0,0 +1,6 @@ + .section .text.new_foo,"ax",%progbits + .globl new_foo + .type new_foo, %function +new_foo: + .byte 0 + .symver new_foo,foo@@VERS_2.0 diff --git a/binutils-2.25/ld/testsuite/ld-elf/pr13195.t b/binutils-2.25/ld/testsuite/ld-elf/pr13195.t new file mode 100644 index 0000000..2b82842 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pr13195.t @@ -0,0 +1,6 @@ +VERS_2.0 { +global: + foo; +local: + *; +}; diff --git a/binutils-2.25/ld/testsuite/ld-elf/pr13250-1.c b/binutils-2.25/ld/testsuite/ld-elf/pr13250-1.c new file mode 100644 index 0000000..e43ebe0 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pr13250-1.c @@ -0,0 +1,8 @@ +int common1[8]; +void +foo () +{ + int i; + for (i = 0; i < sizeof (common1)/ sizeof (common1[0]); i++) + common1[i] = -1; +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/pr13250-2.c b/binutils-2.25/ld/testsuite/ld-elf/pr13250-2.c new file mode 100644 index 0000000..af8268b --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pr13250-2.c @@ -0,0 +1,10 @@ +extern int common1[8]; + +extern void foo (); + +int +bar () +{ + foo (); + return common1[4]; +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/pr13250-3.c b/binutils-2.25/ld/testsuite/ld-elf/pr13250-3.c new file mode 100644 index 0000000..a227670 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pr13250-3.c @@ -0,0 +1,22 @@ +#include <stdio.h> +#include <stdlib.h> + +int common1[1]; +char common2[2]; + +extern int bar (); + +int +main () +{ + int i; + if (bar () != -1) + abort (); + if (common1[0] != -1) + abort (); + for (i = 0; i < sizeof (common2)/ sizeof (common2[0]); i++) + if (common2[i] != 0) + abort (); + printf ("PASS\n"); + return 0; +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/pr13839.d b/binutils-2.25/ld/testsuite/ld-elf/pr13839.d new file mode 100644 index 0000000..fc63a90 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pr13839.d @@ -0,0 +1,6 @@ +#ld: -T pr13839.t +#nm: -n + +#... +[0-9a-f]+ T _text +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/pr13839.s b/binutils-2.25/ld/testsuite/ld-elf/pr13839.s new file mode 100644 index 0000000..3d132f6 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pr13839.s @@ -0,0 +1,10 @@ + .text + .globl main + .globl start + .globl _start + .globl __start +main: +start: +_start: +__start: + .byte 0 diff --git a/binutils-2.25/ld/testsuite/ld-elf/pr13839.t b/binutils-2.25/ld/testsuite/ld-elf/pr13839.t new file mode 100644 index 0000000..6baa228 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pr13839.t @@ -0,0 +1,9 @@ +SECTIONS { + .text : { + _text = .; + *(.text) + } + _end = .; + /DISCARD/ : { *(.*) } +} +. = ASSERT((_end - _text <= (512 * 1024 * 1024)), "foo"); diff --git a/binutils-2.25/ld/testsuite/ld-elf/pr14052.d b/binutils-2.25/ld/testsuite/ld-elf/pr14052.d new file mode 100644 index 0000000..dc893a3 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pr14052.d @@ -0,0 +1,8 @@ +#source: start.s +#ld: -T pr14052.t +#readelf: -s + +#failif +#... + +[0-9]+: +[0-9a-f]+ +0 +(OBJECT|NOTYPE) +GLOBAL +DEFAULT +ABS _data_start +#... diff --git a/binutils-2.25/ld/testsuite/ld-elf/pr14052.t b/binutils-2.25/ld/testsuite/ld-elf/pr14052.t new file mode 100644 index 0000000..360c231 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pr14052.t @@ -0,0 +1,11 @@ +SECTIONS { + .text : { + *(.text) + } + . = ALIGN (0x1000); + .data : { + _data_start = .; + *(.data) + } + /DISCARD/ : { *(.*) } +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/pr14156a.d b/binutils-2.25/ld/testsuite/ld-elf/pr14156a.d new file mode 100644 index 0000000..6476857 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pr14156a.d @@ -0,0 +1,15 @@ +#source: init0.s +#source: init1.s +#source: init2.s +#source: init3.s +#source: initn.s +#ld: --sort-section=alignment +#nm: -n + +#... +[0-9a-f]+ T foo +[0-9a-f]+ t foo1 +[0-9a-f]+ t foo2 +[0-9a-f]+ t foo3 +[0-9a-f]+ t last +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/pr14156b.d b/binutils-2.25/ld/testsuite/ld-elf/pr14156b.d new file mode 100644 index 0000000..ae9fa05 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pr14156b.d @@ -0,0 +1,15 @@ +#source: fini0.s +#source: fini1.s +#source: fini2.s +#source: fini3.s +#source: finin.s +#ld: --sort-section=alignment +#nm: -n + +#... +[0-9a-f]+ T foo +[0-9a-f]+ t foo1 +[0-9a-f]+ t foo2 +[0-9a-f]+ t foo3 +[0-9a-f]+ t last +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/pr14156c.d b/binutils-2.25/ld/testsuite/ld-elf/pr14156c.d new file mode 100644 index 0000000..90ca401 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pr14156c.d @@ -0,0 +1,15 @@ +#source: foo0.s +#source: foo1.s +#source: foo2.s +#source: foo3.s +#source: foon.s +#ld: --sort-section=alignment -T pr14156c.t +#nm: -n + +#... +[0-9a-f]+ T foo +[0-9a-f]+ t foo1 +[0-9a-f]+ t foo2 +[0-9a-f]+ t foo3 +[0-9a-f]+ t last +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/pr14156c.t b/binutils-2.25/ld/testsuite/ld-elf/pr14156c.t new file mode 100644 index 0000000..c8be2c5 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pr14156c.t @@ -0,0 +1,5 @@ +SECTIONS { + .text : { *(.text) } + .foo : { *(SORT_NONE(.foo)) } + /DISCARD/ : { *(.*) } +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/pr14170a.s b/binutils-2.25/ld/testsuite/ld-elf/pr14170a.s new file mode 100644 index 0000000..4264eee --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pr14170a.s @@ -0,0 +1,13 @@ + + .global start /* Used by SH targets. */ +start: + .global _start +_start: + .global __start +__start: + .global main /* Used by HPPA targets. */ +main: + + .data + .dc.a foo + .dc.a bar diff --git a/binutils-2.25/ld/testsuite/ld-elf/pr14170b.s b/binutils-2.25/ld/testsuite/ld-elf/pr14170b.s new file mode 100644 index 0000000..818f975 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pr14170b.s @@ -0,0 +1,11 @@ + .data + .type foo,%object + .globl foo +foo: + .dc.a 0 + .size foo, . - foo + .type foo,%object + .globl bar +bar: + .dc.a 0 + .size bar, . - bar diff --git a/binutils-2.25/ld/testsuite/ld-elf/pr14170c.s b/binutils-2.25/ld/testsuite/ld-elf/pr14170c.s new file mode 100644 index 0000000..a47b67b --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pr14170c.s @@ -0,0 +1,2 @@ + .hidden foo + .comm foo,4,4 diff --git a/binutils-2.25/ld/testsuite/ld-elf/pr14323-1.c b/binutils-2.25/ld/testsuite/ld-elf/pr14323-1.c new file mode 100644 index 0000000..9f63f4c --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pr14323-1.c @@ -0,0 +1,17 @@ +#include <stdlib.h> +#include <stdio.h> + +extern int foo_alias; +extern char *bar (); + +int +main () +{ + if (foo_alias != 0) + abort (); + bar (); + if (foo_alias != -1) + abort (); + printf ("PASS\n"); + return 0; +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/pr14323-2.c b/binutils-2.25/ld/testsuite/ld-elf/pr14323-2.c new file mode 100644 index 0000000..34753d1 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pr14323-2.c @@ -0,0 +1,13 @@ +int foo __attribute__ ((section ("_data_foo"))) = 0; +extern int foo_alias __attribute__ ((weak, alias ("foo"))); +extern char __start__data_foo; +asm (".type __start__data_foo,%object"); +int x1 = 1; +int x2 = 2; + +char * +bar () +{ + foo = -1; + return &__start__data_foo; +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/pr14525.c b/binutils-2.25/ld/testsuite/ld-elf/pr14525.c new file mode 100644 index 0000000..082eb87 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pr14525.c @@ -0,0 +1,11 @@ +#include <stdio.h> + +extern void *__executable_start; + +int +main() +{ + if ((void **) &main >= &__executable_start) + printf ("OK\n"); + return 0; +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/pr14525.out b/binutils-2.25/ld/testsuite/ld-elf/pr14525.out new file mode 100644 index 0000000..d86bac9 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pr14525.out @@ -0,0 +1 @@ +OK diff --git a/binutils-2.25/ld/testsuite/ld-elf/pr14862-1.c b/binutils-2.25/ld/testsuite/ld-elf/pr14862-1.c new file mode 100644 index 0000000..258a834 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pr14862-1.c @@ -0,0 +1,9 @@ +extern void bar () __attribute__((weak)); + +int +main (void) +{ + if (bar) + bar (); + return 0; +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/pr14862-2.c b/binutils-2.25/ld/testsuite/ld-elf/pr14862-2.c new file mode 100644 index 0000000..1b9b393 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pr14862-2.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +void +bar (void) +{ + printf ("OK\n"); +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/pr14862.map b/binutils-2.25/ld/testsuite/ld-elf/pr14862.map new file mode 100644 index 0000000..2947640 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pr14862.map @@ -0,0 +1,4 @@ +VERS_1 { + global: bar; + local: *; +}; diff --git a/binutils-2.25/ld/testsuite/ld-elf/pr14862.out b/binutils-2.25/ld/testsuite/ld-elf/pr14862.out new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pr14862.out diff --git a/binutils-2.25/ld/testsuite/ld-elf/pr14926.d b/binutils-2.25/ld/testsuite/ld-elf/pr14926.d new file mode 100644 index 0000000..148c8b4 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pr14926.d @@ -0,0 +1,8 @@ +#ld: -Ttext=0x60 +#readelf: -S --wide +#notarget: d10v-*-* msp*-*-* xstormy*-*-* +# the above targets use memory regions that don't allow 0x60 for .text + +#... + \[[ 0-9]+\] \.text[ \t]+PROGBITS[ \t]+0*60[ \t]+.* +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/pr14926.s b/binutils-2.25/ld/testsuite/ld-elf/pr14926.s new file mode 100644 index 0000000..3d132f6 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pr14926.s @@ -0,0 +1,10 @@ + .text + .globl main + .globl start + .globl _start + .globl __start +main: +start: +_start: +__start: + .byte 0 diff --git a/binutils-2.25/ld/testsuite/ld-elf/pr349-1.s b/binutils-2.25/ld/testsuite/ld-elf/pr349-1.s new file mode 100644 index 0000000..a205905 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pr349-1.s @@ -0,0 +1,2 @@ + .section ".abcxyz","ax",%progbits + .long 1 diff --git a/binutils-2.25/ld/testsuite/ld-elf/pr349-2.s b/binutils-2.25/ld/testsuite/ld-elf/pr349-2.s new file mode 100644 index 0000000..85f36ca --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pr349-2.s @@ -0,0 +1,2 @@ + .section ".abcxyz","",%progbits + .long 2 diff --git a/binutils-2.25/ld/testsuite/ld-elf/pr349.d b/binutils-2.25/ld/testsuite/ld-elf/pr349.d new file mode 100644 index 0000000..48e3256 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pr349.d @@ -0,0 +1,13 @@ +#source: pr349-1.s +#source: pr349-2.s +#ld: -r +#readelf: -S +#xfail: arc-*-* d30v-*-* dlx-*-* fr30-*-* frv-*-elf i860-*-* i960-*-* +#xfail: iq*-*-* mn10200-*-* moxie-*-* msp*-*-* mt-*-* or32-*-* pj*-*-* +# if not using elf32.em, you don't get fancy section handling + +#... +.* .abcxyz .* +#... +.* .abcxyz .* +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/pr9676-1.c b/binutils-2.25/ld/testsuite/ld-elf/pr9676-1.c new file mode 100644 index 0000000..f8459c7 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pr9676-1.c @@ -0,0 +1,15 @@ +extern int foo (void) __attribute__((section (".gnu.linkonce.t.1"), weak)); + +int +foo (void) +{ + return 1; +} + +extern int foo2 (void); + +int +bar (void) +{ + return foo2 (); +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/pr9676-2.c b/binutils-2.25/ld/testsuite/ld-elf/pr9676-2.c new file mode 100644 index 0000000..e2a3404 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pr9676-2.c @@ -0,0 +1,14 @@ +extern int foo (void) __attribute__((section (".gnu.linkonce.t.1"), weak, + __visibility__ ("hidden"))); + +int +foo (void) +{ + return 1; +} + +int +foo2 (void) +{ + return 1; +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/pr9676-3.c b/binutils-2.25/ld/testsuite/ld-elf/pr9676-3.c new file mode 100644 index 0000000..e5985df --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pr9676-3.c @@ -0,0 +1,7 @@ +extern int foo (void) __attribute__((section (".gnu.linkonce.t.1"), weak)); + +int +foo (void) +{ + return 1; +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/pr9676-4.c b/binutils-2.25/ld/testsuite/ld-elf/pr9676-4.c new file mode 100644 index 0000000..d5013c7 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pr9676-4.c @@ -0,0 +1,9 @@ +extern int bar (void); +extern int foo (void); + +int +x (void) +{ + foo (); + return bar (); +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/pr9676.rd b/binutils-2.25/ld/testsuite/ld-elf/pr9676.rd new file mode 100644 index 0000000..2d832db --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pr9676.rd @@ -0,0 +1,5 @@ +Symbol table '\.dynsym' contains [0-9]+ entries: + +Num: +Value +Size Type +Bind +Vis +Ndx Name +#... + +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +FUNC +LOCAL +DEFAULT +[0-9]+ +_?foo +#... diff --git a/binutils-2.25/ld/testsuite/ld-elf/pr9679-1.c b/binutils-2.25/ld/testsuite/ld-elf/pr9679-1.c new file mode 100644 index 0000000..cf7abbb --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pr9679-1.c @@ -0,0 +1,5 @@ +int +foo (void) +{ + return 1; +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/pr9679-2.c b/binutils-2.25/ld/testsuite/ld-elf/pr9679-2.c new file mode 100644 index 0000000..e125a6b --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pr9679-2.c @@ -0,0 +1,13 @@ +extern int foo (void) __attribute__((weak,__visibility__ ("hidden"))); + +int +foo (void) +{ + return 1; +} + +int +bar (void) +{ + return foo (); +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/pr9679.rd b/binutils-2.25/ld/testsuite/ld-elf/pr9679.rd new file mode 100644 index 0000000..2d832db --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/pr9679.rd @@ -0,0 +1,5 @@ +Symbol table '\.dynsym' contains [0-9]+ entries: + +Num: +Value +Size Type +Bind +Vis +Ndx Name +#... + +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +FUNC +LOCAL +DEFAULT +[0-9]+ +_?foo +#... diff --git a/binutils-2.25/ld/testsuite/ld-elf/preinit.c b/binutils-2.25/ld/testsuite/ld-elf/preinit.c new file mode 100644 index 0000000..9ef2a89 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/preinit.c @@ -0,0 +1,34 @@ +#include <stdio.h> + +static void +preinit_0 (void) +{ + printf ("preinit array 0\n"); +} + +static void +preinit_1 (void) +{ + printf ("preinit array 1\n"); +} + +static void +preinit_2 (void) +{ + printf ("preinit array 2\n"); +} + +void (*const preinit_array []) (void) + __attribute__ ((section (".preinit_array"), + aligned (sizeof (void *)))) = +{ + &preinit_0, + &preinit_1, + &preinit_2 +}; + +int +main (void) +{ + return 0; +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/preinit.out b/binutils-2.25/ld/testsuite/ld-elf/preinit.out new file mode 100644 index 0000000..6a30bc6 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/preinit.out @@ -0,0 +1,3 @@ +preinit array 0 +preinit array 1 +preinit array 2 diff --git a/binutils-2.25/ld/testsuite/ld-elf/provide-hidden-1.ld b/binutils-2.25/ld/testsuite/ld-elf/provide-hidden-1.ld new file mode 100644 index 0000000..47cdbb7 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/provide-hidden-1.ld @@ -0,0 +1,15 @@ +SECTIONS +{ + . = 0x12300000; + .data : + { + PROVIDE_HIDDEN (foo = . + 0x11100000); + *(.data) + } + .got : { *(.got) } + .interp : { *(.interp) } + .dynsym : { *(.dynsym) } + .dynstr : { *(.dynstr) } + .dynamic : { *(.dynamic) } + .hash : { *(.hash) } +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/provide-hidden-1.s b/binutils-2.25/ld/testsuite/ld-elf/provide-hidden-1.s new file mode 100644 index 0000000..c845ffb --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/provide-hidden-1.s @@ -0,0 +1,4 @@ + .data + .globl foo +foo: + .dc.a foo diff --git a/binutils-2.25/ld/testsuite/ld-elf/provide-hidden-2.ld b/binutils-2.25/ld/testsuite/ld-elf/provide-hidden-2.ld new file mode 100644 index 0000000..0b04c49 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/provide-hidden-2.ld @@ -0,0 +1,12 @@ +SECTIONS +{ + . = 0x12300000; + PROVIDE_HIDDEN (foo = . + 0x11100000); + .data : { *(.data) } + .got : { *(.got) } + .interp : { *(.interp) } + .dynsym : { *(.dynsym) } + .dynstr : { *(.dynstr) } + .dynamic : { *(.dynamic) } + .hash : { *(.hash) } +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/provide-hidden-2.s b/binutils-2.25/ld/testsuite/ld-elf/provide-hidden-2.s new file mode 100644 index 0000000..bbaa7de --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/provide-hidden-2.s @@ -0,0 +1,5 @@ + .data + .globl foo + .internal foo +foo: + .dc.a foo diff --git a/binutils-2.25/ld/testsuite/ld-elf/provide-hidden-3.s b/binutils-2.25/ld/testsuite/ld-elf/provide-hidden-3.s new file mode 100644 index 0000000..9413280 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/provide-hidden-3.s @@ -0,0 +1,4 @@ + .data + .globl bar +bar: + .dc.a foo diff --git a/binutils-2.25/ld/testsuite/ld-elf/provide-hidden-4.s b/binutils-2.25/ld/testsuite/ld-elf/provide-hidden-4.s new file mode 100644 index 0000000..2d8f37e --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/provide-hidden-4.s @@ -0,0 +1,5 @@ + .data + .globl bar + .internal foo +bar: + .dc.a foo diff --git a/binutils-2.25/ld/testsuite/ld-elf/provide-hidden-abs.nd b/binutils-2.25/ld/testsuite/ld-elf/provide-hidden-abs.nd new file mode 100644 index 0000000..642a7a0 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/provide-hidden-abs.nd @@ -0,0 +1,5 @@ +#... +Symbol table '\.symtab' contains [0-9]+ entries: +#... + *[0-9]+: 0*23400000 +0 (?:NOTYPE|OBJECT) +LOCAL +DEFAULT +ABS foo +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/provide-hidden-def.nd b/binutils-2.25/ld/testsuite/ld-elf/provide-hidden-def.nd new file mode 100644 index 0000000..d4355c8 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/provide-hidden-def.nd @@ -0,0 +1,5 @@ +#... +Symbol table '\.symtab' contains [0-9]+ entries: +#... + *[0-9]+: 0*12300000 +0 (?:NOTYPE|OBJECT) +LOCAL +DEFAULT +[0-9]+ foo +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/provide-hidden-dyn.nd b/binutils-2.25/ld/testsuite/ld-elf/provide-hidden-dyn.nd new file mode 100644 index 0000000..230f7fd --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/provide-hidden-dyn.nd @@ -0,0 +1,7 @@ +#failif +Symbol table '\.dynsym' contains [0-9]+ entries: +#... +.* foo +#... +Symbol table '\.symtab' contains [0-9]+ entries: +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/provide-hidden-dynabs.nd b/binutils-2.25/ld/testsuite/ld-elf/provide-hidden-dynabs.nd new file mode 100644 index 0000000..86e3adc --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/provide-hidden-dynabs.nd @@ -0,0 +1,8 @@ +Symbol table '\.dynsym' contains [0-9]+ entries: +#... + *[0-9]+: 0*23400000 +0 (?:NOTYPE|OBJECT) +LOCAL +DEFAULT +ABS foo +#... +Symbol table '\.symtab' contains [0-9]+ entries: +#... + *[0-9]+: 0*23400000 +0 (?:NOTYPE|OBJECT) +LOCAL +DEFAULT +ABS foo +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/provide-hidden-dynsec.nd b/binutils-2.25/ld/testsuite/ld-elf/provide-hidden-dynsec.nd new file mode 100644 index 0000000..716dfa1 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/provide-hidden-dynsec.nd @@ -0,0 +1,8 @@ +Symbol table '\.dynsym' contains [0-9]+ entries: +#... + *[0-9]+: 0*23400000 +0 (?:NOTYPE|OBJECT) +LOCAL +DEFAULT +[0-9]+ foo +#... +Symbol table '\.symtab' contains [0-9]+ entries: +#... + *[0-9]+: 0*23400000 +0 (?:NOTYPE|OBJECT) +LOCAL +DEFAULT +[0-9]+ foo +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/provide-hidden-s.ld b/binutils-2.25/ld/testsuite/ld-elf/provide-hidden-s.ld new file mode 100644 index 0000000..cca804f --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/provide-hidden-s.ld @@ -0,0 +1,11 @@ +SECTIONS +{ + . = 0x12300000; + .data : { *(.data) } + .got : { *(.got) } + .interp : { *(.interp) } + .dynsym : { *(.dynsym) } + .dynstr : { *(.dynstr) } + .dynamic : { *(.dynamic) } + .hash : { *(.hash) } +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/provide-hidden-s.nd b/binutils-2.25/ld/testsuite/ld-elf/provide-hidden-s.nd new file mode 100644 index 0000000..4fd2cc5 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/provide-hidden-s.nd @@ -0,0 +1,8 @@ +Symbol table '\.dynsym' contains [0-9]+ entries: +#... + *[0-9]+: 0*12300000 +0 (?:NOTYPE|OBJECT) +GLOBAL +DEFAULT +[0-9]+ foo +#... +Symbol table '\.symtab' contains [0-9]+ entries: +#... + *[0-9]+: 0*12300000 +0 (?:NOTYPE|OBJECT) +GLOBAL +DEFAULT +[0-9]+ foo +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/provide-hidden-sec.nd b/binutils-2.25/ld/testsuite/ld-elf/provide-hidden-sec.nd new file mode 100644 index 0000000..f155d66 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/provide-hidden-sec.nd @@ -0,0 +1,5 @@ +#... +Symbol table '\.symtab' contains [0-9]+ entries: +#... + *[0-9]+: 0*23400000 +0 (?:NOTYPE|OBJECT) +LOCAL +DEFAULT +[0-9]+ foo +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/provide-hidden.exp b/binutils-2.25/ld/testsuite/ld-elf/provide-hidden.exp new file mode 100644 index 0000000..7246d11 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/provide-hidden.exp @@ -0,0 +1,154 @@ +# Expect script for the PROVIDE_HIDDEN linker script command. +# +# Copyright 2013 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 Maciej W. Rozycki <macro@codesourcery.com> +# + +# Export classes only make sense for ELF shared-library targets. +if { ![is_elf_format] || ![check_shared_lib_support] } { + return +} + +# This target requires extra GAS options when building code for shared +# libraries. +set AFLAGS_PIC "" +if [istarget "tic6x-*-*"] { + append AFLAGS_PIC " -mpic -mpid=near" +} + +set testname "PROVIDE_HIDDEN test" + +run_ld_link_tests [list \ + [list \ + "$testname (auxiliary shared object)" \ + "-shared -T provide-hidden-s.ld" "" \ + "$AFLAGS_PIC" \ + [list provide-hidden-1.s ] \ + [list "readelf -s provide-hidden-s.nd"] \ + "provide-hidden-s.so"]] + +run_ld_link_tests [list \ + [list \ + "$testname 1" \ + "-T provide-hidden-1.ld" "" \ + "" \ + [list provide-hidden-1.s] \ + [list \ + [list readelf -s provide-hidden-def.nd] \ + [list readelf -s provide-hidden-dyn.nd]] \ + "provide-hidden-1"] \ + [list \ + "$testname 2" \ + "-T provide-hidden-1.ld" "" \ + "" \ + [list provide-hidden-2.s] \ + [list \ + [list readelf -s provide-hidden-def.nd] \ + [list readelf -s provide-hidden-dyn.nd]] \ + "provide-hidden-2"] \ + [list \ + "$testname 3" \ + "-T provide-hidden-1.ld" "" \ + "" \ + [list provide-hidden-3.s] \ + [list \ + [list readelf -s provide-hidden-sec.nd] \ + [list readelf -s provide-hidden-dyn.nd]] \ + "provide-hidden-3"] \ + [list \ + "$testname 4" \ + "-T provide-hidden-1.ld" "tmpdir/provide-hidden-s.so" \ + "" \ + [list provide-hidden-3.s] \ + [list "readelf -s provide-hidden-dynsec.nd"] \ + "provide-hidden-4"] \ + [list \ + "$testname 5" \ + "-T provide-hidden-1.ld" "" \ + "" \ + [list provide-hidden-4.s] \ + [list \ + [list readelf -s provide-hidden-sec.nd] \ + [list readelf -s provide-hidden-dyn.nd]] \ + "provide-hidden-5"] \ + [list \ + "$testname 6" \ + "-T provide-hidden-1.ld" "tmpdir/provide-hidden-s.so" \ + "" \ + [list provide-hidden-4.s] \ + [list \ + [list readelf -s provide-hidden-sec.nd] \ + [list readelf -s provide-hidden-dyn.nd]] \ + "provide-hidden-6"] \ + [list \ + "$testname 7" \ + "-T provide-hidden-2.ld" "" \ + "" \ + [list provide-hidden-1.s] \ + [list \ + [list readelf -s provide-hidden-def.nd] \ + [list readelf -s provide-hidden-dyn.nd]] \ + "provide-hidden-7"] \ + [list \ + "$testname 8" \ + "-T provide-hidden-2.ld" "" \ + "" \ + [list provide-hidden-2.s] \ + [list \ + [list readelf -s provide-hidden-def.nd] \ + [list readelf -s provide-hidden-dyn.nd]] \ + "provide-hidden-8"] \ + [list \ + "$testname 9" \ + "-T provide-hidden-2.ld" "" \ + "" \ + [list provide-hidden-3.s] \ + [list \ + [list readelf -s provide-hidden-abs.nd] \ + [list readelf -s provide-hidden-dyn.nd]] \ + "provide-hidden-9"] \ + [list \ + "$testname 10" \ + "-T provide-hidden-2.ld" "tmpdir/provide-hidden-s.so" \ + "" \ + [list provide-hidden-3.s] \ + [list "readelf -s provide-hidden-dynabs.nd"] \ + "provide-hidden-10"] \ + [list \ + "$testname 11" \ + "-T provide-hidden-2.ld" "" \ + "" \ + [list provide-hidden-4.s] \ + [list \ + [list readelf -s provide-hidden-abs.nd] \ + [list readelf -s provide-hidden-dyn.nd]] \ + "provide-hidden-11"] \ + [list \ + "$testname 12" \ + "-T provide-hidden-2.ld" "tmpdir/provide-hidden-s.so" \ + "" \ + [list provide-hidden-4.s] \ + [list \ + [list readelf -s provide-hidden-abs.nd] \ + [list readelf -s provide-hidden-dyn.nd]] \ + "provide-hidden-12"]] diff --git a/binutils-2.25/ld/testsuite/ld-elf/rel.c b/binutils-2.25/ld/testsuite/ld-elf/rel.c new file mode 100644 index 0000000..fd94f71 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/rel.c @@ -0,0 +1,9 @@ +static int seven = 7; +static int *__attribute__((section("auto"))) auto_10 = &seven; + +int +eight (void) +{ + extern int *__start_auto[], *__stop_auto[]; + return *auto_10 + __stop_auto - __start_auto; +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/relmain.c b/binutils-2.25/ld/testsuite/ld-elf/relmain.c new file mode 100644 index 0000000..f72dd54 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/relmain.c @@ -0,0 +1,7 @@ +extern int eight (void); + +int +main (void) +{ + return eight () - 8; +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/relmain.out b/binutils-2.25/ld/testsuite/ld-elf/relmain.out new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/relmain.out diff --git a/binutils-2.25/ld/testsuite/ld-elf/relocatable.d b/binutils-2.25/ld/testsuite/ld-elf/relocatable.d new file mode 100644 index 0000000..458244a --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/relocatable.d @@ -0,0 +1,10 @@ +#name: relocatable with script +#source: simple.s +#ld: -r -T relocatable.t +#readelf: -S --wide +#xfail: hppa-*-* + +#... + \[[ 0-9]+\] \.text.*[ \t]+PROGBITS[ \t]+0+800000[ \t0-9a-f]+AX.* + \[[ 0-9]+\] \.data.*[ \t]+PROGBITS[ \t]+0+900000[ \t0-9a-f]+WA.* +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/relocatable.t b/binutils-2.25/ld/testsuite/ld-elf/relocatable.t new file mode 100644 index 0000000..2ec056a --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/relocatable.t @@ -0,0 +1,8 @@ +SECTIONS +{ + . = 0x800000; + .text : { *(.text) } + . = 0x900000; + .data : { *(.data) } + /DISCARD/ : { *(.*) } +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/relro1.s b/binutils-2.25/ld/testsuite/ld-elf/relro1.s new file mode 100644 index 0000000..76c956d --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/relro1.s @@ -0,0 +1,14 @@ + .globl main + .globl start + .globl _start + .globl __start + .text +main: +start: +_start: +__start: + .long 0 + .data + .long 0 + .section .data.rel.ro,"aw",%progbits + .long 0 diff --git a/binutils-2.25/ld/testsuite/ld-elf/relro2.s b/binutils-2.25/ld/testsuite/ld-elf/relro2.s new file mode 100644 index 0000000..0bbf366 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/relro2.s @@ -0,0 +1,5 @@ + .text + .globl x + .type x, @function +x: + jmp foo@PLT diff --git a/binutils-2.25/ld/testsuite/ld-elf/rpath-1.d b/binutils-2.25/ld/testsuite/ld-elf/rpath-1.d new file mode 100644 index 0000000..918a326 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/rpath-1.d @@ -0,0 +1,9 @@ +#source: start.s +#readelf: -d -W +#ld: -shared -rpath . +#target: *-*-linux* *-*-gnu* + +#failif +#... + +0x[0-9a-f]+ +\(RUNPATH\) +Library runpath: +\[.\] +#... diff --git a/binutils-2.25/ld/testsuite/ld-elf/rpath-2.d b/binutils-2.25/ld/testsuite/ld-elf/rpath-2.d new file mode 100644 index 0000000..17be86d --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/rpath-2.d @@ -0,0 +1,8 @@ +#source: start.s +#readelf: -d -W +#ld: -shared -rpath . +#target: *-*-linux* *-*-gnu* + +#... + +0x[0-9a-f]+ +\(RPATH\) +Library rpath: +\[.\] +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/runpath-1.d b/binutils-2.25/ld/testsuite/ld-elf/runpath-1.d new file mode 100644 index 0000000..4d06639 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/runpath-1.d @@ -0,0 +1,9 @@ +#source: start.s +#readelf: -d -W +#ld: -shared -rpath . --enable-new-dtags +#target: *-*-linux* *-*-gnu* + +#failif +#... + +0x[0-9a-f]+ +\(RPATH\) +Library rpath: +\[.\] +#... diff --git a/binutils-2.25/ld/testsuite/ld-elf/runpath-2.d b/binutils-2.25/ld/testsuite/ld-elf/runpath-2.d new file mode 100644 index 0000000..0df8af6 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/runpath-2.d @@ -0,0 +1,8 @@ +#source: start.s +#readelf: -d -W +#ld: -shared -rpath . --enable-new-dtags +#target: *-*-linux* *-*-gnu* + +#... + +0x[0-9a-f]+ +\(RUNPATH\) +Library runpath: +\[.\] +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/sec-to-seg-script-adjoining-pages.t b/binutils-2.25/ld/testsuite/ld-elf/sec-to-seg-script-adjoining-pages.t new file mode 100644 index 0000000..763fcb7 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/sec-to-seg-script-adjoining-pages.t @@ -0,0 +1,11 @@ +SECTIONS +{ + . = 0x1000; + .sec1 : { *sec-to-seg1.o(.rodata) } + . += CONSTANT(MAXPAGESIZE); + .sec2 : { *sec-to-seg2.o(.rodata) } + + .data : { *(.data) } /* For hppa64. */ + + /DISCARD/ : {*(*) } +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/sec-to-seg-script-disjoint-pages.t b/binutils-2.25/ld/testsuite/ld-elf/sec-to-seg-script-disjoint-pages.t new file mode 100644 index 0000000..25023cc --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/sec-to-seg-script-disjoint-pages.t @@ -0,0 +1,11 @@ +SECTIONS +{ + . = 0x1000; + .sec1 : { *sec-to-seg1.o(.rodata) } + . += CONSTANT(MAXPAGESIZE) * 2; + .sec2 : { *sec-to-seg2.o(.rodata) } + + .data : { *(.data) } /* For hppa64. */ + + /DISCARD/ : {*(*) } +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/sec-to-seg-script-same-page.t b/binutils-2.25/ld/testsuite/ld-elf/sec-to-seg-script-same-page.t new file mode 100644 index 0000000..2b50f7e --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/sec-to-seg-script-same-page.t @@ -0,0 +1,10 @@ +SECTIONS +{ + . = 0x1000; + .sec1 : { *sec-to-seg1.o(.rodata) } + .sec2 : { *sec-to-seg2.o(.rodata) } + + .data : { *(.data) } /* For hppa64. */ + + /DISCARD/ : {*(*) } +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/sec-to-seg.exp b/binutils-2.25/ld/testsuite/ld-elf/sec-to-seg.exp new file mode 100644 index 0000000..c963055 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/sec-to-seg.exp @@ -0,0 +1,100 @@ +# Test the assigment of sections to segments. +# +# Copyright 2008, 2010 Free Software Foundation, Inc. +# Contributed by Red Hat. +# +# 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. + +set testname "assignment of ELF sections to segments" + +if {! [is_elf_format] } { + unsupported $testname + return +} + +if { ! [ld_assemble $as $srcdir/$subdir/sec-to-seg1.s tmpdir/sec-to-seg1.o] + || ! [ld_assemble $as $srcdir/$subdir/sec-to-seg2.s tmpdir/sec-to-seg2.o]} then { + unresolved $testname + return +} + +proc sec_to_seg_test { testname scriptname same_seg } { + global srcdir + global subdir + global ld + global exec_output + global READELF + + if {! [ld_simple_link $ld tmpdir/sec-to-seg "-T $srcdir/$subdir/$scriptname tmpdir/sec-to-seg1.o tmpdir/sec-to-seg2.o"] } then { + fail $testname + return 0 + } + + send_log "$READELF --program-headers --section-headers tmpdir/sec-to-seg\n" + set exec_output [run_host_cmd "$READELF" "--program-headers --section-headers tmpdir/sec-to-seg"] + + if { $same_seg == 1 } { + if {! [regexp ".*.sec1 .sec2" $exec_output] } { + fail $testname + return 0 + } + } else { + if { [regexp ".*.sec1 .sec2" $exec_output] } { + fail $testname + return 0 + } + } + + pass $testname + return 1 +} + +# Assuming a pagesize of 0x1000 then: +# +# Test Sec1 End Sec 2 Start Expected Result +# ---- -------- ----------- --------------- +# A 00001042 00001043 Both sections on same page: assign to same segment. +# B 00001042 00002044 Sections on adjacent pages: assign to same segment. +# C 00001042 00003044 Sections on disjoint pages: assign to separate segments. + +# These targets have a pagesize of 1, so they will always end up +# placing the two sections in separate segments in the B test. +if { [istarget avr-*-*] + || [istarget cr16-*-*] + || [istarget crx-*-*] + || [istarget dlx-*-*] + || [istarget h8300-*-*] + || [istarget i960-*-*] + || [istarget ip2k-*-*] + || [istarget m32r-*-*] + || [istarget m88k-*-*] + || [istarget moxie-*-*] + || [istarget msp430-*-*] + || [istarget mt-*-*] + } { + set B_test_same_seg 0 +} else { + set B_test_same_seg 1 +} + +sec_to_seg_test "assignment of ELF sections to segments (same page)" "sec-to-seg-script-same-page.t" 1 +sec_to_seg_test "assignment of ELF sections to segments (adjacent pages)" "sec-to-seg-script-adjoining-pages.t" $B_test_same_seg +sec_to_seg_test "assignment of ELF sections to segments (disjoint pages)" "sec-to-seg-script-disjoint-pages.t" 0 + + +# FIXME: Add more tests to check other rules of section to segment assignment. diff --git a/binutils-2.25/ld/testsuite/ld-elf/sec-to-seg1.s b/binutils-2.25/ld/testsuite/ld-elf/sec-to-seg1.s new file mode 100644 index 0000000..1e8e2bb --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/sec-to-seg1.s @@ -0,0 +1,9 @@ + .file "sec-to-seg1.s" + + .section .rodata + .align 2 + .ascii "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\000" + .align 2 + .ascii "0000000000000000000000000000000\000" + + diff --git a/binutils-2.25/ld/testsuite/ld-elf/sec-to-seg2.s b/binutils-2.25/ld/testsuite/ld-elf/sec-to-seg2.s new file mode 100644 index 0000000..b1dd078 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/sec-to-seg2.s @@ -0,0 +1,13 @@ + .file "sec-to-seg2.s" + + .section .rodata + .align 2 + .ascii "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\000" + .align 2 + .ascii "55555555555555555555555555555555\000" + .align 2 + .ascii "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\000" + .align 2 + .ascii "99999999999999999999999999999999\000" + + diff --git a/binutils-2.25/ld/testsuite/ld-elf/sec64k.exp b/binutils-2.25/ld/testsuite/ld-elf/sec64k.exp new file mode 100644 index 0000000..7c9f292 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/sec64k.exp @@ -0,0 +1,207 @@ +# Expect script for tests for >64k sections +# Copyright 2002, 2003, 2005, 2006, 2007, 2008 +# 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 Hans-Peter Nilsson (hp@axis.com) +# + +# Exclude non-ELF targets. + +if ![is_elf_format] { + return +} + +# Targets using the generic linker backend don't sort section symbols +# before local symbols, so don't bother testing them. +if { [istarget "arc-*-*"] + || [istarget "d30v-*-*"] + || [istarget "dlx-*-*"] + || [istarget "i960-*-*"] + || [istarget "msp430*-*-*"] + || [istarget "or32-*-*"] + || [istarget "pj*-*-*"] + || [istarget "m32r-*-*"] } { + return +} + +# Test >64k sections, with and without -r. First, create the assembly +# files. Have a relocation to another section and one within the local +# section. + +set test1 "64ksec-r" +set test2 "64ksec" + +if { ![runtest_file_p $runtests $test1] \ + && ![runtest_file_p $runtests $test2] } { + return +} + +set sfiles {} +set max_sec 66000 +set secs_per_file 1000 +for { set i 0 } { $i < $max_sec / $secs_per_file } { incr i } { + set sfile "$objdir/tmpdir/sec64-$i.s" + lappend sfiles $sfile + if [catch { set ofd [open $sfile w] } x] { + perror "$x" + unresolved $test1 + unresolved $test2 + return + } + + if { $i == 0 } { + puts $ofd " .global start" + puts $ofd "start:" + puts $ofd " .global _start" + puts $ofd "_start:" + puts $ofd " .global __start" + puts $ofd "__start:" + puts $ofd " .global main" + puts $ofd "main:" + puts $ofd " .global foo_0" + puts $ofd "foo_0: .dc.a 0" + } + + # Make sure the used section is not covered by common linker scripts. + # They should get separate section entries even without -r. + puts $ofd " .altmacro" + puts $ofd " .macro sec secn, secp" + if {![istarget "frv-*-*linux*"]} then { + puts $ofd " .section .foo.\\secn,\"ax\"" + } else { + puts $ofd " .section .foo.\\secn,\"aw\"" + } + puts $ofd " .global foo_\\secn" + puts $ofd "foo_\\secn:" + puts $ofd " .dc.a foo_\\secp" + puts $ofd "bar_\\secn:" + puts $ofd " .dc.a bar_\\secn" + puts $ofd " .endm" + if {![istarget "bfin-*-*"]} then { + puts $ofd " secn = [expr $i * $secs_per_file]" + } else { + puts $ofd " .set secn, [expr $i * $secs_per_file]" + } + puts $ofd " .rept $secs_per_file" + if {![istarget "bfin-*-*"]} then { + puts $ofd " secn = secn + 1" + } else { + puts $ofd " .set secn, secn + 1" + } + puts $ofd " sec %(secn), %(secn-1)" + puts $ofd " .endr" + + close $ofd +} + +if [catch { set ofd [open "tmpdir/$test1.d" w] } x] { + perror "$x" + unresolved $test1 + unresolved $test2 + return +} + +# The ld-r linked file will contain relocation-sections too, so make it +# half the size in order to try and keep the test-time down. + +# The m32r target generates both REL and RELA relocs (for historical +# reasons) so the expected number of sections will be much more than +# 68000, which throws this particular test right off. +if { ![istarget "m32r-*-*"] } then { + foreach sfile [lrange $sfiles 0 [expr [llength $sfiles] / 2]] { + puts $ofd "#source: $sfile" + } + puts $ofd "#ld: -r" + puts $ofd "#readelf: -W -Ss" + puts $ofd "There are 680.. section headers.*:" + puts $ofd "#..." + puts $ofd " \\\[ 0\\\] .* 680\[0-9\]\[0-9\]\[ \]+0\[ \]+0" + puts $ofd "#..." + puts $ofd " \\\[ \[0-9\]\\\] \.foo\.1\[ \]+PROGBITS\[ \]+.*" + puts $ofd "#..." + puts $ofd " \\\[65279\\\] (.rel\[a\]?)?\\.foo\\.\[0-9\]+ .*" + puts $ofd " \\\[65280\\\] (.rel\[a\]?)?\\.foo\\.\[0-9\]+ .*" + puts $ofd "#..." + puts $ofd " 340..: 0+\[ \]+0\[ \]+SECTION\[ \]+LOCAL\[ \]+DEFAULT\[ \]+68... " + puts $ofd "#..." + puts $ofd " 340..: 0+(2|4|8)\[ \]+0\[ \]+NOTYPE\[ \]+LOCAL\[ \]+DEFAULT\[ \]+\[2-5\] bar_1$" + puts $ofd "#..." + puts $ofd ".* bar_34000$" + puts $ofd "#..." + # Global symbols are not in "alphanumeric" order, so we just check + # that the first and the last are present in any order (assuming no + # duplicates). + puts $ofd ".* (\[0-9\] foo_1|68... foo_34000)$" + puts $ofd "#..." + puts $ofd ".* (\[0-9\] foo_1|68... foo_34000)$" + puts $ofd "#pass" + close $ofd + run_dump_test "tmpdir/$test1" +} + +if [catch { set ofd [open "tmpdir/$test2.d" w] } x] { + perror "$x" + unresolved $test2 + return +} + +# too big for d10v and msp +# lack of fancy orphan section handling causes overlap on fr30 and iq2000 +if { ![istarget "d10v-*-*"] + && ![istarget "msp*-*-*"] + && ![istarget "fr30-*-*"] + && ![istarget "iq2000-*-*"] } { + foreach sfile $sfiles { puts $ofd "#source: $sfile" } + if { [istarget "avr-*-*"] } then { + puts $ofd "#as: -mmcu=avr6" + puts $ofd "#ld: -mavr6" + } elseif { [istarget spu*-*-*] } { + puts $ofd "#ld: --local-store 0:0" + } else { + puts $ofd "#ld:" + } + puts $ofd "#readelf: -W -Ss" + puts $ofd "There are 660.. section headers.*:" + puts $ofd "#..." + puts $ofd " \\\[ 0\\\] .* 660..\[ \]+0\[ \]+0" + puts $ofd "#..." + puts $ofd " \\\[65279\\\] \\.foo\\.\[0-9\]+ .*" + puts $ofd " \\\[65280\\\] \\.foo\\.\[0-9\]+ .*" + puts $ofd "#..." + puts $ofd " 660..: \[0-9a-f\]+\[ \]+0\[ \]+SECTION\[ \]+LOCAL\[ \]+DEFAULT\[ \]+660.. " + puts $ofd "#..." + puts $ofd " 660..: \[0-9a-f\]+\[ \]+0\[ \]+NOTYPE\[ \]+LOCAL\[ \]+DEFAULT\[ \]+\[0-9\] bar_1$" + puts $ofd "#..." + puts $ofd ".* bar_66000$" + puts $ofd "#..." + # Global symbols are not in "alphanumeric" order, so we just check + # that the first and the last are present in any order (assuming no + # duplicates). + puts $ofd ".* (\[0-9\] foo_1|66... foo_66000)$" + puts $ofd "#..." + puts $ofd ".* (\[0-9\] foo_1|66... foo_66000)$" + puts $ofd "#pass" + close $ofd + run_dump_test "tmpdir/$test2" +} + +for { set i 1 } { $i < $max_sec / $secs_per_file } { incr i } { + catch "exec rm -f tmpdir/dump$i.o" status +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/seg.d b/binutils-2.25/ld/testsuite/ld-elf/seg.d new file mode 100644 index 0000000..2255195 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/seg.d @@ -0,0 +1,21 @@ +#target: *-*-linux* *-*-gnu* *-*-vxworks +#source: seg.s +#ld: -T seg.t -z max-page-size=0x1000 +#readelf: -l --wide + +#... +Program Headers: + Type Offset VirtAddr.* +# On MIPS, the first segment is for .reginfo. +#... + LOAD .* + LOAD 0x0*001000 0xf*fffff000 0xf*fffff000 0x0*1000 0x0*1000 .* +# FRV adds a PT_GNU_STACK header +#... + Section to Segment mapping: + Segment Sections... + 00 .* +# On MIPS, the first segment is for .reginfo. +#... + 0. reset boot +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/seg.s b/binutils-2.25/ld/testsuite/ld-elf/seg.s new file mode 100644 index 0000000..24ec567 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/seg.s @@ -0,0 +1,6 @@ + .section boot,"ax" + .4byte 0x76543210 + .section reset,"ax" + .4byte 0xfedcba98 + .text + .4byte 0x12345678 diff --git a/binutils-2.25/ld/testsuite/ld-elf/seg.t b/binutils-2.25/ld/testsuite/ld-elf/seg.t new file mode 100644 index 0000000..2f86acf --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/seg.t @@ -0,0 +1,16 @@ + +SECTIONS +{ + reset - 4 : + { + *(reset) + } + boot - 0x1000 : + { + *(boot) + } = 0xffff + . = + SIZEOF_HEADERS; + .text : { *(.text) } + .data : { *(.data) } + .bss : { *(.bss) } +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/shared.exp b/binutils-2.25/ld/testsuite/ld-elf/shared.exp new file mode 100644 index 0000000..56c724f --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/shared.exp @@ -0,0 +1,434 @@ +# Expect script for various ELF tests. +# Copyright 2006, 2007, 2008, 2009, 2010, 2011, 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. +# + +# Exclude non-ELF targets. + +# The following tests require running the executable generated by ld, +# or enough of a build environment to create a fully linked executable. +# This is not commonly available when testing a cross-built linker. +if ![isnative] { + return +} + +if ![is_elf_format] { + return +} + +# Check to see if the C compiler works +if { [which $CC] == 0 } { + return +} + +set build_tests { + {"Build libfoo.so" + "-shared" "-fPIC" + {foo.c} {} "libfoo.so"} + {"Build versioned libfoo.so" + "-shared -Wl,--version-script=foo.map" "-fPIC" + {foo.c} {} "libfoov.so"} + {"Build libbar.so" + "-shared" "-fPIC" + {begin.c end.c} {} "libbar.so"} + {"Build warn libbar.so" + "-shared" "-fPIC" + {beginwarn.c end.c} {{readelf {-S --wide} libbarw.rd}} "libbarw.so" + "C" "^.*\\\): warning: function foo is deprecated$"} + {"Build hidden libbar.so" + "-shared" "-fPIC" + {begin.c endhidden.c} {} "libbarh.so"} + {"Build protected libbar.so" + "-shared" "-fPIC" + {begin.c endprotected.c} {} "libbarp.so"} + {"Build libbar.so with libfoo.so" + "-shared tmpdir/begin.o tmpdir/libfoo.so" "-fPIC" + {end.c} {} "libbarfoo.so"} + {"Build libar.so with versioned libfoo.so" + "-shared tmpdir/begin.o tmpdir/libfoov.so" "-fPIC" + {end.c} {} "libbarfoov.so"} + {"Build hidden libbar.so with libfoo.so" + "-shared tmpdir/begin.o tmpdir/libfoo.so" "-fPIC" + {endhidden.c} {} "libbarhfoo.so"} + {"Build hidden libar.so with versioned libfoo.so" + "-shared tmpdir/begin.o tmpdir/libfoov.so" "-fPIC" + {endhidden.c} {} "libbarhfoov.so"} + {"Build protected libbar.so with libfoo.so" + "-shared tmpdir/begin.o tmpdir/libfoo.so" "-fPIC" + {endprotected.c} {} "libbarpfoo.so"} + {"Build protected libbar.so with versioned libfoo.so" + "-shared tmpdir/begin.o tmpdir/libfoov.so" "-fPIC" + {endprotected.c} {} "libbarpfoov.so"} + {"Build libdl1.so" + "-shared" "-fPIC" + {dl1.c} {} "libdl1.so"} + {"Build libdl2a.so with --dynamic-list=dl2.list" + "-shared -Wl,--dynamic-list=dl2.list" "-fPIC" + {dl2.c dl2xxx.c} {} "libdl2a.so"} + {"Build libdl2a.so with --dynamic-list=dl2a.list" + "-shared -Wl,--dynamic-list=dl2a.list" "-fPIC" + {dl2.c dl2xxx.c} {} "libdl2a.so"} + {"Build libdl2a.so with --dynamic-list-data" + "-shared -Wl,--dynamic-list-data" "-fPIC" + {dl2.c dl2xxx.c} {} "libdl2a.so"} + {"Build libdl2b.so with --dynamic-list=dl2.list and dl2xxx.list" + "-shared -Wl,--dynamic-list=dl2.list,--dynamic-list=dl2xxx.list" "-fPIC" + {dl2.c dl2xxx.c} {} "libdl2b.so"} + {"Build libdl2c.so with --dynamic-list-data and dl2xxx.list" + "-shared -Wl,--dynamic-list-data,--dynamic-list=dl2xxx.list" "-fPIC" + {dl2.c dl2xxx.c} {} "libdl2c.so"} + {"Build libdl4a.so with --dynamic-list=dl4.list" + "-shared -Wl,--dynamic-list=dl4.list" "-fPIC" + {dl4.c dl4xxx.c} {} "libdl4a.so"} + {"Build libdl4b.so with --dynamic-list-data" + "-shared -Wl,--dynamic-list-data" "-fPIC" + {dl4.c dl4xxx.c} {} "libdl4b.so"} + {"Build libdl4c.so with --dynamic-list=dl4.list and dl4xxx.list" + "-shared -Wl,--dynamic-list=dl4.list,--dynamic-list=dl4xxx.list" "-fPIC" + {dl4.c dl4xxx.c} {} "libdl4c.so"} + {"Build libdl4d.so with --dynamic-list-data and dl4xxx.list" + "-shared -Wl,--dynamic-list-data,--dynamic-list=dl4xxx.list" "-fPIC" + {dl4.c dl4xxx.c} {} "libdl4d.so"} + {"Build libdl4e.so with -Bsymbolic-functions --dynamic-list-cpp-new" + "-shared -Wl,-Bsymbolic-functions,--dynamic-list-cpp-new" "-fPIC" + {dl4.c dl4xxx.c} {} "libdl4e.so"} + {"Build libdl4f.so with --dynamic-list-cpp-new -Bsymbolic-functions" + "-shared -Wl,--dynamic-list-cpp-new,-Bsymbolic-functions" "-fPIC" + {dl4.c dl4xxx.c} {} "libdl4f.so"} + {"Build libdl6a.so" + "-shared" "-fPIC" + {dl6.c} {} "libdl6a.so"} + {"Build libdl6b.so with -Bsymbolic --dynamic-list-data" + "-shared -Wl,-Bsymbolic,--dynamic-list-data" "-fPIC" + {dl6.c} {} "libdl6b.so"} + {"Build libdl6c.so with -Bsymbolic" + "-shared -Wl,-Bsymbolic" "-fPIC" + {dl6.c} {} "libdl6c.so"} + {"Build libdl6d.so with --dynamic-list-data -Bsymbolic" + "-shared -Wl,--dynamic-list-data,-Bsymbolic" "-fPIC" + {dl6.c} {} "libdl6d.so"} + {"Build libdata1.so" + "-shared" "-fPIC" + {data1.c} {} "libdata1.so"} + {"Build libdata2.so" + "-shared" "-fPIC" + {data2.c} {} "libdata2.so"} + {"Build libcomm1.o" + "-r -nostdlib" "" + {comm1.c} {} "libcomm1.o"} + {"Build libfunc1.so" + "-shared" "-fPIC" + {func1.c} {} "libfunc1.so"} + {"Build libpr9676-1.a" + "" "-fPIC" + {pr9676-1.c} {} "libpr9676-1.a"} + {"Build libpr9676-2.a" + "" "-fPIC" + {pr9676-2.c} {} "libpr9676-2.a"} + {"Build libpr9676-3.so" + "-shared" "-fPIC" + {pr9676-3.c} {} "libpr9676-3.so"} + {"Build libpr9676-4.so" + "-shared" "-fPIC" + {pr9676-4.c} {} "libpr9676-4.so"} + {"Build libpr9676-4a.so" + "-shared tmpdir/pr9676-4.o -Ltmpdir -lpr9676-3 -Wl,--start-group -lpr9676-1 -lpr9676-2 -Wl,--end-group" + "-fPIC" + {dummy.c} {{readelf {-s} pr9676.rd}} "libpr9676-4a.so"} + {"Build libpr9679.so" + "-shared" "-fPIC -O0" + {pr9679-1.c pr9679-2.c} {{readelf {-s} pr9679.rd}} "libpr9679.so"} + {"Build libpr11138-1.so" + "-shared -Wl,--version-script=pr11138-1.map" "-fPIC" + {pr11138-1.c} {} "libpr11138-1.so"} + {"Build libpr11138-2.o" + "-r -nostdlib" "" + {pr11138-2.c} {} "libpr11138-2.o"} + {"Build pr13250-1.so" + "-shared" "-fPIC" + {pr13250-1.c} {} "libpr13250-1.so"} + {"Build pr13250-2.so with libpr13250-1.so" + "-shared -Wl,--no-as-needed tmpdir/libpr13250-1.so" "-fPIC" + {pr13250-2.c} {} "libpr13250-2.so"} + {"Build libpr13250-3.o" + "-r -nostdlib" "" + {pr13250-3.c} {} "libpr13250-3.o"} + {"Build libpr14323-2.so" + "-shared" "-fPIC" + {pr14323-2.c} {} "libpr14323-2.so"} + {"Build pr14862-1.o" + "-r -nostdlib" "" + {pr14862-1.c} {} "libpr14862-1.o"} + {"Build libpr14862.so" + "-shared -Wl,--version-script=pr11138-1.map" "-fPIC" + {pr14862-2.c} {} "libpr14862.so"} + {"Build libneeded1b.so" + "-shared" "-fPIC" + {needed1b.c} {} "libneeded1b.so"} + {"Build libneeded1a.so" + "-shared -Wl,--add-needed,--no-as-needed -Ltmpdir -lneeded1b" "-fPIC" + {needed1a.c} {} "libneeded1a.so"} + {"Build libneeded1c.o" + "-r -nostdlib" "" + {needed1c.c} {} "libneeded1c.o"} + {"Build libneeded1pic.o" + "-r -nostdlib" "-fPIC" + {needed1c.c} {} "libneeded1pic.o"} + {"Build needed1a.so with --add-needed" + "-shared tmpdir/libneeded1pic.o -Wl,--add-needed,-rpath=tmpdir,-z,defs -Ltmpdir -lneeded1a" "" + {dummy.c} {} "needed1a.so"} + {"Build needed1b.so with --copy-dt-needed-entries" + "-shared tmpdir/libneeded1pic.o -Wl,--copy-dt-needed-entries,-rpath=tmpdir,-z,defs -Ltmpdir -lneeded1a" "" + {dummy.c} {} "needed1b.so"} + {"Build needed1a.so with --no-add-needed" + "-shared tmpdir/libneeded1pic.o -Wl,--no-add-needed -Ltmpdir -lneeded1a" "" + {dummy.c} {} "needed1c.so"} + {"Build needed1b.so with --no-copy-dt-needed-entries" + "-shared tmpdir/libneeded1pic.o -Wl,--no-copy-dt-needed-entries -Ltmpdir -lneeded1a" "" + {dummy.c} {} "needed1d.so"} + {"Build librel.so" + "-shared" "-fPIC" + {rel.c} {} "librel.so"} +} + +run_cc_link_tests $build_tests + +set run_tests { + {"Run normal with libfoo.so" + "tmpdir/begin.o tmpdir/libfoo.so tmpdir/end.o" "" + {main.c} "normal" "normal.out"} + {"Run protected with libfoo.so" + "tmpdir/begin.o tmpdir/libfoo.so tmpdir/endprotected.o" "" + {main.c} "protected" "normal.out"} + {"Run hidden with libfoo.so" + "tmpdir/begin.o tmpdir/libfoo.so tmpdir/endhidden.o" "" + {main.c} "hidden" "hidden.out"} + {"Run normal with versioned libfoo.so" + "tmpdir/begin.o tmpdir/libfoov.so tmpdir/end.o" "" + {main.c} "normalv" "normal.out"} + {"Run warn with versioned libfoo.so" + "tmpdir/beginwarn.o tmpdir/libfoov.so" "" + {main.c} "warn" "warn.out" + "" "" "^.*\\\): warning: function foo is deprecated$"} + {"Run protected with versioned libfoo.so" + "tmpdir/begin.o tmpdir/libfoov.so tmpdir/endprotected.o" "" + {main.c} "protected" "normal.out"} + {"Run hidden with versioned libfoo.so" + "tmpdir/begin.o tmpdir/libfoov.so tmpdir/endhidden.o" "" + {main.c} "hiddenv" "hidden.out"} + {"Run normal libbar.so with libfoo.so" + "tmpdir/libbarfoo.so tmpdir/libfoo.so" "" + {main.c} "normal" "normal.out"} + {"Run protected libbar.so with libfoo.so" + "tmpdir/libbarpfoo.so tmpdir/libfoo.so" "" + {main.c} "protected" "normal.out"} + {"Run hidden libbar.so with libfoo.so" + "tmpdir/libbarhfoo.so tmpdir/libfoo.so" "" + {main.c} "hidden" "hidden.out"} + {"Run normal libbar.so with versioned libfoo.so" + "tmpdir/libbarfoov.so tmpdir/libfoov.so" "" + {main.c} "normal" "normal.out"} + {"Run protected libbar.so with versioned libfoo.so" + "tmpdir/libbarpfoov.so tmpdir/libfoov.so" "" + {main.c} "protected" "normal.out"} + {"Run hidden libbar.so with versioned libfoo.so" + "tmpdir/libbarhfoov.so tmpdir/libfoov.so" "" + {main.c} "hidden" "hidden.out"} + {"Run dl1a with --dynamic-list=dl1.list and dlopen on libdl1.so" + "--dynamic-list=dl1.list -ldl" "" + {dl1main.c} "dl1a" "dl1.out"} + {"Run dl1b with --dynamic-list-data and dlopen on libdl1.so" + "--dynamic-list-data -ldl" "" + {dl1main.c} "dl1b" "dl1.out"} + {"Run with libdl2a.so" + "tmpdir/libdl2a.so" "" + {dl2main.c} "dl2a" "dl2a.out"} + {"Run with libdl2b.so" + "tmpdir/libdl2b.so" "" + {dl2main.c} "dl2b" "dl2b.out"} + {"Run with libdl2c.so" + "tmpdir/libdl2c.so" "" + {dl2main.c} "dl2c" "dl2b.out"} + {"Run with libdl4a.so" + "tmpdir/libdl4a.so" "" + {dl4main.c} "dl4a" "dl4a.out"} + {"Run with libdl4b.so" + "tmpdir/libdl4b.so" "" + {dl4main.c} "dl4b" "dl4a.out"} + {"Run with libdl4c.so" + "tmpdir/libdl4c.so" "" + {dl4main.c} "dl4c" "dl4b.out"} + {"Run with libdl4d.so" + "tmpdir/libdl4d.so" "" + {dl4main.c} "dl4d" "dl4b.out"} + {"Run with libdl4e.so" + "tmpdir/libdl4e.so" "" + {dl4main.c} "dl4e" "dl4a.out"} + {"Run with libdl4f.so" + "tmpdir/libdl4f.so" "" + {dl4main.c} "dl4f" "dl4a.out"} + {"Run dl6a1 with --dynamic-list-data and dlopen on libdl6a.so" + "--dynamic-list-data -ldl" "" + {dl6amain.c} "dl6a1" "dl6a.out"} + {"Run dl6a2 with -Bsymbolic-functions and dlopen on libdl6a.so" + "-Bsymbolic-functions -ldl" "" + {dl6amain.c} "dl6a2" "dl6b.out"} + {"Run dl6a3 with -Bsymbolic and dlopen on libdl6a.so" + "-Bsymbolic -ldl" "" + {dl6amain.c} "dl6a3" "dl6b.out"} + {"Run dl6a4 with -Bsymbolic --dynamic-list-data and dlopen on libdl6a.so" + "-Bsymbolic --dynamic-list-data -ldl" "" + {dl6amain.c} "dl6a4" "dl6a.out"} + {"Run dl6a5 with -Bsymbolic-functions --dynamic-list-cpp-new and dlopen on libdl6a.so" + "-Bsymbolic-functions --dynamic-list-cpp-new -ldl" "" + {dl6amain.c} "dl6a5" "dl6b.out"} + {"Run dl6a6 with --dynamic-list-cpp-new -Bsymbolic-functions and dlopen on libdl6a.so" + "--dynamic-list-cpp-new -Bsymbolic-functions -ldl" "" + {dl6amain.c} "dl6a6" "dl6b.out"} + {"Run dl6a7 with --dynamic-list-data -Bsymbolic and dlopen on libdl6a.so" + "--dynamic-list-data -Bsymbolic -ldl" "" + {dl6amain.c} "dl6a7" "dl6a.out"} + {"Run dl6b1 with --dynamic-list-data and dlopen on libdl6b.so" + "--dynamic-list-data -ldl" "" + {dl6bmain.c} "dl6b1" "dl6a.out"} + {"Run dl6b2 with dlopen on libdl6b.so" + "-ldl" "" + {dl6bmain.c} "dl6b2" "dl6b.out"} + {"Run dl6c1 with --dynamic-list-data and dlopen on libdl6c.so" + "--dynamic-list-data -ldl" "" + {dl6cmain.c} "dl6c1" "dl6b.out"} + {"Run dl6d1 with --dynamic-list-data and dlopen on libdl6d.so" + "--dynamic-list-data -ldl" "" + {dl6dmain.c} "dl6d1" "dl6b.out"} + {"Run with libdata1.so" + "tmpdir/libdata1.so" "" + {dynbss1.c} "dynbss1" "pass.out"} + {"Run with libdata2.so" + "tmpdir/libdata2.so" "" + {weakdef1.c} "weakdef1" "pass.out"} + {"Run with libfunc1.so comm1.o" + "tmpdir/libfunc1.so tmpdir/comm1.o" "" + {dummy.c} "comm1" "pass.out"} + {"Run with comm1.o libfunc1.so" + "tmpdir/comm1.o tmpdir/libfunc1.so" "" + {dummy.c} "comm1" "pass.out"} + {"Run with pr11138-2.c libpr11138-1.so" + "--version-script=pr11138-2.map tmpdir/pr11138-2.o tmpdir/libpr11138-1.so" "" + {dummy.c} "pr11138a" "pr11138.out"} + {"Run with libpr11138-1.so pr11138-2.c" + "--version-script=pr11138-2.map tmpdir/libpr11138-1.so tmpdir/pr11138-2.o" "" + {dummy.c} "pr11138b" "pr11138.out"} + {"Run with pr13250-3.c, libpr13250-1.so and libpr13250-2.so" + "--as-needed tmpdir/pr13250-3.o tmpdir/libpr13250-1.so tmpdir/libpr13250-2.so" "" + {dummy.c} "pr13250" "pass.out"} + {"Run with pr14323-1.c pr14323-2.so" + "tmpdir/libpr14323-2.so" "" + {pr14323-1.c} "pr14323" "pass.out"} + {"Run with pr14862-1.c libpr14862.so" + "--as-needed tmpdir/libpr14862-1.o tmpdir/libpr14862.so" "" + {dummy.c} "pr14862" "pr14862.out"} + {"Link with --add-needed" + "tmpdir/libneeded1c.o --add-needed -rpath=tmpdir -Ltmpdir -lneeded1a" "" + {dummy.c} "needed1a" "needed1.out"} + {"Link with --copy-dt-needed-entries" + "tmpdir/libneeded1c.o --copy-dt-needed-entries -rpath=tmpdir -Ltmpdir -lneeded1a" "" + {dummy.c} "needed1b" "needed1.out"} + {"Run relmain" + "--no-as-needed -rpath=tmpdir -Ltmpdir -lrel" "" + {relmain.c} "relmain" "relmain.out"} +} + +# NetBSD ELF systems do not currently support the .*_array sections. +run_ld_link_exec_tests [list "*-*-netbsdelf*"] $run_tests + +# Check --no-add-needed and --no-copy-dt-needed-entries +set testname "--no-add-needed" +set exec_output [run_host_cmd "$CC" "$gcc_gas_flag $gcc_ld_flag tmpdir/libneeded1c.o -Wl,--no-add-needed,-rpath-link=tmpdir -Ltmpdir -lneeded1a"] +if { [ regexp "tmpdir/libneeded1b.so: .*: DSO missing" $exec_output ] } { + pass $testname +} { + fail $testname +} +set testname "--no-copy-dt-needed-entries" +set exec_output [run_host_cmd "$CC" "$gcc_gas_flag $gcc_ld_flag tmpdir/libneeded1c.o -Wl,--no-copy-dt-needed-entries,-rpath-link=tmpdir -Ltmpdir -lneeded1a"] +if { [ regexp "tmpdir/libneeded1b.so: .*: DSO missing" $exec_output ] } { + pass $testname +} { + fail $testname +} +set testname "--no-add-needed -shared" +set exec_output [run_host_cmd "$CC" "$gcc_gas_flag $gcc_ld_flag -shared tmpdir/libneeded1pic.o -Wl,--no-add-needed,-z,defs -Ltmpdir -lneeded1a"] +if { [ regexp "undefined reference to `bar'" $exec_output ] } { + pass $testname +} { + fail $testname +} +set testname "--no-copy-dt-needed-entries -shared" +set exec_output [run_host_cmd "$CC" "$gcc_gas_flag $gcc_ld_flag -shared tmpdir/libneeded1pic.o -Wl,--no-copy-dt-needed-entries,-z,defs -Ltmpdir -lneeded1a"] +if { [ regexp "undefined reference to `bar'" $exec_output ] } { + pass $testname +} { + fail $testname +} + +# Check to see if the C++ compiler works +if { [which $CXX] == 0 } { + return +} + +set build_cxx_tests { + {"Build libdl3a.so with --dynamic-list=dl3.list" + "-shared -Wl,--dynamic-list=dl3.list" "-fPIC" + {dl3.cc} {} "libdl3a.so" "c++"} + {"Build libdl3b.so with -Bsymbolic" + "-shared -Wl,-Bsymbolic" "-fPIC" + {dl3.cc} {} "libdl3b.so" "c++"} + {"Build libdl3a.so with --dynamic-list-cpp-typeinfo" + "-shared -Wl,--dynamic-list-cpp-typeinfo" "-fPIC" + {dl3.cc} {} "libdl3c.so" "c++"} + {"Build libdnew1a.so with --Bsymbolic-functions --dynamic-list-cpp-new" + "-shared -Wl,-Bsymbolic-functions,--dynamic-list-cpp-new" "-fPIC" + {del.cc new.cc} {} "libnew1a.so" "c++"} + {"Build libdnew1b.so with --dynamic-list-data --dynamic-list-cpp-new" + "-shared -Wl,--dynamic-list-data,--dynamic-list-cpp-new" "-fPIC" + {del.cc new.cc} {} "libnew1b.so" "c++"} +} + +# "-shared -Bsymbolic" only works with gcc 4.5.0 and newer. +# {"Run with libdl3b.so" +# "tmpdir/libdl3b.so" "" +# {dl3main.cc} "dl3b" "dl3b.out" "" "c++"} +set run_cxx_tests { + {"Run with libdl3a.so" + "-Wl,--no-as-needed tmpdir/libdl3a.so" "" + {dl3main.cc} "dl3a" "dl3a.out" "" "c++"} + {"Run with libdl3c.so" + "-Wl,--no-as-needed tmpdir/libdl3c.so" "" + {dl3main.cc} "dl3c" "dl3a.out" "" "c++"} + {"Run with libnew1a.so" + "tmpdir/libnew1a.so" "" + {dl5.cc} "dl5a" "dl5.out" "" "c++"} + {"Run with libnew1b.so" + "tmpdir/libnew1b.so" "" + {dl5.cc} "dl5b" "dl5.out" "" "c++"} +} + +run_cc_link_tests $build_cxx_tests +run_ld_link_exec_tests [] $run_cxx_tests diff --git a/binutils-2.25/ld/testsuite/ld-elf/simple.s b/binutils-2.25/ld/testsuite/ld-elf/simple.s new file mode 100644 index 0000000..2834182 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/simple.s @@ -0,0 +1,4 @@ + .text + .long 1 + .data + .long 2 diff --git a/binutils-2.25/ld/testsuite/ld-elf/stab.d b/binutils-2.25/ld/testsuite/ld-elf/stab.d new file mode 100644 index 0000000..346640d --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/stab.d @@ -0,0 +1,14 @@ +#source: start.s +#as: -gstabs +#readelf: -S --wide +#ld: +#notarget: "ia64-*-*" "alpha*" + +# Disabled on alpha because the entry point may be above 4GB but the stabs +# value on 32 bits. + +#... + \[[0-9 ][0-9]\] \.stab +PROGBITS +0+ [0-9a-f]+ [0-9a-f]+ [0-9a-f]+ +[1-9]+ +0.* +#... + \[[0-9 ][0-9]\] \.stabstr +STRTAB +0+ [0-9a-f]+ [0-9a-f]+ 00 +0 +0.* +#... diff --git a/binutils-2.25/ld/testsuite/ld-elf/stack-exec.rd b/binutils-2.25/ld/testsuite/ld-elf/stack-exec.rd new file mode 100644 index 0000000..7f68a6c --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/stack-exec.rd @@ -0,0 +1,3 @@ +#... + GNU_STACK 0x0+00000 0x0+000000 0x0+000000 0x0+000 0x.+0000 RWE 0x[0-9a-f]+ +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/stack-size.rd b/binutils-2.25/ld/testsuite/ld-elf/stack-size.rd new file mode 100644 index 0000000..413db3a --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/stack-size.rd @@ -0,0 +1,3 @@ +#... + GNU_STACK 0x0+00000 0x0+000000 0x0+000000 0x0+000 0x123400 RW. 0x[0-9a-f]+ +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/stack.s b/binutils-2.25/ld/testsuite/ld-elf/stack.s new file mode 100644 index 0000000..259e62c --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/stack.s @@ -0,0 +1,6 @@ + .text + .globl start + .globl _start +start: +_start: + .long 0 diff --git a/binutils-2.25/ld/testsuite/ld-elf/start.s b/binutils-2.25/ld/testsuite/ld-elf/start.s new file mode 100644 index 0000000..d8655be --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/start.s @@ -0,0 +1,10 @@ + .text + .global start /* Used by SH targets. */ +start: + .global _start +_start: + .global __start +__start: + .global main /* Used by HPPA targets. */ +main: + .dc.a 0 diff --git a/binutils-2.25/ld/testsuite/ld-elf/symbol1ref.s b/binutils-2.25/ld/testsuite/ld-elf/symbol1ref.s new file mode 100644 index 0000000..99df499 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/symbol1ref.s @@ -0,0 +1,3 @@ + .data + .dc.a symbol1 + diff --git a/binutils-2.25/ld/testsuite/ld-elf/symbol1w.s b/binutils-2.25/ld/testsuite/ld-elf/symbol1w.s new file mode 100644 index 0000000..38778d3 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/symbol1w.s @@ -0,0 +1,10 @@ + .section .gnu.warning.symbol1 + .asciz "witty one-liner" + .text + .type symbol1,"function" + .global symbol1 +symbol1: +.L1: + .long 0 +.L0: + .size symbol1,.L0-.L1 diff --git a/binutils-2.25/ld/testsuite/ld-elf/symbol2ref.s b/binutils-2.25/ld/testsuite/ld-elf/symbol2ref.s new file mode 100644 index 0000000..0a1a9eb --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/symbol2ref.s @@ -0,0 +1,3 @@ + .data + .dc.a Foo + diff --git a/binutils-2.25/ld/testsuite/ld-elf/symbol2w.s b/binutils-2.25/ld/testsuite/ld-elf/symbol2w.s new file mode 100644 index 0000000..794a753 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/symbol2w.s @@ -0,0 +1,6 @@ + .section .gnu.warning,"a",%progbits + .global Foo + .type Foo, %object + .size Foo, 20 +Foo: + .string "function 'Foo' used" diff --git a/binutils-2.25/ld/testsuite/ld-elf/symbol3.s b/binutils-2.25/ld/testsuite/ld-elf/symbol3.s new file mode 100644 index 0000000..4fd76d5 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/symbol3.s @@ -0,0 +1 @@ + .comm badsym,4 diff --git a/binutils-2.25/ld/testsuite/ld-elf/symbol3w.s b/binutils-2.25/ld/testsuite/ld-elf/symbol3w.s new file mode 100644 index 0000000..33262a6 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/symbol3w.s @@ -0,0 +1,4 @@ + .data + .dc.a badsym + .section .gnu.warning.badsym,"",%progbits + .string "badsym warning" diff --git a/binutils-2.25/ld/testsuite/ld-elf/table.s b/binutils-2.25/ld/testsuite/ld-elf/table.s new file mode 100644 index 0000000..2b13f70 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/table.s @@ -0,0 +1 @@ + .section .gcc_except_table,"a",%progbits diff --git a/binutils-2.25/ld/testsuite/ld-elf/tbss.s b/binutils-2.25/ld/testsuite/ld-elf/tbss.s new file mode 100644 index 0000000..cc43340 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/tbss.s @@ -0,0 +1,15 @@ + .file "x.c" + .globl bss + .section .bss,"aw",%nobits + .p2align 12 + .type bss,%object + .size bss,4096 +bss: + .zero 4096 + .globl tbss + .section .tbss,"awT",%nobits + .p2align 12 + .type tbss,%object + .size tbss,4096 +tbss: + .zero 4096 diff --git a/binutils-2.25/ld/testsuite/ld-elf/tbss1.s b/binutils-2.25/ld/testsuite/ld-elf/tbss1.s new file mode 100644 index 0000000..4f1631f --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/tbss1.s @@ -0,0 +1,24 @@ + .globl main + .globl start + .globl _start + .globl __start + .text +main: +start: +_start: +__start: + .byte 0 + .globl bss + .section .bss,"aw",%nobits + .p2align 12 + .type bss,%object + .size bss,4096 +bss: + .zero 4096 + .globl tbss + .section .tbss,"awT",%nobits + .p2align 12 + .type tbss,%object + .size tbss,4096 +tbss: + .zero 4096 diff --git a/binutils-2.25/ld/testsuite/ld-elf/tbss2.s b/binutils-2.25/ld/testsuite/ld-elf/tbss2.s new file mode 100644 index 0000000..b980925 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/tbss2.s @@ -0,0 +1,16 @@ + .globl main + .globl start + .globl _start + .globl __start + .text +main: +start: +_start: +__start: + .byte 0 + .globl tbss + .section .tbss,"awT",%nobits + .type tbss,%object + .size tbss,1 +tbss: + .zero 1 diff --git a/binutils-2.25/ld/testsuite/ld-elf/tbss3.s b/binutils-2.25/ld/testsuite/ld-elf/tbss3.s new file mode 100644 index 0000000..f5530a3 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/tbss3.s @@ -0,0 +1,17 @@ + .globl main + .globl start + .globl _start + .globl __start + .text +main: +start: +_start: +__start: + .byte 0 + + .section .tbss,"awT",%nobits + .p2align 10 + .type tbss, %object + .size tbss, 1024 +tbss: + .zero 1024 diff --git a/binutils-2.25/ld/testsuite/ld-elf/tdata1.s b/binutils-2.25/ld/testsuite/ld-elf/tdata1.s new file mode 100644 index 0000000..6ea57b6 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/tdata1.s @@ -0,0 +1,24 @@ + .globl main + .globl start + .globl _start + .globl __start + .text +main: +start: +_start: +__start: + .byte 0 + .globl data + .section .data,"aw",%progbits + .p2align 4 + .type data,%object + .size data,4096 +data: + .zero 4096 + .globl tdata + .section .tdata,"awT",%progbits + .p2align 4 + .type tdata,%object + .size tdata,4096 +tdata: + .zero 4096 diff --git a/binutils-2.25/ld/testsuite/ld-elf/tdata2.s b/binutils-2.25/ld/testsuite/ld-elf/tdata2.s new file mode 100644 index 0000000..1da459f --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/tdata2.s @@ -0,0 +1,16 @@ + .globl main + .globl start + .globl _start + .globl __start + .text +main: +start: +_start: +__start: + .byte 0 + .globl tdata + .section .tdata,"awT",%progbits + .type tdata,%object + .size tdata,1 +tdata: + .byte 0 diff --git a/binutils-2.25/ld/testsuite/ld-elf/tdata3.s b/binutils-2.25/ld/testsuite/ld-elf/tdata3.s new file mode 100644 index 0000000..8886360 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/tdata3.s @@ -0,0 +1,23 @@ + .globl main + .globl start + .globl _start + .globl __start + .text +main: +start: +_start: +__start: + .byte 0 + + .section .tdata,"awT",%progbits + .type tdata,%object + .size tdata,1 +tdata: + .byte 17 + + .section .tbss,"awT",%nobits + .p2align 10 + .type tbss, %object + .size tbss, 1024 +tbss: + .zero 1024 diff --git a/binutils-2.25/ld/testsuite/ld-elf/textaddr1.d b/binutils-2.25/ld/testsuite/ld-elf/textaddr1.d new file mode 100644 index 0000000..e1d6731 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/textaddr1.d @@ -0,0 +1,8 @@ +#source: maxpage1.s +#ld: -Ttext-segment 0x7000000 -z max-page-size=0x200000 +#readelf: -l --wide +#target: *-*-linux-gnu *-*-gnu* + +#... + LOAD +0x0+ 0x0*7000000 0x0*7000000 0x0*[0-9a-f][0-9a-f][0-9a-f] 0x0*[0-9a-f][0-9a-f][0-9a-f] R E 0x200000 +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/textaddr2.d b/binutils-2.25/ld/testsuite/ld-elf/textaddr2.d new file mode 100644 index 0000000..bcd3658 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/textaddr2.d @@ -0,0 +1,8 @@ +#source: maxpage1.s +#ld: -shared -Ttext-segment 0x7000000 -z max-page-size=0x200000 +#readelf: -l --wide +#target: *-*-linux-gnu *-*-gnu* + +#... + LOAD +0x0+ 0x0*7000000 0x0*7000000 0x0*[0-9a-f]+ 0x0*[0-9a-f]+ R[ W]E 0x200000 +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/textaddr3.d b/binutils-2.25/ld/testsuite/ld-elf/textaddr3.d new file mode 100644 index 0000000..29ed498 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/textaddr3.d @@ -0,0 +1,4 @@ +#source: maxpage1.s +#ld: -Ttext-segment 0x10000 -z max-page-size=0x200000 +#target: *-*-linux-gnu *-*-gnu* +#warning: .*address of `text-segment' isn't multiple of maximum page size diff --git a/binutils-2.25/ld/testsuite/ld-elf/textaddr4.d b/binutils-2.25/ld/testsuite/ld-elf/textaddr4.d new file mode 100644 index 0000000..16df9a8 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/textaddr4.d @@ -0,0 +1,8 @@ +#source: maxpage1.s +#ld: -z max-page-size=0x10000 -Ttext-segment 0x10000 +#readelf: -l --wide +#target: *-*-linux-gnu *-*-gnu* + +#... + LOAD +0x0+ 0x0*10000 0x0*10000 0x0*[0-9a-f][0-9a-f][0-9a-f] 0x0*[0-9a-f][0-9a-f][0-9a-f] R E 0x10000 +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/textaddr5.d b/binutils-2.25/ld/testsuite/ld-elf/textaddr5.d new file mode 100644 index 0000000..41d00c5 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/textaddr5.d @@ -0,0 +1,4 @@ +#source: maxpage1.s +#ld: -shared -z max-page-size=0x200000 -Ttext-segment 0x10000 +#target: *-*-linux-gnu *-*-gnu* +#warning: .*address of `text-segment' isn't multiple of maximum page size diff --git a/binutils-2.25/ld/testsuite/ld-elf/textaddr6.d b/binutils-2.25/ld/testsuite/ld-elf/textaddr6.d new file mode 100644 index 0000000..584784b --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/textaddr6.d @@ -0,0 +1,8 @@ +#source: maxpage1.s +#ld: -shared -z max-page-size=0x10000 -Ttext-segment 0x10000 +#readelf: -l --wide +#target: *-*-linux-gnu *-*-gnu* + +#... + LOAD +0x0+ 0x0*10000 0x0*10000 0x0*[0-9a-f]+ 0x0*[0-9a-f]+ R[ W]E 0x10000 +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/textaddr7.d b/binutils-2.25/ld/testsuite/ld-elf/textaddr7.d new file mode 100644 index 0000000..b4237db --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/textaddr7.d @@ -0,0 +1,8 @@ +#source: maxpage1.s +#ld: -n -z max-page-size=0x200000 -Ttext-segment 0x10000 +#readelf: -l --wide +#target: *-*-linux-gnu *-*-gnu* + +#... + LOAD .* +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/tls_common.exp b/binutils-2.25/ld/testsuite/ld-elf/tls_common.exp new file mode 100644 index 0000000..fee4031 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/tls_common.exp @@ -0,0 +1,73 @@ +# Expect script for .tls_common tests +# Copyright 2006, 2007, 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 Jakub Jelinek (jakub@redhat.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 +} + +global as +global ld +global READELF +global srcdir +global subdir +global link_output + +if { ![ld_assemble $as $srcdir/$subdir/tls_common.s tmpdir/tls_common.o ] } { + unresolved "tls_common" + return +} + +if { ![ld_simple_link $ld tmpdir/tls_common1.o "-r tmpdir/tls_common.o"] } { + fail "tls_common" + return +} + +if { ![ld_simple_link $ld tmpdir/tls_common "tmpdir/tls_common1.o"] } { + if { [string match "*not supported*" $link_output] + || [string match "*unrecognized option*" $link_output] } { + unsupported "$ld_options is not supported by this target" + } elseif { [string match "*Warning*alignment*of common symbol*" $link_output] } { + fail "tls_common" + } else { + unresolved "tls_common" + } + return +} + +set readelf_output [run_host_cmd "$READELF" "-l --wide tmpdir/tls_common"] +if ![regexp ".*TLS.*0x0+ 0x0+4 R .*" $readelf_output] then { + send_log "$readelf_output\n" + fail "tls_common" + return +} + +pass "tls_common" diff --git a/binutils-2.25/ld/testsuite/ld-elf/tls_common.s b/binutils-2.25/ld/testsuite/ld-elf/tls_common.s new file mode 100644 index 0000000..502d8f3 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/tls_common.s @@ -0,0 +1,11 @@ + .globl main + .globl start + .globl _start + .globl __start + .text +main: +start: +_start: +__start: + .byte 0 + .tls_common foo,4,4 diff --git a/binutils-2.25/ld/testsuite/ld-elf/tls_gc.s b/binutils-2.25/ld/testsuite/ld-elf/tls_gc.s new file mode 100644 index 0000000..db93eba --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/tls_gc.s @@ -0,0 +1,16 @@ + .globl main + .globl start + .globl _start + .globl __start + .text +main: +start: +_start: +__start: + .byte 0 + .globl var + .section .tbss.var,"awT",%nobits + .type var,%object + .size var,1 +var: + .zero 1 diff --git a/binutils-2.25/ld/testsuite/ld-elf/unknown.d b/binutils-2.25/ld/testsuite/ld-elf/unknown.d new file mode 100644 index 0000000..636e6c7 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/unknown.d @@ -0,0 +1,7 @@ +#source: ../../../binutils/testsuite/binutils-all/unknown.s +#ld: -r +#readelf: -S + +#... + \[[ 0-9]+\] \.foo[ \t]+NOTE[ \t]+.* +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/unknown2.d b/binutils-2.25/ld/testsuite/ld-elf/unknown2.d new file mode 100644 index 0000000..8d6cdee --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/unknown2.d @@ -0,0 +1,8 @@ +#source: unknown2.s +#ld: -shared +#readelf: -S +#target: *-*-linux* *-*-gnu* + +#... + \[[ 0-9]+\] \.note.foo[ \t]+NOTE[ \t]+.* +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/unknown2.s b/binutils-2.25/ld/testsuite/ld-elf/unknown2.s new file mode 100644 index 0000000..8592820 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/unknown2.s @@ -0,0 +1,6 @@ + .section .note.foo,"a","note" + .space 16 + .section .data,"aw" + .space 3800 + .section .rodata,"a" + .space 4 diff --git a/binutils-2.25/ld/testsuite/ld-elf/var1.d b/binutils-2.25/ld/testsuite/ld-elf/var1.d new file mode 100644 index 0000000..718efb7 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/var1.d @@ -0,0 +1,10 @@ +#ld: $srcdir/$subdir/var1.t --sort-section name +#nm: -n + +#... +[0-9a-f]* D var1 +#... +[0-9a-f]*3 A var2 +#... +[0-9a-f]* D var3 +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/var1.s b/binutils-2.25/ld/testsuite/ld-elf/var1.s new file mode 100644 index 0000000..58bc931 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/var1.s @@ -0,0 +1,31 @@ + .globl main + .globl start + .globl _start + .globl __start + .text +main: +start: +_start: +__start: + .byte 0 + .globl var3 + .section .data.var3,"aw",%progbits + .p2align 2 + .type var3, %object + .size var3, 4 +var3: + .zero 4 + .globl var2 + .section .data.var2,"aw",%progbits + .p2align 4 + .type var2, %object + .size var2, 16 +var2: + .zero 16 + .globl var1 + .section .data.var1,"aw",%progbits + .p2align 2 + .type var1, %object + .size var1, 4 +var1: + .zero 4 diff --git a/binutils-2.25/ld/testsuite/ld-elf/var1.t b/binutils-2.25/ld/testsuite/ld-elf/var1.t new file mode 100644 index 0000000..6b9502c --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/var1.t @@ -0,0 +1 @@ +var2 = var2 + 3; diff --git a/binutils-2.25/ld/testsuite/ld-elf/warn.out b/binutils-2.25/ld/testsuite/ld-elf/warn.out new file mode 100644 index 0000000..ba836ce --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/warn.out @@ -0,0 +1,3 @@ +TEST2 +TEST2 +MAIN diff --git a/binutils-2.25/ld/testsuite/ld-elf/warn1.d b/binutils-2.25/ld/testsuite/ld-elf/warn1.d new file mode 100644 index 0000000..3ef5032 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/warn1.d @@ -0,0 +1,15 @@ +#source: start.s +#source: symbol1ref.s +#source: symbol1w.s +#ld: -T group.ld +#warning: ^[^\\n]*\): warning: witty one-liner$ +#readelf: -s +#notarget: "sparc64-*-solaris2*" "sparcv9-*-solaris2*" +#xfail: "arc-*-*" "d30v-*-*" "dlx-*-*" "i960-*-*" "or32-*-*" "pj-*-*" + +# Check that warnings are generated for the .gnu.warning.SYMBOL +# construct and that the symbol still appears as expected. + +#... + +[0-9]+: +[0-9a-f]+ +[48] +FUNC +GLOBAL +DEFAULT +[1-9] symbol1 +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/warn2.d b/binutils-2.25/ld/testsuite/ld-elf/warn2.d new file mode 100644 index 0000000..95b7ef4 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/warn2.d @@ -0,0 +1,17 @@ +#source: start.s +#source: symbol2ref.s +#source: symbol2w.s +#ld: -T group.ld +#warning: ^[^\\n]*\.[obj]+: warning: function 'Foo' used$ +#readelf: -s +#notarget: "sparc64-*-solaris2*" "sparcv9-*-solaris2*" +#xfail: arc-*-* d30v-*-* dlx-*-* fr30-*-* frv-*-elf i860-*-* i960-*-* +#xfail: iq*-*-* mn10200-*-* moxie-*-* msp*-*-* mt-*-* or32-*-* pj*-*-* +# if not using elf32.em, you don't get fancy section handling + +# Check that warnings are generated for the symbols in .gnu.warning +# construct and that the symbol still appears as expected. + +#... + +[0-9]+: +[0-9a-f]+ +20 +OBJECT +GLOBAL +DEFAULT +[1-9] Foo +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/warn3.d b/binutils-2.25/ld/testsuite/ld-elf/warn3.d new file mode 100644 index 0000000..53dee18 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/warn3.d @@ -0,0 +1,14 @@ +#source: start.s +#ld: tmpdir/symbol3w.o tmpdir/symbol3.a +#warning: .*: warning: badsym warning$ +#readelf: -s +#notarget: hppa64*-hpux* +#xfail: arc-*-* d30v-*-* dlx-*-* i960-*-* or32-*-* pj*-*-* +# generic linker targets don't support .gnu.warning sections. + +# Check that warnings are generated for the symbols in .gnu.warning +# construct and that the symbol still appears as expected. + +#... + +[0-9]+: +[0-9a-f]+ +4 +OBJECT +GLOBAL +DEFAULT +[1-9] badsym +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/weak-dyn-1.ld b/binutils-2.25/ld/testsuite/ld-elf/weak-dyn-1.ld new file mode 100644 index 0000000..495b712 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/weak-dyn-1.ld @@ -0,0 +1,8 @@ +SECTIONS +{ + . = 0x800000; + PROVIDE (bar = .); + .data : { + *(.data) + } +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/weak-dyn-1.rd b/binutils-2.25/ld/testsuite/ld-elf/weak-dyn-1.rd new file mode 100644 index 0000000..ab5e0ba --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/weak-dyn-1.rd @@ -0,0 +1,3 @@ +#... +.* foo.* +#pass diff --git a/binutils-2.25/ld/testsuite/ld-elf/weak-dyn-1a.s b/binutils-2.25/ld/testsuite/ld-elf/weak-dyn-1a.s new file mode 100644 index 0000000..bb81d3a --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/weak-dyn-1a.s @@ -0,0 +1,13 @@ + .globl foo + .weak foo + .type foo,%object + .size foo,1 + + .globl bar + .type bar,%object + .size bar,1 + + .data +foo: +bar: + .byte 1 diff --git a/binutils-2.25/ld/testsuite/ld-elf/weak-dyn-1b.s b/binutils-2.25/ld/testsuite/ld-elf/weak-dyn-1b.s new file mode 100644 index 0000000..23f187a --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/weak-dyn-1b.s @@ -0,0 +1,2 @@ + .data + .dc.a foo diff --git a/binutils-2.25/ld/testsuite/ld-elf/weakdef1.c b/binutils-2.25/ld/testsuite/ld-elf/weakdef1.c new file mode 100644 index 0000000..82642bb --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/weakdef1.c @@ -0,0 +1,15 @@ +#include <stdio.h> +#include <stdlib.h> + +extern int foo_alias; +extern void bar (void); + +int +main (void) +{ + bar (); + if (foo_alias != -1) + abort (); + printf ("PASS\n"); + return 0; +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/wrap.exp b/binutils-2.25/ld/testsuite/ld-elf/wrap.exp new file mode 100644 index 0000000..70e433d --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/wrap.exp @@ -0,0 +1,57 @@ +# Expect script for wrap ELF tests. +# Copyright 2006, 2007 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. +# + +# Exclude non-ELF targets. + +if ![is_elf_format] { + return +} + +# The following tests require running the executable generated by ld. +if ![isnative] { + return +} + +# Check if compiler works +if { [which $CC] == 0 } { + return +} + +set build_tests { + {"Build libwrap1a.so" + "-shared" "-fPIC" + {wrap1a.c} {} "libwrap1a.so"} + {"Build libwrap1b.so" + "-shared tmpdir/libwrap1a.so" "-fPIC" + {wrap1b.c} {} "libwrap1b.so"} +} + +set run_tests { + {"Run with libwrap1a.so and libwrap1b.so" + "--wrap par tmpdir/libwrap1a.so tmpdir/libwrap1b.so" "" + {wrap1.c} "wrap1" "wrap1.out"} + {"Run with libwrap1b.so and libwrap1a.so" + "--wrap par tmpdir/libwrap1b.so tmpdir/libwrap1a.so" "" + {wrap1.c} "wrap1" "wrap1.out"} +} + +run_cc_link_tests $build_tests +run_ld_link_exec_tests [] $run_tests diff --git a/binutils-2.25/ld/testsuite/ld-elf/wrap1.c b/binutils-2.25/ld/testsuite/ld-elf/wrap1.c new file mode 100644 index 0000000..1ff250e --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/wrap1.c @@ -0,0 +1,8 @@ +extern void par (void); + +int +main (void) +{ + par (); + return 0; +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/wrap1.out b/binutils-2.25/ld/testsuite/ld-elf/wrap1.out new file mode 100644 index 0000000..7c1938f --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/wrap1.out @@ -0,0 +1,3 @@ +__wrap_par +__real_par +par diff --git a/binutils-2.25/ld/testsuite/ld-elf/wrap1a.c b/binutils-2.25/ld/testsuite/ld-elf/wrap1a.c new file mode 100644 index 0000000..75c94e0 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/wrap1a.c @@ -0,0 +1,6 @@ +#include <stdio.h> + +void par (void) +{ + printf ("par\n"); +} diff --git a/binutils-2.25/ld/testsuite/ld-elf/wrap1b.c b/binutils-2.25/ld/testsuite/ld-elf/wrap1b.c new file mode 100644 index 0000000..abd39aa --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-elf/wrap1b.c @@ -0,0 +1,16 @@ +#include <stdio.h> + +extern void par (void); + +void __real_par (void) +{ + printf ("__real_par \n"); + par (); +} + +void +__wrap_par (void) +{ + printf ("__wrap_par \n"); + __real_par (); +} |