This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: Add 2 run-time tests for size relocation against hidden symbols


Hi,

I checked in this patch to add 2 run-time tests for size relocation
against hidden symbols.


H.J.
---
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index 2432df4..c7ffa1e 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,5 +1,20 @@
 2013-01-17  H.J. Lu  <hongjiu.lu@intel.com>
 
+	* ld-size/size-1.c: New file.
+	* ld-size/size-1.out: Likewise.
+	* ld-size/size-1a.c: Likewise.
+	* ld-size/size-1b.c: Likewise.
+	* ld-size/size-2.c: Likewise.
+	* ld-size/size-2.out: Likewise.
+	* ld-size/size-2a.c: Likewise.
+	* ld-size/size-2b.c: Likewise.
+
+	* ld-size/size.exp (build_tests): Build libsize-1.so and
+	libsize-2.so.
+	(run_tests): Run size-1 and size-2.
+
+2013-01-17  H.J. Lu  <hongjiu.lu@intel.com>
+
 	* ld-size/size32-3-i386.d: New file.
 	* ld-size/size32-3-x32.d: Likewise.
 	* ld-size/size32-3-x86-64.d: Likewise.
diff --git a/ld/testsuite/ld-size/size-1.c b/ld/testsuite/ld-size/size-1.c
new file mode 100644
index 0000000..71a7a66
--- /dev/null
+++ b/ld/testsuite/ld-size/size-1.c
@@ -0,0 +1,12 @@
+#include <stdio.h>
+
+extern int bar_size;
+
+int
+main ()
+{
+  if (bar_size == 10)
+    printf ("OK\n");
+
+  return 0;
+}
diff --git a/ld/testsuite/ld-size/size-1.out b/ld/testsuite/ld-size/size-1.out
new file mode 100644
index 0000000..d86bac9
--- /dev/null
+++ b/ld/testsuite/ld-size/size-1.out
@@ -0,0 +1 @@
+OK
diff --git a/ld/testsuite/ld-size/size-1a.c b/ld/testsuite/ld-size/size-1a.c
new file mode 100644
index 0000000..a9b20f5
--- /dev/null
+++ b/ld/testsuite/ld-size/size-1a.c
@@ -0,0 +1 @@
+char bar[10] __attribute__ ((visibility("hidden")));
diff --git a/ld/testsuite/ld-size/size-1b.c b/ld/testsuite/ld-size/size-1b.c
new file mode 100644
index 0000000..723c60a
--- /dev/null
+++ b/ld/testsuite/ld-size/size-1b.c
@@ -0,0 +1,3 @@
+extern char bar[];
+extern char size_of_bar asm ("bar@SIZE");
+char *bar_size = &size_of_bar;
diff --git a/ld/testsuite/ld-size/size-2.c b/ld/testsuite/ld-size/size-2.c
new file mode 100644
index 0000000..47e6a2f
--- /dev/null
+++ b/ld/testsuite/ld-size/size-2.c
@@ -0,0 +1,14 @@
+#include <stdio.h>
+
+extern int bar_size;
+extern char *get_bar (int, int);
+
+int
+main ()
+{
+  char *bar = get_bar (2, 20);
+  if (bar_size == 10 && bar[2] == 20)
+    printf ("OK\n");
+
+  return 0;
+}
diff --git a/ld/testsuite/ld-size/size-2.out b/ld/testsuite/ld-size/size-2.out
new file mode 100644
index 0000000..d86bac9
--- /dev/null
+++ b/ld/testsuite/ld-size/size-2.out
@@ -0,0 +1 @@
+OK
diff --git a/ld/testsuite/ld-size/size-2a.c b/ld/testsuite/ld-size/size-2a.c
new file mode 100644
index 0000000..0b96aa7
--- /dev/null
+++ b/ld/testsuite/ld-size/size-2a.c
@@ -0,0 +1 @@
+__thread char bar[10] __attribute__ ((visibility("hidden")));
diff --git a/ld/testsuite/ld-size/size-2b.c b/ld/testsuite/ld-size/size-2b.c
new file mode 100644
index 0000000..0f02c94
--- /dev/null
+++ b/ld/testsuite/ld-size/size-2b.c
@@ -0,0 +1,10 @@
+extern __thread char bar[];
+extern char size_of_bar asm ("bar@SIZE");
+char *bar_size = &size_of_bar;
+
+char *
+get_bar (int i, int v)
+{
+  bar[i] = v;
+  return bar;
+}
diff --git a/ld/testsuite/ld-size/size.exp b/ld/testsuite/ld-size/size.exp
index d6bdaf1..7255233 100644
--- a/ld/testsuite/ld-size/size.exp
+++ b/ld/testsuite/ld-size/size.exp
@@ -55,6 +55,12 @@ if { [which $CC] == 0 } {
 }
 
 set build_tests {
+  {"Build libsize-1.so"
+   "-shared" "-fPIC"
+   {size-1a.c size-1b.c} {} "libsize-1.so"}
+  {"Build libsize-2.so"
+   "-shared" "-fPIC"
+   {size-2a.c size-2b.c} {} "libsize-2.so"}
   {"Build libsize-3a.so"
    "-shared" "-fPIC"
    {size-3a.c} {} "libsize-3a.so"}
@@ -84,6 +90,12 @@ set build_tests {
 run_cc_link_tests $build_tests
 
 set run_tests {
+    {"Run size-1"
+     "tmpdir/libsize-1.so" ""
+     {size-1.c} "size-1" "size-1.out"}
+    {"Run size-2"
+     "tmpdir/libsize-2.so" ""
+     {size-2.c} "size-2" "size-2.out"}
     {"Run size-3a"
      "" ""
      {size-3.c size-3a.c} "size-3a" "size-3.out"}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]