aboutsummaryrefslogtreecommitdiff
path: root/gold/testsuite
diff options
context:
space:
mode:
authorCary Coutant <ccoutant@gmail.com>2015-03-21 19:03:00 -0700
committerCary Coutant <ccoutant@gmail.com>2015-03-21 19:54:15 -0700
commit410da591ba7814912e11be826b20dfba9abed9f7 (patch)
treefaf2cf11ec24592cfb68657240e3a620e9e357a9 /gold/testsuite
parent0d5bbdb0e1d193fa6f6804f2620fbdfc950c57a4 (diff)
downloadgdb-410da591ba7814912e11be826b20dfba9abed9f7.zip
gdb-410da591ba7814912e11be826b20dfba9abed9f7.tar.gz
gdb-410da591ba7814912e11be826b20dfba9abed9f7.tar.bz2
PR gold/18048: Fix INCLUDE directive support for gold
This patch fixes INCLUDE directives in script files, so that when an INCLUDE appears inside a sections block, section commands block, or memory def block, the contents are parsed in the appropriate context. gold/ PR gold/18048 * script-c.h (script_include_directive): Add first_token parameter. * script.cc (script_include_directive): Add first_token parameter, and pass it to read_script_file. * yyscript.y (PARSING_SECTIONS_BLOCK, PARSING_SECTION_CMDS) (PARSING_MEMORY_DEF): New tokens. (top): Add new productions for INCLUDE files. (file_cmd): Replace file_or_sections_cmd with copy of its productions. Pass PARSING_LINKER_SCRIPT to script_include_directive. (section_block_cmd): Likewise; pass PARSING_SECTIONS_BLOCK. (section_cmd): Pass PARSING_SECTION_CMDS. (file_or_sections_cmd): Remove. (memory_def): Pass PARSING_MEMORY_DEF. * testsuite/Makefile.am (memory_test_2): New test. * testsuite/Makefile.in: Regenerate. * testsuite/memory_test_inc.t: New script file. * testsuite/memory_test_inc_1.t.src: New script file. * testsuite/memory_test_inc_2.t.src: New script file. * testsuite/memory_test_inc_3.t.src: New script file.
Diffstat (limited to 'gold/testsuite')
-rw-r--r--gold/testsuite/Makefile.am13
-rw-r--r--gold/testsuite/Makefile.in18
-rw-r--r--gold/testsuite/memory_test_inc.t28
-rw-r--r--gold/testsuite/memory_test_inc_1.t.src1
-rw-r--r--gold/testsuite/memory_test_inc_2.t.src1
-rw-r--r--gold/testsuite/memory_test_inc_3.t.src1
6 files changed, 60 insertions, 2 deletions
diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am
index 43da146..2bc4940 100644
--- a/gold/testsuite/Makefile.am
+++ b/gold/testsuite/Makefile.am
@@ -2181,6 +2181,19 @@ memory_test: memory_test.o gcctestdir/ld $(srcdir)/memory_test.t
memory_test.stdout: memory_test
$(TEST_READELF) -lWS $< > $@
+# Test INCLUDE directives in linker scripts.
+# The binary isn't runnable, so we just check that we can build it without errors.
+check_DATA += memory_test_2
+MOSTLYCLEANFILES += memory_test_inc_1.t memory_test_inc_2.t memory_test_inc_3.t
+memory_test_inc_1.t: $(srcdir)/memory_test_inc_1.t.src
+ cp $< $@
+memory_test_inc_2.t: $(srcdir)/memory_test_inc_2.t.src
+ cp $< $@
+memory_test_inc_3.t: $(srcdir)/memory_test_inc_3.t.src
+ cp $< $@
+memory_test_2: memory_test.o gcctestdir/ld $(srcdir)/memory_test.t memory_test_inc_1.t memory_test_inc_2.t memory_test_inc_3.t
+ $(LINK) -Bgcctestdir/ -nostartfiles -nostdlib -z max-page-size=0x1000 -z common-page-size=0x1000 -Wl,-T,$(srcdir)/memory_test.t -o $@ memory_test.o
+
if HAVE_PUBNAMES
# Test that --gdb-index functions correctly without gcc-generated pubnames.
diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in
index 51b58ad..c48461f 100644
--- a/gold/testsuite/Makefile.in
+++ b/gold/testsuite/Makefile.in
@@ -424,6 +424,9 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \
@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 memory_test.sh
+
+# Test INCLUDE directives in linker scripts.
+# The binary isn't runnable, so we just check that we can build it without errors.
@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_46 = exclude_libs_test.syms \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ discard_locals_test.syms \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ discard_locals_relocatable_test1.syms \
@@ -433,7 +436,7 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \
@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@ memory_test.stdout
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ memory_test.stdout memory_test_2
@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_47 = exclude_libs_test.syms \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ libexclude_libs_test_1.a \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ libexclude_libs_test_2.a \
@@ -460,7 +463,10 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ dyn_weak_ref.stdout \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ libstart_lib_test.a \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ memory_test.stdout memory_test \
-@GCC_TRUE@@NATIVE_LINKER_TRUE@ memory_test.o
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ memory_test.o \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ memory_test_inc_1.t \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ memory_test_inc_2.t \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ memory_test_inc_3.t
@GCC_TRUE@@MCMODEL_MEDIUM_TRUE@@NATIVE_LINKER_TRUE@am__append_48 = large
@GCC_FALSE@large_DEPENDENCIES =
@MCMODEL_MEDIUM_FALSE@large_DEPENDENCIES =
@@ -5664,6 +5670,14 @@ uninstall-am:
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(LINK) -Bgcctestdir/ -nostartfiles -nostdlib -z max-page-size=0x1000 -z common-page-size=0x1000 -Wl,-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) -lWS $< > $@
+@GCC_TRUE@@NATIVE_LINKER_TRUE@memory_test_inc_1.t: $(srcdir)/memory_test_inc_1.t.src
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ cp $< $@
+@GCC_TRUE@@NATIVE_LINKER_TRUE@memory_test_inc_2.t: $(srcdir)/memory_test_inc_2.t.src
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ cp $< $@
+@GCC_TRUE@@NATIVE_LINKER_TRUE@memory_test_inc_3.t: $(srcdir)/memory_test_inc_3.t.src
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ cp $< $@
+@GCC_TRUE@@NATIVE_LINKER_TRUE@memory_test_2: memory_test.o gcctestdir/ld $(srcdir)/memory_test.t memory_test_inc_1.t memory_test_inc_2.t memory_test_inc_3.t
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(LINK) -Bgcctestdir/ -nostartfiles -nostdlib -z max-page-size=0x1000 -z common-page-size=0x1000 -Wl,-T,$(srcdir)/memory_test.t -o $@ memory_test.o
@GCC_TRUE@@HAVE_PUBNAMES_TRUE@@NATIVE_LINKER_TRUE@gdb_index_test.o: gdb_index_test.cc
@GCC_TRUE@@HAVE_PUBNAMES_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -O0 -g -gno-pubnames -c -o $@ $<
@GCC_TRUE@@HAVE_PUBNAMES_TRUE@@NATIVE_LINKER_TRUE@gdb_index_test_1: gdb_index_test.o gcctestdir/ld
diff --git a/gold/testsuite/memory_test_inc.t b/gold/testsuite/memory_test_inc.t
new file mode 100644
index 0000000..b835ab7
--- /dev/null
+++ b/gold/testsuite/memory_test_inc.t
@@ -0,0 +1,28 @@
+MEMORY
+{
+ region1 : ORIGIN = 0x1000, LENGTH = 0x1000 ,
+ INCLUDE memory_test_inc_1.t
+ region3 (wx) : o = 0x4000, l = 4
+ region4 (!r) : o = 0x6000 + 60, len = 0x30 * 0x6
+}
+
+SECTIONS
+{
+ .sec0 : { *(*.sec0) }
+
+ .sec1 ORIGIN (region1) : { *(*.sec1) } AT> region2
+
+ INCLUDE memory_test_inc_2.t
+
+ .sec2 : { *(*.sec2) } > region3 AT> region4
+
+ .sec3 0x5000 : {
+ INCLUDE memory_test_inc_3.t
+ }
+
+ .sec4 : { *(*.sec4) } AT> region2
+
+ .sec5 : { LONG(0x5555) } > region2
+
+ /DISCARD/ : { *(*) }
+}
diff --git a/gold/testsuite/memory_test_inc_1.t.src b/gold/testsuite/memory_test_inc_1.t.src
new file mode 100644
index 0000000..21c0851
--- /dev/null
+++ b/gold/testsuite/memory_test_inc_1.t.src
@@ -0,0 +1 @@
+ region2 (r) : org = 0x2000, len = 300
diff --git a/gold/testsuite/memory_test_inc_2.t.src b/gold/testsuite/memory_test_inc_2.t.src
new file mode 100644
index 0000000..b0bc4de
--- /dev/null
+++ b/gold/testsuite/memory_test_inc_2.t.src
@@ -0,0 +1 @@
+ fred = ORIGIN (region1) + LENGTH (region1);
diff --git a/gold/testsuite/memory_test_inc_3.t.src b/gold/testsuite/memory_test_inc_3.t.src
new file mode 100644
index 0000000..fe58e3b
--- /dev/null
+++ b/gold/testsuite/memory_test_inc_3.t.src
@@ -0,0 +1 @@
+ *(*.sec3)