diff options
author | Doug Kwan <dougkwan@google.com> | 2009-10-16 18:56:07 +0000 |
---|---|---|
committer | Doug Kwan <dougkwan@google.com> | 2009-10-16 18:56:07 +0000 |
commit | 3c12dcdba03d51b78e80c1847f249787d39cd572 (patch) | |
tree | fe93ffbc7f8c85217450c21ab466eb027cee43d6 /gold/testsuite | |
parent | 64b1ae3731ea1d8ffe5bcd0a4b1046921c869fa4 (diff) | |
download | gdb-3c12dcdba03d51b78e80c1847f249787d39cd572.zip gdb-3c12dcdba03d51b78e80c1847f249787d39cd572.tar.gz gdb-3c12dcdba03d51b78e80c1847f249787d39cd572.tar.bz2 |
2009-10-16 Doug Kwan <dougkwan@google.com>
* expression.cc (class Segment_start_expression): New class definition.
(Segment_start_expression::value): New method definition.
(script_exp_function_segment_start): Return a new
Segment_start_expression.
* gold/script-c.h (script_saw_segment_start_expression): New function
prototype.
* script-sections.cc (Script_sections::Script_sections): Initialize
SAW_SEGMENT_START_EXPRESSION_ to false.
(Script_sections::set_section_addresses): Use -Ttext, -Tdata
and -Tbbs options to specify section addresses if given in
command line and no SEGMENT_START expression is seen in a script.
* script-sections.h (Script_sections::saw_segment_start_expression,
Script_sections::set_saw_segment_start_expression): New method
definition.
(Script_sections::saw_segment_start_expression_): New data member
declaration.
* script.cc (script_saw_segment_start_expression): New function.
* yyscript.y (SEGMENT_START): Call script_saw_segment_start_expression.
* testsuite/Makefile.am (check_SCRIPTS): Add script_test_6.sh,
script_test_7.sh and script_test_8.sh.
(check_DATA): Add script_test_6.stdout, script_test_7.stdout and
script_test_8.stdout.
(MOSTLYCLEANFILES): Add script_test_6, script_test_7 and script_test_8.
(script_test_6, script_test_6.stdout, script_test_7,
script_test_7.stdout, script_test_8, script_test_8.stdout): New rules.
* Makefile.in: Regenerate.
* testsuite/script_test_6.sh: New file.
* testsuite/script_test_6.t: Same.
* testsuite/script_test_7.sh: Same.
* testsuite/script_test_7.t: Same.
* testsuite/script_test_8.sh: Same.
Diffstat (limited to 'gold/testsuite')
-rw-r--r-- | gold/testsuite/Makefile.am | 26 | ||||
-rw-r--r-- | gold/testsuite/Makefile.in | 29 | ||||
-rwxr-xr-x | gold/testsuite/script_test_6.sh | 43 | ||||
-rw-r--r-- | gold/testsuite/script_test_6.t | 41 | ||||
-rwxr-xr-x | gold/testsuite/script_test_7.sh | 43 | ||||
-rw-r--r-- | gold/testsuite/script_test_7.t | 41 | ||||
-rwxr-xr-x | gold/testsuite/script_test_8.sh | 44 |
7 files changed, 263 insertions, 4 deletions
diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am index 09d7325..6fa1e18 100644 --- a/gold/testsuite/Makefile.am +++ b/gold/testsuite/Makefile.am @@ -1009,6 +1009,32 @@ script_test_5: script_test_5.o gcctestdir/ld $(srcdir)/script_test_5.t script_test_5.stdout: script_test_5 $(TEST_READELF) -SW script_test_5 > script_test_5.stdout +check_SCRIPTS += script_test_6.sh +check_DATA += script_test_6.stdout +MOSTLYCLEANFILES += script_test_6 +script_test_6: basic_test.o gcctestdir/ld $(srcdir)/script_test_6.t + $(CXXLINK) -Bgcctestdir/ basic_test.o -T $(srcdir)/script_test_6.t \ + -Wl,-Ttext=0x10001000 -Wl,-Tdata=0x10200000 -Wl,-Tbss=0x10400000 +script_test_6.stdout: script_test_6 + $(TEST_READELF) -SlW script_test_6 > script_test_6.stdout + +check_SCRIPTS += script_test_7.sh +check_DATA += script_test_7.stdout +MOSTLYCLEANFILES += script_test_7 +script_test_7: basic_test.o gcctestdir/ld $(srcdir)/script_test_7.t + $(CXXLINK) -Bgcctestdir/ basic_test.o -T $(srcdir)/script_test_7.t +script_test_7.stdout: script_test_7 + $(TEST_READELF) -SlW script_test_7 > script_test_7.stdout + +check_SCRIPTS += script_test_8.sh +check_DATA += script_test_8.stdout +MOSTLYCLEANFILES += script_test_8 +script_test_8: basic_test.o gcctestdir/ld $(srcdir)/script_test_7.t + $(CXXLINK) -Bgcctestdir/ basic_test.o -T $(srcdir)/script_test_7.t \ + -Wl,-Ttext=0x20001000 -Wl,-Tdata=0x20200000 -Wl,-Tbss=0x20400000 +script_test_8.stdout: script_test_8 + $(TEST_READELF) -SlW script_test_8 > script_test_8.stdout + # Test --dynamic-list, --dynamic-list-data, --dynamic-list-cpp-new, # and --dynamic-list-cpp-typeinfo diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in index 3f5459f..193888a 100644 --- a/gold/testsuite/Makefile.in +++ b/gold/testsuite/Makefile.in @@ -67,7 +67,10 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_matching_test.sh \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_3.sh \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_4.sh \ -@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_5.sh dynamic_list.sh +@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_5.sh \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_6.sh \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_7.sh \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_8.sh dynamic_list.sh # Create the data files that debug_msg.sh analyzes. @@ -92,6 +95,9 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_3.stdout \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_4.stdout \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_5.stdout \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_6.stdout \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_7.stdout \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_8.stdout \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ dynamic_list.stdout @GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_3 = gc_comdat_test \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_tls_test icf_test \ @@ -242,9 +248,10 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_matching_test.stdout \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_3.stdout \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_4 script_test_5 \ -@GCC_TRUE@@NATIVE_LINKER_TRUE@ dynamic_list dynamic_list.stdout \ -@GCC_TRUE@@NATIVE_LINKER_TRUE@ libthin1.a libthin3.a \ -@GCC_TRUE@@NATIVE_LINKER_TRUE@ libthinall.a \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_6 script_test_7 \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_8 dynamic_list \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ dynamic_list.stdout libthin1.a \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ libthin3.a libthinall.a \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ alt/thin_archive_test_2.o \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ alt/thin_archive_test_4.o \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ alt/libthin2.a alt/libthin4.a @@ -2972,6 +2979,20 @@ uninstall-am: @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ script_test_5.o -T $(srcdir)/script_test_5.t @GCC_TRUE@@NATIVE_LINKER_TRUE@script_test_5.stdout: script_test_5 @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_READELF) -SW script_test_5 > script_test_5.stdout +@GCC_TRUE@@NATIVE_LINKER_TRUE@script_test_6: basic_test.o gcctestdir/ld $(srcdir)/script_test_6.t +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ basic_test.o -T $(srcdir)/script_test_6.t \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ -Wl,-Ttext=0x10001000 -Wl,-Tdata=0x10200000 -Wl,-Tbss=0x10400000 +@GCC_TRUE@@NATIVE_LINKER_TRUE@script_test_6.stdout: script_test_6 +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_READELF) -SlW script_test_6 > script_test_6.stdout +@GCC_TRUE@@NATIVE_LINKER_TRUE@script_test_7: basic_test.o gcctestdir/ld $(srcdir)/script_test_7.t +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ basic_test.o -T $(srcdir)/script_test_7.t +@GCC_TRUE@@NATIVE_LINKER_TRUE@script_test_7.stdout: script_test_7 +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_READELF) -SlW script_test_7 > script_test_7.stdout +@GCC_TRUE@@NATIVE_LINKER_TRUE@script_test_8: basic_test.o gcctestdir/ld $(srcdir)/script_test_7.t +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ basic_test.o -T $(srcdir)/script_test_7.t \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ -Wl,-Ttext=0x20001000 -Wl,-Tdata=0x20200000 -Wl,-Tbss=0x20400000 +@GCC_TRUE@@NATIVE_LINKER_TRUE@script_test_8.stdout: script_test_8 +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_READELF) -SlW script_test_8 > script_test_8.stdout @GCC_TRUE@@NATIVE_LINKER_TRUE@dynamic_list: basic_test.o gcctestdir/ld $(srcdir)/dynamic_list.t @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ basic_test.o \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ -Wl,--dynamic-list $(srcdir)/dynamic_list.t \ diff --git a/gold/testsuite/script_test_6.sh b/gold/testsuite/script_test_6.sh new file mode 100755 index 0000000..bbc96d8 --- /dev/null +++ b/gold/testsuite/script_test_6.sh @@ -0,0 +1,43 @@ +#!/bin/sh + +# script_test_6.sh -- test for -Ttext, -Tdata and -Tbss with a script. + +# Copyright 2009 Free Software Foundation, Inc. +# Written by Doug Kwan <dougkwan@google.com>. + +# This file is part of gold. + +# 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. + +# This file goes with script_test_4.t, which is a linker script which +# starts the program at an unaligned address. + +check() +{ + if ! grep -q "$2" "$1" + then + echo "Did not find expected section in $1:" + echo " $2" + echo "" + echo "Actual output below:" + cat "$1" + exit 1 + fi +} + +check script_test_6.stdout "\\.text[ ]*PROGBITS[ ]*0*10001000" +check script_test_6.stdout "\\.data[ ]*PROGBITS[ ]*0*10200000" +check script_test_6.stdout "\\.bss[ ]*NOBITS[ ]*0*10400000" diff --git a/gold/testsuite/script_test_6.t b/gold/testsuite/script_test_6.t new file mode 100644 index 0000000..9676371 --- /dev/null +++ b/gold/testsuite/script_test_6.t @@ -0,0 +1,41 @@ +/* script_test_5.t -- linker script test 5 for gold + + Copyright 2009 Free Software Foundation, Inc. + Written by Cary Coutant <ccoutant@google.com>. + + This file is part of gold. + + 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. */ + +/* We won't try to run this program, just ensure that it links + as expected. */ + +SECTIONS +{ + . = 0x10000000; + + /* With luck this will be enough to get the program working. */ + .interp : { *(.interp) } + .text : { *(.text .text.*) } + .rodata : { *(.rodata .rodata.*) } + . += 0x100000; + . = ALIGN(0x100); + .dynamic : { *(.dynamic) } + .data : { *(.data) } + . += 0x100000; + . = ALIGN(0x100); + .bss : { *(.bss) } +} diff --git a/gold/testsuite/script_test_7.sh b/gold/testsuite/script_test_7.sh new file mode 100755 index 0000000..982a1c1 --- /dev/null +++ b/gold/testsuite/script_test_7.sh @@ -0,0 +1,43 @@ +#!/bin/sh + +# script_test_7.sh -- test for SEGMENT_START expressions. + +# Copyright 2009 Free Software Foundation, Inc. +# Written by Doug Kwan <dougkwan@google.com>. + +# This file is part of gold. + +# 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. + +# This file goes with script_test_4.t, which is a linker script which +# starts the program at an unaligned address. + +check() +{ + if ! grep -q "$2" "$1" + then + echo "Did not find expected section in $1:" + echo " $2" + echo "" + echo "Actual output below:" + cat "$1" + exit 1 + fi +} + +check script_test_7.stdout "\\.interp[ ]*PROGBITS[ ]*0*10000100" +check script_test_7.stdout "\\.data[ ]*PROGBITS[ ]*0*10200000" +check script_test_7.stdout "\\.bss[ ]*NOBITS[ ]*0*10400..." diff --git a/gold/testsuite/script_test_7.t b/gold/testsuite/script_test_7.t new file mode 100644 index 0000000..a4c4973 --- /dev/null +++ b/gold/testsuite/script_test_7.t @@ -0,0 +1,41 @@ +/* script_test_5.t -- linker script test 5 for gold + + Copyright 2009 Free Software Foundation, Inc. + Written by Cary Coutant <ccoutant@google.com>. + + This file is part of gold. + + 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. */ + +/* We won't try to run this program, just ensure that it links + as expected. */ + +SECTIONS +{ + . = SEGMENT_START(".text", 0x10000100); + + /* With luck this will be enough to get the program working. */ + .interp : { *(.interp) } + .text : { *(.text .text.*) } + .rodata : { *(.rodata .rodata.*) } + .dynamic : { *(.dynamic) } + + . = SEGMENT_START(".data", 0x10200000); + .data : { *(.data) } + + . = SEGMENT_START(".bss", 0x10400000); + .bss : { *(.bss) } +} diff --git a/gold/testsuite/script_test_8.sh b/gold/testsuite/script_test_8.sh new file mode 100755 index 0000000..83e8e72 --- /dev/null +++ b/gold/testsuite/script_test_8.sh @@ -0,0 +1,44 @@ +#!/bin/sh + +# script_test_8.sh -- test for SEGMENT_START expressions with +# -Ttext, -Tdata and -Tbss in a script. + +# Copyright 2009 Free Software Foundation, Inc. +# Written by Doug Kwan <dougkwan@google.com>. + +# This file is part of gold. + +# 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. + +# This file goes with script_test_4.t, which is a linker script which +# starts the program at an unaligned address. + +check() +{ + if ! grep -q "$2" "$1" + then + echo "Did not find expected section in $1:" + echo " $2" + echo "" + echo "Actual output below:" + cat "$1" + exit 1 + fi +} + +check script_test_8.stdout "\\.interp[ ]*PROGBITS[ ]*0*20001000" +check script_test_8.stdout "\\.data[ ]*PROGBITS[ ]*0*20200000" +check script_test_8.stdout "\\.bss[ ]*NOBITS[ ]*0*2040...." |