aboutsummaryrefslogtreecommitdiff
path: root/gold/testsuite
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2010-09-08 16:10:33 +0000
committerNick Clifton <nickc@redhat.com>2010-09-08 16:10:33 +0000
commit7f8cd8440375de26ebca766ab281c34522262b53 (patch)
treeada43984d6bc35a3487c093cb6b1c5b1a988527b /gold/testsuite
parentab3e2b4a1c329818752fe855215d81fe21f88a8b (diff)
downloadgdb-7f8cd8440375de26ebca766ab281c34522262b53.zip
gdb-7f8cd8440375de26ebca766ab281c34522262b53.tar.gz
gdb-7f8cd8440375de26ebca766ab281c34522262b53.tar.bz2
* README: Remove claim that MEMORY is not supported.
* expression.cc (script_exp_function_origin) (script_exp_function_length): Move from here to ... * script.cc: ... here. (script_set_section_region, script_add_memory) (script_parse_memory_attr, script_include_directive): New functions. * script-sections.cc (class Memory_region): New class. (class Output_section_definition): Add set_memory_region, set_section_vma, set_section_lma and get_section_name methods. (class Script_Sections): Add add_memory_region, find_memory_region, find_memory_region_origin, find_memory_region_length and set_memory_region methods. Have set_section_addresses method walk the list of set memory regions. Extend the print methos to display memory regions. * script-sections.h: Add prototypes for new methods. Add enum for MEMORY region attributes. * yyscript.y: Add support for parsing MEMORY regions. * script-c.h: Add prototypes for new functions. * testsuite/Makefile.am: Add test of MEMORY region functionality. * testsuite/Makefile.in: Regenerate. * testsuite/memory_test.sh: New script. * testsuite/memory_test.s: New assembler source file. * testsuite/memory_test.t: New linker script.
Diffstat (limited to 'gold/testsuite')
-rw-r--r--gold/testsuite/Makefile.am10
-rw-r--r--gold/testsuite/Makefile.in18
-rw-r--r--gold/testsuite/memory_test.s14
-rwxr-xr-xgold/testsuite/memory_test.sh48
-rw-r--r--gold/testsuite/memory_test.t29
5 files changed, 116 insertions, 3 deletions
diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am
index bd8bfbd..161b86a 100644
--- a/gold/testsuite/Makefile.am
+++ b/gold/testsuite/Makefile.am
@@ -1779,6 +1779,16 @@ start_lib_test: start_lib_test_main.o libstart_lib_test.a start_lib_test_2.o sta
libstart_lib_test.a: start_lib_test_1.o
$(TEST_AR) rc $@ $^
+# Test that MEMORY region support works.
+check_SCRIPTS += memory_test.sh
+check_DATA += memory_test.stdout
+MOSTLYCLEANFILES += memory_test.stdout memory_test memory_test.o
+memory_test: memory_test.s
+ $(COMPILE) -c $< -o memory_test.o
+ $(LINK) -Bgcctestdir/ -nostartfiles -nostdlib -T $(srcdir)/memory_test.t -o $@ memory_test.o
+memory_test.stdout: memory_test
+ $(TEST_READELF) -lS $< > $@
+
endif GCC
endif NATIVE_LINKER
diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in
index 29caa06..09dc84a 100644
--- a/gold/testsuite/Makefile.in
+++ b/gold/testsuite/Makefile.in
@@ -312,13 +312,15 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \
# Test that a strong weak reference remains strong if there is another
# weak reference in a DSO.
+
+# Test that MEMORY region support works.
@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_27 = exclude_libs_test.sh \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ discard_locals_test.sh \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ hidden_test.sh \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ retain_symbols_file_test.sh \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ no_version_test.sh \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ strong_ref_weak_def.sh \
-@GCC_TRUE@@NATIVE_LINKER_TRUE@ dyn_weak_ref.sh
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ dyn_weak_ref.sh memory_test.sh
@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_28 = exclude_libs_test.syms \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ discard_locals_test.syms \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ discard_locals_relocatable_test1.syms \
@@ -327,7 +329,8 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ retain_symbols_file_test.stdout \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ no_version_test.stdout \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ strong_ref_weak_def.stdout \
-@GCC_TRUE@@NATIVE_LINKER_TRUE@ dyn_weak_ref.stdout
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ dyn_weak_ref.stdout \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ memory_test.stdout
@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_29 = exclude_libs_test.syms \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ libexclude_libs_test_1.a \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ libexclude_libs_test_2.a \
@@ -351,7 +354,9 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ strong_ref_weak_def.stdout \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ dyn_weak_ref_1.so \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ dyn_weak_ref_2.so \
-@GCC_TRUE@@NATIVE_LINKER_TRUE@ dyn_weak_ref.stdout
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ dyn_weak_ref.stdout \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ memory_test.stdout memory_test \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ memory_test.o
@GCC_TRUE@@MCMODEL_MEDIUM_TRUE@@NATIVE_LINKER_TRUE@am__append_30 = large
@GCC_FALSE@large_DEPENDENCIES =
@MCMODEL_MEDIUM_FALSE@large_DEPENDENCIES =
@@ -3282,6 +3287,8 @@ strong_ref_weak_def.sh.log: strong_ref_weak_def.sh
@p='strong_ref_weak_def.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
dyn_weak_ref.sh.log: dyn_weak_ref.sh
@p='dyn_weak_ref.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+memory_test.sh.log: memory_test.sh
+ @p='memory_test.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
split_i386.sh.log: split_i386.sh
@p='split_i386.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
split_x86_64.sh.log: split_x86_64.sh
@@ -4476,6 +4483,11 @@ uninstall-am:
@GCC_TRUE@@NATIVE_LINKER_TRUE@ -Wl,--start-lib start_lib_test_2.o start_lib_test_3.o -Wl,--end-lib
@GCC_TRUE@@NATIVE_LINKER_TRUE@libstart_lib_test.a: start_lib_test_1.o
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_AR) rc $@ $^
+@GCC_TRUE@@NATIVE_LINKER_TRUE@memory_test: memory_test.s
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(COMPILE) -c $< -o memory_test.o
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(LINK) -Bgcctestdir/ -nostartfiles -nostdlib -T $(srcdir)/memory_test.t -o $@ memory_test.o
+@GCC_TRUE@@NATIVE_LINKER_TRUE@memory_test.stdout: memory_test
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_READELF) -lS $< > $@
@DEFAULT_TARGET_I386_TRUE@split_i386_1.o: split_i386_1.s
@DEFAULT_TARGET_I386_TRUE@ $(TEST_AS) -o $@ $<
@DEFAULT_TARGET_I386_TRUE@split_i386_2.o: split_i386_2.s
diff --git a/gold/testsuite/memory_test.s b/gold/testsuite/memory_test.s
new file mode 100644
index 0000000..dbb63ea
--- /dev/null
+++ b/gold/testsuite/memory_test.s
@@ -0,0 +1,14 @@
+ .section .sec0, "a"
+ .word 0
+
+ .section .sec1, "a"
+ .word 0x11
+
+ .section .sec2, "a"
+ .word 0x22
+
+ .section .sec3, "a"
+ .word 0x33
+
+ .section .sec4, "a"
+ .word 0x44
diff --git a/gold/testsuite/memory_test.sh b/gold/testsuite/memory_test.sh
new file mode 100755
index 0000000..8a223ad
--- /dev/null
+++ b/gold/testsuite/memory_test.sh
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+# memory_test.sh -- test MEMORY regions.
+
+# Copyright 2010 Free Software Foundation, Inc.
+# Written by Nick Clifton <nickc@redhat.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.
+
+
+check()
+{
+ file=$1
+ pattern=$2
+ found=`grep "$pattern" $file`
+ if test -z "$found"; then
+ echo "pattern \"$pattern\" not found in file $file."
+ echo $found
+ exit 1
+ fi
+}
+
+check memory_test.stdout \
+ " LOAD 0x001000 0x00000000 0x00000000 0x00002 0x00002 R 0x1000"
+check memory_test.stdout \
+ " LOAD 0x00112c 0x00001000 0x0000012c 0x00002 0x00002 R 0x1000"
+check memory_test.stdout \
+ " LOAD 0x002000 0x00005000 0x00005000 0x00002 0x00002 R 0x1000"
+check memory_test.stdout \
+ " LOAD 0x00203c 0x00004000 0x0000603c 0x0002a 0x0002a R E 0x1000"
+
+
+exit 0
diff --git a/gold/testsuite/memory_test.t b/gold/testsuite/memory_test.t
new file mode 100644
index 0000000..7bcb877
--- /dev/null
+++ b/gold/testsuite/memory_test.t
@@ -0,0 +1,29 @@
+MEMORY
+{
+ region1 : ORIGIN = 0x1000, LENGTH = 0x1000 ,
+ region2 (r) : org = 0x2000, len = 300
+ region3 (wx) : o = 0x4000, l = 4
+ region4 (!r) : o = 0x6000 + 60, len = 0x30 * 0x6
+}
+
+SECTIONS
+{
+ .sec0 : { *(*.sec0) }
+
+ .sec1 ORIGIN (region1) : AT(LENGTH (region2)) { *(*.sec1) }
+
+ fred = ORIGIN (region1) + LENGTH (region1) ;
+
+ .sec2 : { *(*.sec2) } > region3 AT> region4
+
+ .sec3 0x5000 : { *(*.sec3) }
+
+ /* In theory we could put:
+
+ /DISCARD/ : { *(*) }
+
+ here as we do not need any other sections for this test.
+ In practice however doing so breaks GOLD as it relies upon
+ being able to create/find various other sections such as
+ .dynamic, .dynsym and .gnu.hash. */
+}