aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite
diff options
context:
space:
mode:
Diffstat (limited to 'ld/testsuite')
-rw-r--r--ld/testsuite/ChangeLog5
-rw-r--r--ld/testsuite/ld-scripts/defined.exp1
-rw-r--r--ld/testsuite/ld-scripts/defined3.d25
-rw-r--r--ld/testsuite/ld-scripts/defined3.t15
4 files changed, 46 insertions, 0 deletions
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index f00cf6a..20dedda 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2003-10-11 Hans-Peter Nilsson <hp@bitrange.com>
+
+ * ld-scripts/defined3.d, ld-scripts/defined3.t: New test.
+ * ld-scripts/defined.exp: Run defined3.
+
2003-10-08 Hans-Peter Nilsson <hp@bitrange.com>
* ld-scripts/defined2.d, ld-scripts/defined2.t: New test.
diff --git a/ld/testsuite/ld-scripts/defined.exp b/ld/testsuite/ld-scripts/defined.exp
index 277ba37..138e663 100644
--- a/ld/testsuite/ld-scripts/defined.exp
+++ b/ld/testsuite/ld-scripts/defined.exp
@@ -56,3 +56,4 @@ if ![ld_simple_link $ld tmpdir/def "-T $srcdir/$subdir/defined.t tmpdir/def.o"]
set prms_id 0
run_dump_test "defined2"
+run_dump_test "defined3"
diff --git a/ld/testsuite/ld-scripts/defined3.d b/ld/testsuite/ld-scripts/defined3.d
new file mode 100644
index 0000000..1a7946d
--- /dev/null
+++ b/ld/testsuite/ld-scripts/defined3.d
@@ -0,0 +1,25 @@
+#ld: -Tdefined3.t
+#nm: -B
+#source: phdrs.s
+#source: defined.s
+
+# Check that DEFINED matches only symbols defined before its location.
+# The ellipsis account for target-specific symbols. Matching both A and T
+# accounts for formats that can't tell a .text symbol from an absolute
+# symbol (mmo), but matches whatever section that contains an address
+# matching the value.
+
+#...
+0+1 [AT] defined
+0+200 A defined1
+0+201 A defined2
+0+100 A defined3
+0+ [AT] defined4
+0+2a A defined5
+0+ [AT] defined6
+0+1 [AT] defined7
+0+1 [AT] defined8
+#...
+0+2a A sym1
+[0-9a-f]+ T sym2
+#pass
diff --git a/ld/testsuite/ld-scripts/defined3.t b/ld/testsuite/ld-scripts/defined3.t
new file mode 100644
index 0000000..1fe6eef
--- /dev/null
+++ b/ld/testsuite/ld-scripts/defined3.t
@@ -0,0 +1,15 @@
+defined6 = DEFINED (sym2) ? 1 : 0;
+SECTIONS {
+ .text : { *(.text) sym2 = .; }
+ .data : { *(.data) }
+ .bss : { *(.bss) *(COMMON) }
+}
+defined4 = DEFINED (sym1) ? 1 : 0;
+sym1 = 42;
+defined3 = DEFINED (defined1) ? defined1 + 1 : 256;
+defined1 = DEFINED (defined1) ? defined1 + 1 : 512;
+defined2 = DEFINED (defined1) ? defined1 + 1 : 1024;
+defined5 = DEFINED (sym1) ? sym1 : 0;
+defined7 = DEFINED (sym2);
+defined8 = !DEFINED (defined8);
+defined = DEFINED (defined) ? defined : 42;