aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2013-01-17 04:28:48 +0000
committerH.J. Lu <hjl.tools@gmail.com>2013-01-17 04:28:48 +0000
commit8fd4256dd0a856d3a1320598f063d4d593d84e67 (patch)
treeb614ee9174f36ec9976ca8081f9224ce33953767 /ld/testsuite
parentc32d6f7bd43c74fbe950858502e6e9ba6eaca2af (diff)
downloadgdb-8fd4256dd0a856d3a1320598f063d4d593d84e67.zip
gdb-8fd4256dd0a856d3a1320598f063d4d593d84e67.tar.gz
gdb-8fd4256dd0a856d3a1320598f063d4d593d84e67.tar.bz2
Add x86 size relocation support to gas
gas/ * config/tc-i386.c (reloc): Support BFD_RELOC_SIZE32. (tc_i386_fix_adjustable): Keep symbol for BFD_RELOC_32_SIZE and BFD_RELOC_64_SIZE relocations. (lex_got): Support "symbol@SIZE" and don't create GOT symbol for it. (tc_gen_reloc): Resolve BFD_RELOC_SIZE32 and BFD_RELOC_SIZE64 relocations against local symbols. gas/testsuite/ * gas/i386/i386.exp: Run size-1, size-2, size-3, size-4, x86-64-size-1, x86-64-size-2, x86-64-size-3, x86-64-size-4, x86-64-size-5 and x86-64-size-inval-1. * gas/i386/size-1.d: New file. * gas/i386/size-1.s: Likewise. * gas/i386/size-2.d: Likewise. * gas/i386/size-2.s: Likewise. * gas/i386/size-3.d: Likewise. * gas/i386/size-3.s: Likewise. * gas/i386/size-4.d: Likewise. * gas/i386/size-4.s: Likewise. * gas/i386/x86-64-size-1.d: Likewise. * gas/i386/x86-64-size-2.d: Likewise. * gas/i386/x86-64-size-3.d: Likewise. * gas/i386/x86-64-size-4.d: Likewise. * gas/i386/x86-64-size-5.d: Likewise. * gas/i386/x86-64-size-5.s: Likewise. * gas/i386/x86-64-size-inval-1.l: Likewise. * gas/i386/x86-64-size-inval-1.s: Likewise. * gas/i386/ilp32/x86-64-size-1.d: Likewise. * gas/i386/ilp32/x86-64-size-2.d: Likewise. * gas/i386/ilp32/x86-64-size-3.d: Likewise. * gas/i386/ilp32/x86-64-size-4.d: Likewise. * gas/i386/ilp32/x86-64-size-5.d: Likewise. ld/testsuite/ * ld-size/size.exp: New file. * ld-size/size32-1-i386.d: Likewise. * ld-size/size32-1-x32.d: Likewise. * ld-size/size32-1-x86-64.d: Likewise. * ld-size/size32-1.s: Likewise. * ld-size/size32-2-i386.d: Likewise. * ld-size/size32-2-x32.d: Likewise. * ld-size/size32-2-x86-64.d: Likewise. * ld-size/size32-2.s: Likewise. * ld-size/size64-1-x32.d: Likewise. * ld-size/size64-1-x86-64.d: Likewise. * ld-size/size64-1.s: Likewise. * ld-size/size64-2-x32.d: Likewise. * ld-size/size64-2-x86-64.d: Likewise. * ld-size/size64-2.s: Likewise. * ld-size/size-3.c: Likewise. * ld-size/size-3.out: Likewise. * ld-size/size-3a.c: Likewise. * ld-size/size-3b.c: Likewise. * ld-size/size-3c.c: Likewise. * ld-size/size-4.out: Likewise. * ld-size/size-4a.c: Likewise. * ld-size/size-4b.c: Likewise. * ld-size/size-5.out: Likewise. * ld-size/size-5a.c: Likewise. * ld-size/size-5b.c: Likewise. * ld-size/size-6.out: Likewise. * ld-size/size-6a.c: Likewise. * ld-size/size-6b.c: Likewise. * ld-size/size-7.rd: Likewise. * ld-size/size-7a.c: Likewise. * ld-size/size-7b.c: Likewise. * ld-size/size-8.rd: Likewise. * ld-size/size-8a.c: Likewise. * ld-size/size-8b.c: Likewise.
Diffstat (limited to 'ld/testsuite')
-rw-r--r--ld/testsuite/ChangeLog38
-rw-r--r--ld/testsuite/ld-size/size-3.c12
-rw-r--r--ld/testsuite/ld-size/size-3.out1
-rw-r--r--ld/testsuite/ld-size/size-3a.c3
-rw-r--r--ld/testsuite/ld-size/size-3b.c4
-rw-r--r--ld/testsuite/ld-size/size-3c.c3
-rw-r--r--ld/testsuite/ld-size/size-4.out2
-rw-r--r--ld/testsuite/ld-size/size-4a.c24
-rw-r--r--ld/testsuite/ld-size/size-4b.c35
-rw-r--r--ld/testsuite/ld-size/size-5.out2
-rw-r--r--ld/testsuite/ld-size/size-5a.c24
-rw-r--r--ld/testsuite/ld-size/size-5b.c37
-rw-r--r--ld/testsuite/ld-size/size-6.out1
-rw-r--r--ld/testsuite/ld-size/size-6a.c15
-rw-r--r--ld/testsuite/ld-size/size-6b.c7
-rw-r--r--ld/testsuite/ld-size/size-7.rd3
-rw-r--r--ld/testsuite/ld-size/size-7a.c12
-rw-r--r--ld/testsuite/ld-size/size-7b.c1
-rw-r--r--ld/testsuite/ld-size/size-8.rd3
-rw-r--r--ld/testsuite/ld-size/size-8a.c15
-rw-r--r--ld/testsuite/ld-size/size-8b.c7
-rw-r--r--ld/testsuite/ld-size/size.exp122
-rw-r--r--ld/testsuite/ld-size/size32-1-i386.d22
-rw-r--r--ld/testsuite/ld-size/size32-1-x32.d22
-rw-r--r--ld/testsuite/ld-size/size32-1-x86-64.d22
-rw-r--r--ld/testsuite/ld-size/size32-1.s14
-rw-r--r--ld/testsuite/ld-size/size32-2-i386.d20
-rw-r--r--ld/testsuite/ld-size/size32-2-x32.d20
-rw-r--r--ld/testsuite/ld-size/size32-2-x86-64.d20
-rw-r--r--ld/testsuite/ld-size/size32-2.s22
-rw-r--r--ld/testsuite/ld-size/size64-1-x32.d23
-rw-r--r--ld/testsuite/ld-size/size64-1-x86-64.d23
-rw-r--r--ld/testsuite/ld-size/size64-1.s14
-rw-r--r--ld/testsuite/ld-size/size64-2-x32.d21
-rw-r--r--ld/testsuite/ld-size/size64-2-x86-64.d21
-rw-r--r--ld/testsuite/ld-size/size64-2.s22
36 files changed, 657 insertions, 0 deletions
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index 017758a..c578fb6 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,3 +1,41 @@
+2013-01-16 H.J. Lu <hongjiu.lu@intel.com>
+
+ * ld-size/size.exp: New file.
+ * ld-size/size32-1-i386.d: Likewise.
+ * ld-size/size32-1-x32.d: Likewise.
+ * ld-size/size32-1-x86-64.d: Likewise.
+ * ld-size/size32-1.s: Likewise.
+ * ld-size/size32-2-i386.d: Likewise.
+ * ld-size/size32-2-x32.d: Likewise.
+ * ld-size/size32-2-x86-64.d: Likewise.
+ * ld-size/size32-2.s: Likewise.
+ * ld-size/size64-1-x32.d: Likewise.
+ * ld-size/size64-1-x86-64.d: Likewise.
+ * ld-size/size64-1.s: Likewise.
+ * ld-size/size64-2-x32.d: Likewise.
+ * ld-size/size64-2-x86-64.d: Likewise.
+ * ld-size/size64-2.s: Likewise.
+ * ld-size/size-3.c: Likewise.
+ * ld-size/size-3.out: Likewise.
+ * ld-size/size-3a.c: Likewise.
+ * ld-size/size-3b.c: Likewise.
+ * ld-size/size-3c.c: Likewise.
+ * ld-size/size-4.out: Likewise.
+ * ld-size/size-4a.c: Likewise.
+ * ld-size/size-4b.c: Likewise.
+ * ld-size/size-5.out: Likewise.
+ * ld-size/size-5a.c: Likewise.
+ * ld-size/size-5b.c: Likewise.
+ * ld-size/size-6.out: Likewise.
+ * ld-size/size-6a.c: Likewise.
+ * ld-size/size-6b.c: Likewise.
+ * ld-size/size-7.rd: Likewise.
+ * ld-size/size-7a.c: Likewise.
+ * ld-size/size-7b.c: Likewise.
+ * ld-size/size-8.rd: Likewise.
+ * ld-size/size-8a.c: Likewise.
+ * ld-size/size-8b.c: Likewise.
+
2013-01-16 Alan Modra <amodra@gmail.com>
* ld-plugin/lto.exp (lto-9.o, pr13229.o): Pass -finline.
diff --git a/ld/testsuite/ld-size/size-3.c b/ld/testsuite/ld-size/size-3.c
new file mode 100644
index 0000000..71a7a66
--- /dev/null
+++ b/ld/testsuite/ld-size/size-3.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-3.out b/ld/testsuite/ld-size/size-3.out
new file mode 100644
index 0000000..d86bac9
--- /dev/null
+++ b/ld/testsuite/ld-size/size-3.out
@@ -0,0 +1 @@
+OK
diff --git a/ld/testsuite/ld-size/size-3a.c b/ld/testsuite/ld-size/size-3a.c
new file mode 100644
index 0000000..b321559
--- /dev/null
+++ b/ld/testsuite/ld-size/size-3a.c
@@ -0,0 +1,3 @@
+char bar[10] __attribute__ ((visibility("hidden")));
+extern char size_of_bar asm ("bar@SIZE");
+char *bar_size = &size_of_bar;
diff --git a/ld/testsuite/ld-size/size-3b.c b/ld/testsuite/ld-size/size-3b.c
new file mode 100644
index 0000000..fc379df
--- /dev/null
+++ b/ld/testsuite/ld-size/size-3b.c
@@ -0,0 +1,4 @@
+static char bar[10];
+extern char size_of_bar asm ("bar@SIZE");
+char *bar_size = &size_of_bar;
+char *bar_p = bar;
diff --git a/ld/testsuite/ld-size/size-3c.c b/ld/testsuite/ld-size/size-3c.c
new file mode 100644
index 0000000..d94ceef
--- /dev/null
+++ b/ld/testsuite/ld-size/size-3c.c
@@ -0,0 +1,3 @@
+__thread char bar[10] __attribute__ ((visibility("hidden")));
+extern char size_of_bar asm ("bar@SIZE");
+char *bar_size = &size_of_bar;
diff --git a/ld/testsuite/ld-size/size-4.out b/ld/testsuite/ld-size/size-4.out
new file mode 100644
index 0000000..2c94e48
--- /dev/null
+++ b/ld/testsuite/ld-size/size-4.out
@@ -0,0 +1,2 @@
+OK
+OK
diff --git a/ld/testsuite/ld-size/size-4a.c b/ld/testsuite/ld-size/size-4a.c
new file mode 100644
index 0000000..b11089b
--- /dev/null
+++ b/ld/testsuite/ld-size/size-4a.c
@@ -0,0 +1,24 @@
+#include <stdio.h>
+
+char bar[10];
+char foo[20] = { 1 } ;
+extern int bar_size1 (void);
+extern int bar_size2 (void);
+extern int foo_size1 (void);
+extern int foo_size2 (void);
+
+int
+main ()
+{
+ int size;
+
+ size = bar_size1 ();
+ if (size == sizeof (bar) && bar_size2 () == size)
+ printf ("OK\n");
+
+ size = foo_size1 ();
+ if (size == sizeof (foo) && foo_size2 () == size)
+ printf ("OK\n");
+
+ return 0;
+}
diff --git a/ld/testsuite/ld-size/size-4b.c b/ld/testsuite/ld-size/size-4b.c
new file mode 100644
index 0000000..c618be0
--- /dev/null
+++ b/ld/testsuite/ld-size/size-4b.c
@@ -0,0 +1,35 @@
+extern char bar[];
+extern char size_of_bar asm ("bar@SIZE");
+
+char *bar_size_1 = &size_of_bar;
+static char *bar_size_2 = &size_of_bar;
+
+char *
+bar_size1 (void)
+{
+ return bar_size_1;
+}
+
+char *
+bar_size2 (void)
+{
+ return bar_size_2;
+}
+
+extern char foo[];
+extern char size_of_foo asm ("foo@SIZE");
+
+char *foo_size_1 = &size_of_foo;
+static char *foo_size_2 = &size_of_foo;
+
+char *
+foo_size1 (void)
+{
+ return foo_size_1;
+}
+
+char *
+foo_size2 (void)
+{
+ return foo_size_2;
+}
diff --git a/ld/testsuite/ld-size/size-5.out b/ld/testsuite/ld-size/size-5.out
new file mode 100644
index 0000000..2c94e48
--- /dev/null
+++ b/ld/testsuite/ld-size/size-5.out
@@ -0,0 +1,2 @@
+OK
+OK
diff --git a/ld/testsuite/ld-size/size-5a.c b/ld/testsuite/ld-size/size-5a.c
new file mode 100644
index 0000000..500678a
--- /dev/null
+++ b/ld/testsuite/ld-size/size-5a.c
@@ -0,0 +1,24 @@
+#include <stdio.h>
+
+__thread char bar[10];
+__thread char foo[20] = { 1 } ;
+extern int bar_size1 (void);
+extern int bar_size2 (void);
+extern int foo_size1 (void);
+extern int foo_size2 (void);
+
+int
+main ()
+{
+ int size;
+
+ size = bar_size1 ();
+ if (bar[2] == 3 && size == sizeof (bar) && bar_size2 () == size)
+ printf ("OK\n");
+
+ size = foo_size1 ();
+ if (foo[3] == 4 && size == sizeof (foo) && foo_size2 () == size)
+ printf ("OK\n");
+
+ return 0;
+}
diff --git a/ld/testsuite/ld-size/size-5b.c b/ld/testsuite/ld-size/size-5b.c
new file mode 100644
index 0000000..a9450a5
--- /dev/null
+++ b/ld/testsuite/ld-size/size-5b.c
@@ -0,0 +1,37 @@
+extern __thread char bar[];
+extern char size_of_bar asm ("bar@SIZE");
+
+char *bar_size_1 = &size_of_bar;
+static char *bar_size_2 = &size_of_bar;
+
+char *
+bar_size1 (void)
+{
+ bar[2] = 3;
+ return bar_size_1;
+}
+
+char *
+bar_size2 (void)
+{
+ return bar_size_2;
+}
+
+extern __thread char foo[];
+extern char size_of_foo asm ("foo@SIZE");
+
+char *foo_size_1 = &size_of_foo;
+static char *foo_size_2 = &size_of_foo;
+
+char *
+foo_size1 (void)
+{
+ foo[3] = 4;
+ return foo_size_1;
+}
+
+char *
+foo_size2 (void)
+{
+ return foo_size_2;
+}
diff --git a/ld/testsuite/ld-size/size-6.out b/ld/testsuite/ld-size/size-6.out
new file mode 100644
index 0000000..d86bac9
--- /dev/null
+++ b/ld/testsuite/ld-size/size-6.out
@@ -0,0 +1 @@
+OK
diff --git a/ld/testsuite/ld-size/size-6a.c b/ld/testsuite/ld-size/size-6a.c
new file mode 100644
index 0000000..3946fb1
--- /dev/null
+++ b/ld/testsuite/ld-size/size-6a.c
@@ -0,0 +1,15 @@
+#include <stdio.h>
+
+extern char bar[];
+extern char size_of_bar asm ("bar@SIZE");
+extern void set_bar (int, int);
+
+int
+main ()
+{
+ set_bar (1, 20);
+ if (10 == (long) &size_of_bar && bar[1] == 20)
+ printf ("OK\n");
+
+ return 0;
+}
diff --git a/ld/testsuite/ld-size/size-6b.c b/ld/testsuite/ld-size/size-6b.c
new file mode 100644
index 0000000..5014bb5
--- /dev/null
+++ b/ld/testsuite/ld-size/size-6b.c
@@ -0,0 +1,7 @@
+char bar[10];
+
+void
+set_bar (int i, int v)
+{
+ bar[i] = v;
+}
diff --git a/ld/testsuite/ld-size/size-7.rd b/ld/testsuite/ld-size/size-7.rd
new file mode 100644
index 0000000..a5f8ee8
--- /dev/null
+++ b/ld/testsuite/ld-size/size-7.rd
@@ -0,0 +1,3 @@
+#...
+[0-9a-f]+ +[0-9a-f]+ +R_.*_SIZE(32|64) +.*
+#pass
diff --git a/ld/testsuite/ld-size/size-7a.c b/ld/testsuite/ld-size/size-7a.c
new file mode 100644
index 0000000..c415180
--- /dev/null
+++ b/ld/testsuite/ld-size/size-7a.c
@@ -0,0 +1,12 @@
+#include <stdio.h>
+
+extern char size_of_bar asm ("bar@SIZE");
+
+int
+main ()
+{
+ if (10 == (long) &size_of_bar)
+ printf ("OK\n");
+
+ return 0;
+}
diff --git a/ld/testsuite/ld-size/size-7b.c b/ld/testsuite/ld-size/size-7b.c
new file mode 100644
index 0000000..b95ad01
--- /dev/null
+++ b/ld/testsuite/ld-size/size-7b.c
@@ -0,0 +1 @@
+char bar[10];
diff --git a/ld/testsuite/ld-size/size-8.rd b/ld/testsuite/ld-size/size-8.rd
new file mode 100644
index 0000000..a5f8ee8
--- /dev/null
+++ b/ld/testsuite/ld-size/size-8.rd
@@ -0,0 +1,3 @@
+#...
+[0-9a-f]+ +[0-9a-f]+ +R_.*_SIZE(32|64) +.*
+#pass
diff --git a/ld/testsuite/ld-size/size-8a.c b/ld/testsuite/ld-size/size-8a.c
new file mode 100644
index 0000000..78c5732
--- /dev/null
+++ b/ld/testsuite/ld-size/size-8a.c
@@ -0,0 +1,15 @@
+#include <stdio.h>
+
+extern __thread char bar[];
+extern char size_of_bar asm ("bar@SIZE");
+extern void set_bar (int, int);
+
+int
+main ()
+{
+ set_bar (1, 20);
+ if (10 == (long) &size_of_bar && bar[1] == 20)
+ printf ("OK\n");
+
+ return 0;
+}
diff --git a/ld/testsuite/ld-size/size-8b.c b/ld/testsuite/ld-size/size-8b.c
new file mode 100644
index 0000000..e9f1204
--- /dev/null
+++ b/ld/testsuite/ld-size/size-8b.c
@@ -0,0 +1,7 @@
+__thread char bar[10];
+
+void
+set_bar (int i, int v)
+{
+ bar[i] = v;
+}
diff --git a/ld/testsuite/ld-size/size.exp b/ld/testsuite/ld-size/size.exp
new file mode 100644
index 0000000..4bbb5d7
--- /dev/null
+++ b/ld/testsuite/ld-size/size.exp
@@ -0,0 +1,122 @@
+# Expect script for linker support of size relocations.
+#
+# Copyright 2013 Free Software Foundation, Inc.
+#
+# This file is part of the GNU Binutils.
+#
+# 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.
+#
+
+
+# Size relications have only been implemented for the ix86 and x86_64,
+# so far.
+if {!(([istarget "i?86-*-*"]
+ || [istarget "x86_64-*-*"])
+ && ([istarget "*-*-elf*"]
+ || [istarget "*-*-nacl*"]
+ || (([istarget "*-*-linux*"]
+ || [istarget "*-*-gnu*"])
+ && ![istarget "*-*-*aout*"]
+ && ![istarget "*-*-*oldld*"]))) } {
+ verbose "Size relocations tests not run - no target support"
+ return
+}
+
+set test_list [lsort [glob -nocomplain $srcdir/$subdir/*.d]]
+foreach t $test_list {
+ # We need to strip the ".d", but can leave the dirname.
+ verbose [file rootname $t]
+ run_dump_test [file rootname $t]
+}
+
+# We need a native system.
+if ![isnative] {
+ verbose "Natibe size relocation tests not run - not a native toolchain"
+ return
+}
+
+# We need a working compiler.
+if { [which $CC] == 0 } {
+ verbose "Native size relocation tests not run - no compiler available"
+ return
+}
+
+set build_tests {
+ {"Build libsize-3a.so"
+ "-shared" "-fPIC"
+ {size-3a.c} {} "libsize-3a.so"}
+ {"Build libsize-3b.so"
+ "-shared" "-fPIC"
+ {size-3b.c} {} "libsize-3b.so"}
+ {"Build libsize-3c.so"
+ "-shared" "-fPIC"
+ {size-3c.c} {} "libsize-3c.so"}
+ {"Build libsize-6b.so"
+ "-shared" "-fPIC"
+ {size-6b.c} {} "libsize-6b.so"}
+ {"Build libsize-7.so"
+ "-shared" "-fPIC"
+ {size-7b.c} {} "libsize-7.so"}
+ {"Build size-7"
+ "tmpdir/libsize-7.so" ""
+ {size-7a.c} {{readelf -rW size-7.rd}} "size-7.exe"}
+ {"Build libsize-8.so"
+ "-shared" "-fPIC"
+ {size-8b.c} {} "libsize-8.so"}
+ {"Build size-8"
+ "tmpdir/libsize-8.so" ""
+ {size-8a.c} {{readelf -rW size-8.rd}} "size-8.exe"}
+}
+
+run_cc_link_tests $build_tests
+
+set run_tests {
+ {"Run size-3a"
+ "" ""
+ {size-3.c size-3a.c} "size-3a" "size-3.out"}
+ {"Run size-3b"
+ "tmpdir/libsize-3a.so" ""
+ {size-3.c} "size-3b" "size-3.out"}
+ {"Run size-3c"
+ "" ""
+ {size-3.c size-3b.c} "size-3c" "size-3.out"}
+ {"Run size-3d"
+ "tmpdir/libsize-3b.so" ""
+ {size-3.c} "size-3d" "size-3.out"}
+ {"Run size-3d"
+ "" ""
+ {size-3.c size-3c.c} "size-3d" "size-3.out"}
+ {"Run size-3e"
+ "tmpdir/libsize-3c.so" ""
+ {size-3.c} "size-3e" "size-3.out"}
+ {"Run size-4a"
+ "" ""
+ {size-4a.c size-4b.c} "size-4a" "size-4.out"}
+ {"Run size-4b"
+ "" ""
+ {size-4b.c size-4a.c} "size-4b" "size-4.out"}
+ {"Run size-5a"
+ "" ""
+ {size-5a.c size-5b.c} "size-5a" "size-5.out"}
+ {"Run size-5b"
+ "" ""
+ {size-5b.c size-5a.c} "size-5b" "size-5.out"}
+ {"Run size-6"
+ "tmpdir/libsize-6b.so" ""
+ {size-6a.c} "size-6" "size-6.out"}
+}
+
+run_ld_link_exec_tests [] $run_tests
diff --git a/ld/testsuite/ld-size/size32-1-i386.d b/ld/testsuite/ld-size/size32-1-i386.d
new file mode 100644
index 0000000..e8a6622
--- /dev/null
+++ b/ld/testsuite/ld-size/size32-1-i386.d
@@ -0,0 +1,22 @@
+#source: size32-1.s
+#as: --32
+#ld: -shared -melf_i386
+#objdump: -R -s -j .data
+#target: x86_64-*-* i?86-*-*
+
+.*: +file format .*
+
+DYNAMIC RELOCATION RECORDS
+OFFSET TYPE VALUE
+0+11f4 R_386_SIZE32 xxx
+0+11f8 R_386_SIZE32 xxx
+0+11fc R_386_SIZE32 xxx
+0+1200 R_386_SIZE32 yyy
+0+1204 R_386_SIZE32 zzz
+
+
+Contents of section .data:
+ 11f4 00000000 e2ffffff 1e000000 00000000 ................
+ 1204 00000000 00000000 00000000 00000000 ................
+ 1214 00000000 00000000 00000000 00000000 ................
+ 1224 00000000 00000000 00000000 ............
diff --git a/ld/testsuite/ld-size/size32-1-x32.d b/ld/testsuite/ld-size/size32-1-x32.d
new file mode 100644
index 0000000..1022dba
--- /dev/null
+++ b/ld/testsuite/ld-size/size32-1-x32.d
@@ -0,0 +1,22 @@
+#source: size32-1.s
+#as: --x32
+#ld: -shared -melf32_x86_64
+#objdump: -R -s -j .data
+#target: x86_64-*-*
+
+.*: +file format .*
+
+DYNAMIC RELOCATION RECORDS
+OFFSET TYPE VALUE
+0+200220 R_X86_64_SIZE32 xxx
+0+200224 R_X86_64_SIZE32 xxx-0x0000001e
+0+200228 R_X86_64_SIZE32 xxx\+0x0000001e
+0+20022c R_X86_64_SIZE32 yyy
+0+200230 R_X86_64_SIZE32 zzz
+
+
+Contents of section .data:
+ 200220 00000000 00000000 00000000 00000000 ................
+ 200230 00000000 00000000 00000000 00000000 ................
+ 200240 00000000 00000000 00000000 00000000 ................
+ 200250 00000000 00000000 00000000 ............
diff --git a/ld/testsuite/ld-size/size32-1-x86-64.d b/ld/testsuite/ld-size/size32-1-x86-64.d
new file mode 100644
index 0000000..80c4a66
--- /dev/null
+++ b/ld/testsuite/ld-size/size32-1-x86-64.d
@@ -0,0 +1,22 @@
+#source: size32-1.s
+#as: --64
+#ld: -shared -melf_x86_64
+#objdump: -R -s -j .data
+#target: x86_64-*-*
+
+.*: +file format .*
+
+DYNAMIC RELOCATION RECORDS
+OFFSET TYPE VALUE
+0+200360 R_X86_64_SIZE32 xxx
+0+200364 R_X86_64_SIZE32 xxx-0x000000000000001e
+0+200368 R_X86_64_SIZE32 xxx\+0x000000000000001e
+0+20036c R_X86_64_SIZE32 yyy
+0+200370 R_X86_64_SIZE32 zzz
+
+
+Contents of section .data:
+ 200360 00000000 00000000 00000000 00000000 ................
+ 200370 00000000 00000000 00000000 00000000 ................
+ 200380 00000000 00000000 00000000 00000000 ................
+ 200390 00000000 00000000 00000000 ............
diff --git a/ld/testsuite/ld-size/size32-1.s b/ld/testsuite/ld-size/size32-1.s
new file mode 100644
index 0000000..9e2840c
--- /dev/null
+++ b/ld/testsuite/ld-size/size32-1.s
@@ -0,0 +1,14 @@
+# 32-bit size relocation in shared object
+ .comm xxx,40,32
+ .data
+ .p2align 2
+ .long xxx@SIZE
+ .long xxx@SIZE-30
+ .long xxx@SIZE+30
+ .long yyy@SIZE
+ .long zzz@SIZE
+ .globl yyy
+ .type yyy, %object
+ .size yyy, 40
+yyy:
+ .zero 40
diff --git a/ld/testsuite/ld-size/size32-2-i386.d b/ld/testsuite/ld-size/size32-2-i386.d
new file mode 100644
index 0000000..2db0e1d
--- /dev/null
+++ b/ld/testsuite/ld-size/size32-2-i386.d
@@ -0,0 +1,20 @@
+#source: size32-2.s
+#as: --32
+#ld: -shared -melf_i386
+#objdump: -R -s -j .data
+#target: x86_64-*-* i?86-*-*
+
+.*: +file format .*
+
+DYNAMIC RELOCATION RECORDS
+OFFSET TYPE VALUE
+0+123c R_386_SIZE32 xxx
+0+1240 R_386_SIZE32 yyy
+0+1244 R_386_SIZE32 zzz
+0+1248 R_386_SIZE32 zzz
+0+124c R_386_SIZE32 zzz
+
+
+Contents of section .data:
+ 123c 00000000 00000000 00000000 e2ffffff ................
+ 124c 1e000000 ....
diff --git a/ld/testsuite/ld-size/size32-2-x32.d b/ld/testsuite/ld-size/size32-2-x32.d
new file mode 100644
index 0000000..9c1eae2
--- /dev/null
+++ b/ld/testsuite/ld-size/size32-2-x32.d
@@ -0,0 +1,20 @@
+#source: size32-2.s
+#as: --x32
+#ld: -shared -melf32_x86_64
+#objdump: -R -s -j .data
+#target: x86_64-*-*
+
+.*: +file format .*
+
+DYNAMIC RELOCATION RECORDS
+OFFSET TYPE VALUE
+0+200278 R_X86_64_SIZE32 xxx
+0+20027c R_X86_64_SIZE32 yyy
+0+200280 R_X86_64_SIZE32 zzz
+0+200284 R_X86_64_SIZE32 zzz-0x0000001e
+0+200288 R_X86_64_SIZE32 zzz\+0x0000001e
+
+
+Contents of section .data:
+ 200278 00000000 00000000 00000000 00000000 ................
+ 200288 00000000 ....
diff --git a/ld/testsuite/ld-size/size32-2-x86-64.d b/ld/testsuite/ld-size/size32-2-x86-64.d
new file mode 100644
index 0000000..1851e0f
--- /dev/null
+++ b/ld/testsuite/ld-size/size32-2-x86-64.d
@@ -0,0 +1,20 @@
+#source: size32-2.s
+#as: --64
+#ld: -shared -melf_x86_64
+#objdump: -R -s -j .data
+#target: x86_64-*-*
+
+.*: +file format .*
+
+DYNAMIC RELOCATION RECORDS
+OFFSET TYPE VALUE
+0+2003d8 R_X86_64_SIZE32 xxx
+0+2003dc R_X86_64_SIZE32 yyy
+0+2003e0 R_X86_64_SIZE32 zzz
+0+2003e4 R_X86_64_SIZE32 zzz-0x000000000000001e
+0+2003e8 R_X86_64_SIZE32 zzz\+0x000000000000001e
+
+
+Contents of section .data:
+ 2003d8 00000000 00000000 00000000 00000000 ................
+ 2003e8 00000000 ....
diff --git a/ld/testsuite/ld-size/size32-2.s b/ld/testsuite/ld-size/size32-2.s
new file mode 100644
index 0000000..d5a650d
--- /dev/null
+++ b/ld/testsuite/ld-size/size32-2.s
@@ -0,0 +1,22 @@
+# 32-bit size relocation against TLS symbol in shared object
+ .globl xxx
+ .section .tbss,"awT",%nobits
+ .p2align 2
+ .type xxx, %object
+ .size xxx, 40
+xxx:
+ .zero 40
+ .globl yyy
+ .section .tdata,"awT",%progbits
+ .p2align 2
+ .type yyy, %object
+ .size yyy, 40
+yyy:
+ .zero 40
+ .data
+ .p2align 2
+ .long xxx@SIZE
+ .long yyy@SIZE
+ .long zzz@SIZE
+ .long zzz@SIZE-30
+ .long zzz@SIZE+30
diff --git a/ld/testsuite/ld-size/size64-1-x32.d b/ld/testsuite/ld-size/size64-1-x32.d
new file mode 100644
index 0000000..51c2f13
--- /dev/null
+++ b/ld/testsuite/ld-size/size64-1-x32.d
@@ -0,0 +1,23 @@
+#source: size64-1.s
+#as: --x32
+#ld: -shared -melf32_x86_64
+#objdump: -R -s -j .data
+#target: x86_64-*-*
+
+.*: +file format .*
+
+DYNAMIC RELOCATION RECORDS
+OFFSET TYPE VALUE
+0+200220 R_X86_64_SIZE32 xxx
+0+200228 R_X86_64_SIZE64 xxx-0x0000001e
+0+200230 R_X86_64_SIZE64 xxx\+0x0000001e
+0+200238 R_X86_64_SIZE32 yyy
+0+200240 R_X86_64_SIZE32 zzz
+
+
+Contents of section .data:
+ 200220 00000000 00000000 00000000 00000000 ................
+ 200230 00000000 00000000 00000000 00000000 ................
+ 200240 00000000 00000000 00000000 00000000 ................
+ 200250 00000000 00000000 00000000 00000000 ................
+ 200260 00000000 00000000 00000000 00000000 ................
diff --git a/ld/testsuite/ld-size/size64-1-x86-64.d b/ld/testsuite/ld-size/size64-1-x86-64.d
new file mode 100644
index 0000000..c4ed9c2
--- /dev/null
+++ b/ld/testsuite/ld-size/size64-1-x86-64.d
@@ -0,0 +1,23 @@
+#source: size64-1.s
+#as: --64
+#ld: -shared -melf_x86_64
+#objdump: -R -s -j .data
+#target: x86_64-*-*
+
+.*: +file format .*
+
+DYNAMIC RELOCATION RECORDS
+OFFSET TYPE VALUE
+0+200360 R_X86_64_SIZE64 xxx
+0+200368 R_X86_64_SIZE64 xxx-0x000000000000001e
+0+200370 R_X86_64_SIZE64 xxx\+0x000000000000001e
+0+200378 R_X86_64_SIZE64 yyy
+0+200380 R_X86_64_SIZE64 zzz
+
+
+Contents of section .data:
+ 200360 00000000 00000000 00000000 00000000 ................
+ 200370 00000000 00000000 00000000 00000000 ................
+ 200380 00000000 00000000 00000000 00000000 ................
+ 200390 00000000 00000000 00000000 00000000 ................
+ 2003a0 00000000 00000000 00000000 00000000 ................
diff --git a/ld/testsuite/ld-size/size64-1.s b/ld/testsuite/ld-size/size64-1.s
new file mode 100644
index 0000000..25672b5
--- /dev/null
+++ b/ld/testsuite/ld-size/size64-1.s
@@ -0,0 +1,14 @@
+# 64-bit size relocation in shared object
+ .comm xxx,40,32
+ .data
+ .p2align 2
+ .quad xxx@SIZE
+ .quad xxx@SIZE-30
+ .quad xxx@SIZE+30
+ .quad yyy@SIZE
+ .quad zzz@SIZE
+ .globl yyy
+ .type yyy, %object
+ .size yyy, 40
+yyy:
+ .zero 40
diff --git a/ld/testsuite/ld-size/size64-2-x32.d b/ld/testsuite/ld-size/size64-2-x32.d
new file mode 100644
index 0000000..1a30c98
--- /dev/null
+++ b/ld/testsuite/ld-size/size64-2-x32.d
@@ -0,0 +1,21 @@
+#source: size64-2.s
+#as: --x32
+#ld: -shared -melf32_x86_64
+#objdump: -R -s -j .data
+#target: x86_64-*-*
+
+.*: +file format .*
+
+DYNAMIC RELOCATION RECORDS
+OFFSET TYPE VALUE
+0+200278 R_X86_64_SIZE32 xxx
+0+200280 R_X86_64_SIZE32 yyy
+0+200288 R_X86_64_SIZE32 zzz
+0+200290 R_X86_64_SIZE64 zzz-0x0000001e
+0+200298 R_X86_64_SIZE64 zzz\+0x0000001e
+
+
+Contents of section .data:
+ 200278 00000000 00000000 00000000 00000000 ................
+ 200288 00000000 00000000 00000000 00000000 ................
+ 200298 00000000 00000000 ........
diff --git a/ld/testsuite/ld-size/size64-2-x86-64.d b/ld/testsuite/ld-size/size64-2-x86-64.d
new file mode 100644
index 0000000..4cc11cf
--- /dev/null
+++ b/ld/testsuite/ld-size/size64-2-x86-64.d
@@ -0,0 +1,21 @@
+#source: size64-2.s
+#as: --64
+#ld: -shared -melf_x86_64
+#objdump: -R -s -j .data
+#target: x86_64-*-*
+
+.*: +file format .*
+
+DYNAMIC RELOCATION RECORDS
+OFFSET TYPE VALUE
+0+2003d8 R_X86_64_SIZE64 xxx
+0+2003e0 R_X86_64_SIZE64 yyy
+0+2003e8 R_X86_64_SIZE64 zzz
+0+2003f0 R_X86_64_SIZE64 zzz-0x000000000000001e
+0+2003f8 R_X86_64_SIZE64 zzz\+0x000000000000001e
+
+
+Contents of section .data:
+ 2003d8 00000000 00000000 00000000 00000000 ................
+ 2003e8 00000000 00000000 00000000 00000000 ................
+ 2003f8 00000000 00000000 ........
diff --git a/ld/testsuite/ld-size/size64-2.s b/ld/testsuite/ld-size/size64-2.s
new file mode 100644
index 0000000..e443085
--- /dev/null
+++ b/ld/testsuite/ld-size/size64-2.s
@@ -0,0 +1,22 @@
+# 64-bit size relocation against TLS symbol in shared object
+ .globl xxx
+ .section .tbss,"awT",%nobits
+ .p2align 2
+ .type xxx, %object
+ .size xxx, 40
+xxx:
+ .zero 40
+ .globl yyy
+ .section .tdata,"awT",%progbits
+ .p2align 2
+ .type yyy, %object
+ .size yyy, 40
+yyy:
+ .zero 40
+ .data
+ .p2align 2
+ .quad xxx@SIZE
+ .quad yyy@SIZE
+ .quad zzz@SIZE
+ .quad zzz@SIZE-30
+ .quad zzz@SIZE+30