aboutsummaryrefslogtreecommitdiff
path: root/gas/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 /gas/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 'gas/testsuite')
-rw-r--r--gas/testsuite/ChangeLog28
-rw-r--r--gas/testsuite/gas/i386/i386.exp12
-rw-r--r--gas/testsuite/gas/i386/ilp32/x86-64-size-1.d23
-rw-r--r--gas/testsuite/gas/i386/ilp32/x86-64-size-2.d20
-rw-r--r--gas/testsuite/gas/i386/ilp32/x86-64-size-3.d19
-rw-r--r--gas/testsuite/gas/i386/ilp32/x86-64-size-4.d18
-rw-r--r--gas/testsuite/gas/i386/ilp32/x86-64-size-5.d17
-rw-r--r--gas/testsuite/gas/i386/size-1.d22
-rw-r--r--gas/testsuite/gas/i386/size-1.s27
-rw-r--r--gas/testsuite/gas/i386/size-2.d20
-rw-r--r--gas/testsuite/gas/i386/size-2.s26
-rw-r--r--gas/testsuite/gas/i386/size-3.d18
-rw-r--r--gas/testsuite/gas/i386/size-3.s22
-rw-r--r--gas/testsuite/gas/i386/size-4.d17
-rw-r--r--gas/testsuite/gas/i386/size-4.s20
-rw-r--r--gas/testsuite/gas/i386/x86-64-size-1.d23
-rw-r--r--gas/testsuite/gas/i386/x86-64-size-2.d21
-rw-r--r--gas/testsuite/gas/i386/x86-64-size-3.d19
-rw-r--r--gas/testsuite/gas/i386/x86-64-size-4.d18
-rw-r--r--gas/testsuite/gas/i386/x86-64-size-5.d16
-rw-r--r--gas/testsuite/gas/i386/x86-64-size-5.s21
-rw-r--r--gas/testsuite/gas/i386/x86-64-size-inval-1.l25
-rw-r--r--gas/testsuite/gas/i386/x86-64-size-inval-1.s11
23 files changed, 463 insertions, 0 deletions
diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog
index 622d266..9bbead9 100644
--- a/gas/testsuite/ChangeLog
+++ b/gas/testsuite/ChangeLog
@@ -1,3 +1,31 @@
+2013-01-16 H.J. Lu <hongjiu.lu@intel.com>
+
+ * 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.
+
2013-01-16 Alan Modra <amodra@gmail.com>
* gas/ppc/htm.d: Ignore padding at end of section.
diff --git a/gas/testsuite/gas/i386/i386.exp b/gas/testsuite/gas/i386/i386.exp
index 70f1c37..6daf559 100644
--- a/gas/testsuite/gas/i386/i386.exp
+++ b/gas/testsuite/gas/i386/i386.exp
@@ -289,6 +289,11 @@ if [expr ([istarget "i*86-*-*"] || [istarget "x86_64-*-*"]) && [gas_32_check]]
run_dump_test "dw2-compress-2"
run_dump_test "bad-size"
+
+ run_dump_test "size-1"
+ run_dump_test "size-2"
+ run_dump_test "size-3"
+ run_dump_test "size-4"
}
# This is a PE specific test.
@@ -531,6 +536,13 @@ if [expr ([istarget "i*86-*-*"] || [istarget "x86_64-*-*"]) && [gas_64_check]] t
run_dump_test "debug1"
run_dump_test "x86-64-dw2-compress-2"
+
+ run_dump_test "x86-64-size-1"
+ run_dump_test "x86-64-size-2"
+ run_dump_test "x86-64-size-3"
+ run_dump_test "x86-64-size-4"
+ run_dump_test "x86-64-size-5"
+ run_list_test "x86-64-size-inval-1" "-al"
}
set ASFLAGS "$old_ASFLAGS"
diff --git a/gas/testsuite/gas/i386/ilp32/x86-64-size-1.d b/gas/testsuite/gas/i386/ilp32/x86-64-size-1.d
new file mode 100644
index 0000000..7b0884f
--- /dev/null
+++ b/gas/testsuite/gas/i386/ilp32/x86-64-size-1.d
@@ -0,0 +1,23 @@
+#name: x32 size 1
+#source: ../size-1.s
+#readelf: -r
+
+
+Relocation section '.rela.text' at offset 0x2e0 contains 9 entries:
+ Offset Info Type Sym.Value Sym. Name \+ Addend
+0+1 00000420 R_X86_64_SIZE32 00000000 xxx \+ 0
+0+6 00000420 R_X86_64_SIZE32 00000000 xxx - 8
+0+b 00000420 R_X86_64_SIZE32 00000000 xxx \+ 8
+0+10 00000520 R_X86_64_SIZE32 00000000 yyy \+ 0
+0+15 00000520 R_X86_64_SIZE32 00000000 yyy - 10
+0+1a 00000520 R_X86_64_SIZE32 00000000 yyy \+ 10
+0+1f 00000620 R_X86_64_SIZE32 00000020 zzz \+ 0
+0+24 00000620 R_X86_64_SIZE32 00000020 zzz - 20
+0+29 00000620 R_X86_64_SIZE32 00000020 zzz \+ 20
+
+Relocation section '.rela.data' at offset 0x34c contains 3 entries:
+ Offset Info Type Sym.Value Sym. Name \+ Addend
+0+50 00000420 R_X86_64_SIZE32 00000000 xxx - 1
+0+54 00000520 R_X86_64_SIZE32 00000000 yyy \+ 2
+0+58 00000620 R_X86_64_SIZE32 00000020 zzz \+ 0
+#pass
diff --git a/gas/testsuite/gas/i386/ilp32/x86-64-size-2.d b/gas/testsuite/gas/i386/ilp32/x86-64-size-2.d
new file mode 100644
index 0000000..8b210bf
--- /dev/null
+++ b/gas/testsuite/gas/i386/ilp32/x86-64-size-2.d
@@ -0,0 +1,20 @@
+#name: x32 size 2
+#source: ../size-2.s
+#objdump: -dwr
+
+.*: +file format .*
+
+
+Disassembly of section .text:
+
+0+ <.text>:
+[ ]*[a-f0-9]+: b8 50 00 00 00 mov \$0x50,%eax
+[ ]*[a-f0-9]+: b8 48 00 00 00 mov \$0x48,%eax
+[ ]*[a-f0-9]+: b8 58 00 00 00 mov \$0x58,%eax
+[ ]*[a-f0-9]+: b8 1e 00 00 00 mov \$0x1e,%eax
+[ ]*[a-f0-9]+: b8 0e 00 00 00 mov \$0xe,%eax
+[ ]*[a-f0-9]+: b8 2e 00 00 00 mov \$0x2e,%eax
+[ ]*[a-f0-9]+: b8 90 99 99 19 mov \$0x19999990,%eax
+[ ]*[a-f0-9]+: b8 70 99 99 19 mov \$0x19999970,%eax
+[ ]*[a-f0-9]+: b8 b0 99 99 19 mov \$0x199999b0,%eax
+#pass
diff --git a/gas/testsuite/gas/i386/ilp32/x86-64-size-3.d b/gas/testsuite/gas/i386/ilp32/x86-64-size-3.d
new file mode 100644
index 0000000..044c1e2
--- /dev/null
+++ b/gas/testsuite/gas/i386/ilp32/x86-64-size-3.d
@@ -0,0 +1,19 @@
+#name: x32 size 3
+#source: ../size-3.s
+#readelf: -r
+
+
+Relocation section '.rela.text' at offset 0x334 contains 6 entries:
+ Offset Info Type Sym.Value Sym. Name \+ Addend
+0+1 00000620 R_X86_64_SIZE32 00000000 xxx \+ 0
+0+6 00000620 R_X86_64_SIZE32 00000000 xxx - 8
+0+b 00000620 R_X86_64_SIZE32 00000000 xxx \+ 8
+0+10 00000720 R_X86_64_SIZE32 00000000 yyy \+ 0
+0+15 00000720 R_X86_64_SIZE32 00000000 yyy - 10
+0+1a 00000720 R_X86_64_SIZE32 00000000 yyy \+ 10
+
+Relocation section '.rela.tdata' at offset 0x37c contains 2 entries:
+ Offset Info Type Sym.Value Sym. Name \+ Addend
+0+50 00000620 R_X86_64_SIZE32 00000000 xxx - 1
+0+54 00000720 R_X86_64_SIZE32 00000000 yyy \+ 2
+#pass
diff --git a/gas/testsuite/gas/i386/ilp32/x86-64-size-4.d b/gas/testsuite/gas/i386/ilp32/x86-64-size-4.d
new file mode 100644
index 0000000..8d9ae19
--- /dev/null
+++ b/gas/testsuite/gas/i386/ilp32/x86-64-size-4.d
@@ -0,0 +1,18 @@
+#name: x32 size 4
+#source: ../size-4.s
+#objdump: -dwr
+
+
+.*: +file format .*
+
+
+Disassembly of section .text:
+
+0+ <.text>:
+[ ]*[a-f0-9]+: b8 50 00 00 00 mov \$0x50,%eax
+[ ]*[a-f0-9]+: b8 48 00 00 00 mov \$0x48,%eax
+[ ]*[a-f0-9]+: b8 58 00 00 00 mov \$0x58,%eax
+[ ]*[a-f0-9]+: b8 1e 00 00 00 mov \$0x1e,%eax
+[ ]*[a-f0-9]+: b8 0e 00 00 00 mov \$0xe,%eax
+[ ]*[a-f0-9]+: b8 2e 00 00 00 mov \$0x2e,%eax
+#pass
diff --git a/gas/testsuite/gas/i386/ilp32/x86-64-size-5.d b/gas/testsuite/gas/i386/ilp32/x86-64-size-5.d
new file mode 100644
index 0000000..1c420fa
--- /dev/null
+++ b/gas/testsuite/gas/i386/ilp32/x86-64-size-5.d
@@ -0,0 +1,17 @@
+#name: x32 size 5
+#source: ../x86-64-size-5.s
+#readelf: -r
+
+
+Relocation section '.rela.text' at offset 0x2dc contains 3 entries:
+ Offset Info Type Sym.Value Sym. Name \+ Addend
+0+2 00000421 R_X86_64_SIZE64 00000000 xxx \+ 0
+0+c 00000421 R_X86_64_SIZE64 00000000 xxx - 8
+0+16 00000421 R_X86_64_SIZE64 00000000 xxx \+ 8
+
+Relocation section '.rela.data' at offset 0x300 contains 3 entries:
+ Offset Info Type Sym.Value Sym. Name \+ Addend
+0+50 00000421 R_X86_64_SIZE64 00000000 xxx - 1
+0+58 00000621 R_X86_64_SIZE64 00000000 yyy \+ c8
+0+60 00000521 R_X86_64_SIZE64 00000020 zzz \+ 0
+#pass
diff --git a/gas/testsuite/gas/i386/size-1.d b/gas/testsuite/gas/i386/size-1.d
new file mode 100644
index 0000000..ae10fdf
--- /dev/null
+++ b/gas/testsuite/gas/i386/size-1.d
@@ -0,0 +1,22 @@
+#name: i386 size 1
+#readelf: -r
+
+
+Relocation section '.rel.text' at offset 0x2dc contains 9 entries:
+ Offset Info Type Sym.Value Sym. Name
+0+1 00000426 R_386_SIZE32 00000000 xxx
+0+6 00000426 R_386_SIZE32 00000000 xxx
+0+b 00000426 R_386_SIZE32 00000000 xxx
+0+10 00000526 R_386_SIZE32 00000000 yyy
+0+15 00000526 R_386_SIZE32 00000000 yyy
+0+1a 00000526 R_386_SIZE32 00000000 yyy
+0+1f 00000626 R_386_SIZE32 00000020 zzz
+0+24 00000626 R_386_SIZE32 00000020 zzz
+0+29 00000626 R_386_SIZE32 00000020 zzz
+
+Relocation section '.rel.data' at offset 0x324 contains 3 entries:
+ Offset Info Type Sym.Value Sym. Name
+0+50 00000426 R_386_SIZE32 00000000 xxx
+0+54 00000526 R_386_SIZE32 00000000 yyy
+0+58 00000626 R_386_SIZE32 00000020 zzz
+#pass
diff --git a/gas/testsuite/gas/i386/size-1.s b/gas/testsuite/gas/i386/size-1.s
new file mode 100644
index 0000000..2a19dbd
--- /dev/null
+++ b/gas/testsuite/gas/i386/size-1.s
@@ -0,0 +1,27 @@
+# Test SIZE32 relocations against global symbols
+ .text
+ movl $xxx@SIZE, %eax
+ movl $xxx@SIZE - 8, %eax
+ movl $xxx@SIZE + 8, %eax
+ movl $yyy@SIZE, %eax
+ movl $yyy@SIZE - 16, %eax
+ movl $yyy@SIZE + 16, %eax
+ movl $zzz@SIZE, %eax
+ movl $zzz@SIZE - 32, %eax
+ movl $zzz@SIZE + 32, %eax
+ .comm zzz,429496729,32
+ .bss
+ .global yyy
+ .type yyy,%object
+ .size yyy,30
+yyy:
+ .zero 30
+ .data
+ .global xxx
+ .type xxx,%object
+ .size xxx,80
+xxx:
+ .zero 80
+ .long xxx@SIZE - 1
+ .long yyy@SIZE + 2
+ .long zzz@SIZE
diff --git a/gas/testsuite/gas/i386/size-2.d b/gas/testsuite/gas/i386/size-2.d
new file mode 100644
index 0000000..685720b
--- /dev/null
+++ b/gas/testsuite/gas/i386/size-2.d
@@ -0,0 +1,20 @@
+#name: i386 size 2
+#objdump: -dwr
+
+
+.*: +file format .*
+
+
+Disassembly of section .text:
+
+0+ <.text>:
+[ ]*[a-f0-9]+: b8 50 00 00 00 mov \$0x50,%eax
+[ ]*[a-f0-9]+: b8 48 00 00 00 mov \$0x48,%eax
+[ ]*[a-f0-9]+: b8 58 00 00 00 mov \$0x58,%eax
+[ ]*[a-f0-9]+: b8 1e 00 00 00 mov \$0x1e,%eax
+[ ]*[a-f0-9]+: b8 0e 00 00 00 mov \$0xe,%eax
+[ ]*[a-f0-9]+: b8 2e 00 00 00 mov \$0x2e,%eax
+[ ]*[a-f0-9]+: b8 90 99 99 19 mov \$0x19999990,%eax
+[ ]*[a-f0-9]+: b8 70 99 99 19 mov \$0x19999970,%eax
+[ ]*[a-f0-9]+: b8 b0 99 99 19 mov \$0x199999b0,%eax
+#pass
diff --git a/gas/testsuite/gas/i386/size-2.s b/gas/testsuite/gas/i386/size-2.s
new file mode 100644
index 0000000..09f8f47
--- /dev/null
+++ b/gas/testsuite/gas/i386/size-2.s
@@ -0,0 +1,26 @@
+# Test SIZE32 relocations against local symbols
+ .text
+ movl $xxx@SIZE, %eax
+ movl $xxx@SIZE - 8, %eax
+ movl $xxx@SIZE + 8, %eax
+ movl $yyy@SIZE, %eax
+ movl $yyy@SIZE - 16, %eax
+ movl $yyy@SIZE + 16, %eax
+ movl $zzz@SIZE, %eax
+ movl $zzz@SIZE - 32, %eax
+ movl $zzz@SIZE + 32, %eax
+ .local zzz
+ .comm zzz,429496720,32
+ .bss
+ .type yyy,%object
+ .size yyy,30
+yyy:
+ .zero 30
+ .data
+ .type xxx,%object
+ .size xxx,80
+xxx:
+ .zero 80
+ .long xxx@SIZE - 1
+ .long yyy@SIZE + 2
+ .long zzz@SIZE
diff --git a/gas/testsuite/gas/i386/size-3.d b/gas/testsuite/gas/i386/size-3.d
new file mode 100644
index 0000000..78a9fb6
--- /dev/null
+++ b/gas/testsuite/gas/i386/size-3.d
@@ -0,0 +1,18 @@
+#name: i386 size 3
+#readelf: -r
+
+
+Relocation section '.rel.text' at offset 0x334 contains 6 entries:
+ Offset Info Type Sym.Value Sym. Name
+0+1 00000626 R_386_SIZE32 00000000 xxx
+0+6 00000626 R_386_SIZE32 00000000 xxx
+0+b 00000626 R_386_SIZE32 00000000 xxx
+0+10 00000726 R_386_SIZE32 00000000 yyy
+0+15 00000726 R_386_SIZE32 00000000 yyy
+0+1a 00000726 R_386_SIZE32 00000000 yyy
+
+Relocation section '.rel.tdata' at offset 0x364 contains 2 entries:
+ Offset Info Type Sym.Value Sym. Name
+0+50 00000626 R_386_SIZE32 00000000 xxx
+0+54 00000726 R_386_SIZE32 00000000 yyy
+#pass
diff --git a/gas/testsuite/gas/i386/size-3.s b/gas/testsuite/gas/i386/size-3.s
new file mode 100644
index 0000000..420cb84
--- /dev/null
+++ b/gas/testsuite/gas/i386/size-3.s
@@ -0,0 +1,22 @@
+# Test SIZE32 relocations against global TLS symbols
+ .text
+ movl $xxx@SIZE, %eax
+ movl $xxx@SIZE - 8, %eax
+ movl $xxx@SIZE + 8, %eax
+ movl $yyy@SIZE, %eax
+ movl $yyy@SIZE - 16, %eax
+ movl $yyy@SIZE + 16, %eax
+ .section .tbss,"awT",%nobits
+ .global yyy
+ .type yyy,%object
+ .size yyy,30
+yyy:
+ .zero 30
+ .section .tdata,"awT",%progbits
+ .global xxx
+ .type xxx,%object
+ .size xxx,80
+xxx:
+ .zero 80
+ .long xxx@SIZE - 1
+ .long yyy@SIZE + 2
diff --git a/gas/testsuite/gas/i386/size-4.d b/gas/testsuite/gas/i386/size-4.d
new file mode 100644
index 0000000..384542c
--- /dev/null
+++ b/gas/testsuite/gas/i386/size-4.d
@@ -0,0 +1,17 @@
+#name: i386 size 4
+#objdump: -dwr
+
+
+.*: +file format .*
+
+
+Disassembly of section .text:
+
+0+ <.text>:
+[ ]*[a-f0-9]+: b8 50 00 00 00 mov \$0x50,%eax
+[ ]*[a-f0-9]+: b8 48 00 00 00 mov \$0x48,%eax
+[ ]*[a-f0-9]+: b8 58 00 00 00 mov \$0x58,%eax
+[ ]*[a-f0-9]+: b8 1e 00 00 00 mov \$0x1e,%eax
+[ ]*[a-f0-9]+: b8 0e 00 00 00 mov \$0xe,%eax
+[ ]*[a-f0-9]+: b8 2e 00 00 00 mov \$0x2e,%eax
+#pass
diff --git a/gas/testsuite/gas/i386/size-4.s b/gas/testsuite/gas/i386/size-4.s
new file mode 100644
index 0000000..1e0944c
--- /dev/null
+++ b/gas/testsuite/gas/i386/size-4.s
@@ -0,0 +1,20 @@
+# Test SIZE32 relocations against local TLS symbols
+ .text
+ movl $xxx@SIZE, %eax
+ movl $xxx@SIZE - 8, %eax
+ movl $xxx@SIZE + 8, %eax
+ movl $yyy@SIZE, %eax
+ movl $yyy@SIZE - 16, %eax
+ movl $yyy@SIZE + 16, %eax
+ .section .tbss,"awT",%nobits
+ .type yyy,%object
+ .size yyy,30
+yyy:
+ .zero 30
+ .section .tdata,"awT",%progbits
+ .type xxx,%object
+ .size xxx,80
+xxx:
+ .zero 80
+ .long xxx@SIZE - 1
+ .long yyy@SIZE + 2
diff --git a/gas/testsuite/gas/i386/x86-64-size-1.d b/gas/testsuite/gas/i386/x86-64-size-1.d
new file mode 100644
index 0000000..03484f8
--- /dev/null
+++ b/gas/testsuite/gas/i386/x86-64-size-1.d
@@ -0,0 +1,23 @@
+#name: x86-64 size 1
+#source: size-1.s
+#readelf: -r
+
+
+Relocation section '.rela.text' at offset 0x400 contains 9 entries:
+ Offset Info Type Sym. Value Sym. Name \+ Addend
+0+1 000400000020 R_X86_64_SIZE32 0000000000000000 xxx \+ 0
+0+6 000400000020 R_X86_64_SIZE32 0000000000000000 xxx - 8
+0+b 000400000020 R_X86_64_SIZE32 0000000000000000 xxx \+ 8
+0+10 000500000020 R_X86_64_SIZE32 0000000000000000 yyy \+ 0
+0+15 000500000020 R_X86_64_SIZE32 0000000000000000 yyy - 10
+0+1a 000500000020 R_X86_64_SIZE32 0000000000000000 yyy \+ 10
+0+1f 000600000020 R_X86_64_SIZE32 0000000000000020 zzz \+ 0
+0+24 000600000020 R_X86_64_SIZE32 0000000000000020 zzz - 20
+0+29 000600000020 R_X86_64_SIZE32 0000000000000020 zzz \+ 20
+
+Relocation section '.rela.data' at offset 0x4d8 contains 3 entries:
+ Offset Info Type Sym. Value Sym. Name \+ Addend
+0+50 000400000020 R_X86_64_SIZE32 0000000000000000 xxx - 1
+0+54 000500000020 R_X86_64_SIZE32 0000000000000000 yyy \+ 2
+0+58 000600000020 R_X86_64_SIZE32 0000000000000020 zzz \+ 0
+#pass
diff --git a/gas/testsuite/gas/i386/x86-64-size-2.d b/gas/testsuite/gas/i386/x86-64-size-2.d
new file mode 100644
index 0000000..f144c47
--- /dev/null
+++ b/gas/testsuite/gas/i386/x86-64-size-2.d
@@ -0,0 +1,21 @@
+#name: x86-64 size 2
+#source: size-2.s
+#objdump: -dwr
+
+
+.*: +file format .*
+
+
+Disassembly of section .text:
+
+0+ <.text>:
+[ ]*[a-f0-9]+: b8 50 00 00 00 mov \$0x50,%eax
+[ ]*[a-f0-9]+: b8 48 00 00 00 mov \$0x48,%eax
+[ ]*[a-f0-9]+: b8 58 00 00 00 mov \$0x58,%eax
+[ ]*[a-f0-9]+: b8 1e 00 00 00 mov \$0x1e,%eax
+[ ]*[a-f0-9]+: b8 0e 00 00 00 mov \$0xe,%eax
+[ ]*[a-f0-9]+: b8 2e 00 00 00 mov \$0x2e,%eax
+[ ]*[a-f0-9]+: b8 90 99 99 19 mov \$0x19999990,%eax
+[ ]*[a-f0-9]+: b8 70 99 99 19 mov \$0x19999970,%eax
+[ ]*[a-f0-9]+: b8 b0 99 99 19 mov \$0x199999b0,%eax
+#pass
diff --git a/gas/testsuite/gas/i386/x86-64-size-3.d b/gas/testsuite/gas/i386/x86-64-size-3.d
new file mode 100644
index 0000000..0ce908e
--- /dev/null
+++ b/gas/testsuite/gas/i386/x86-64-size-3.d
@@ -0,0 +1,19 @@
+#name: x86-64 size 3
+#source: size-3.s
+#readelf: -r
+
+
+Relocation section '.rela.text' at offset 0x490 contains 6 entries:
+ Offset Info Type Sym. Value Sym. Name \+ Addend
+0+1 000600000020 R_X86_64_SIZE32 0000000000000000 xxx \+ 0
+0+6 000600000020 R_X86_64_SIZE32 0000000000000000 xxx - 8
+0+b 000600000020 R_X86_64_SIZE32 0000000000000000 xxx \+ 8
+0+10 000700000020 R_X86_64_SIZE32 0000000000000000 yyy \+ 0
+0+15 000700000020 R_X86_64_SIZE32 0000000000000000 yyy - 10
+0+1a 000700000020 R_X86_64_SIZE32 0000000000000000 yyy \+ 10
+
+Relocation section '.rela.tdata' at offset 0x520 contains 2 entries:
+ Offset Info Type Sym. Value Sym. Name \+ Addend
+0+50 000600000020 R_X86_64_SIZE32 0000000000000000 xxx - 1
+0+54 000700000020 R_X86_64_SIZE32 0000000000000000 yyy \+ 2
+#pass
diff --git a/gas/testsuite/gas/i386/x86-64-size-4.d b/gas/testsuite/gas/i386/x86-64-size-4.d
new file mode 100644
index 0000000..8c3583c
--- /dev/null
+++ b/gas/testsuite/gas/i386/x86-64-size-4.d
@@ -0,0 +1,18 @@
+#name: x86-64 size 4
+#source: size-4.s
+#objdump: -dwr
+
+
+.*: +file format .*
+
+
+Disassembly of section .text:
+
+0+ <.text>:
+[ ]*[a-f0-9]+: b8 50 00 00 00 mov \$0x50,%eax
+[ ]*[a-f0-9]+: b8 48 00 00 00 mov \$0x48,%eax
+[ ]*[a-f0-9]+: b8 58 00 00 00 mov \$0x58,%eax
+[ ]*[a-f0-9]+: b8 1e 00 00 00 mov \$0x1e,%eax
+[ ]*[a-f0-9]+: b8 0e 00 00 00 mov \$0xe,%eax
+[ ]*[a-f0-9]+: b8 2e 00 00 00 mov \$0x2e,%eax
+#pass
diff --git a/gas/testsuite/gas/i386/x86-64-size-5.d b/gas/testsuite/gas/i386/x86-64-size-5.d
new file mode 100644
index 0000000..be7e90d
--- /dev/null
+++ b/gas/testsuite/gas/i386/x86-64-size-5.d
@@ -0,0 +1,16 @@
+#name: x86-64 size 5
+#readelf: -r
+
+
+Relocation section '.rela.text' at offset 0x3f8 contains 3 entries:
+ Offset Info Type Sym. Value Sym. Name \+ Addend
+0+2 000400000021 R_X86_64_SIZE64 0000000000000000 xxx \+ 0
+0+c 000400000021 R_X86_64_SIZE64 0000000000000000 xxx - 8
+0+16 000400000021 R_X86_64_SIZE64 0000000000000000 xxx \+ 8
+
+Relocation section '.rela.data' at offset 0x440 contains 3 entries:
+ Offset Info Type Sym. Value Sym. Name \+ Addend
+0+50 000400000021 R_X86_64_SIZE64 0000000000000000 xxx - 1
+0+58 000600000021 R_X86_64_SIZE64 0000000000000000 yyy \+ c8
+0+60 000500000021 R_X86_64_SIZE64 0000000000000020 zzz \+ 0
+#pass
diff --git a/gas/testsuite/gas/i386/x86-64-size-5.s b/gas/testsuite/gas/i386/x86-64-size-5.s
new file mode 100644
index 0000000..42d248e
--- /dev/null
+++ b/gas/testsuite/gas/i386/x86-64-size-5.s
@@ -0,0 +1,21 @@
+# Test SIZE64 relocation
+ .text
+ movq $xxx@SIZE, %r15
+ movq $xxx@SIZE - 8, %r15
+ movq $xxx@SIZE + 8, %r15
+ .comm zzz,4294967290,32
+ .bss
+ .global yyy
+ .type yyy,%object
+ .size yyy,30
+yyy:
+ .zero 30
+ .data
+ .global xxx
+ .type xxx,%object
+ .size xxx,80
+xxx:
+ .zero 80
+ .quad xxx@SIZE - 1
+ .quad yyy@SIZE + 200
+ .quad zzz@SIZE
diff --git a/gas/testsuite/gas/i386/x86-64-size-inval-1.l b/gas/testsuite/gas/i386/x86-64-size-inval-1.l
new file mode 100644
index 0000000..856174d
--- /dev/null
+++ b/gas/testsuite/gas/i386/x86-64-size-inval-1.l
@@ -0,0 +1,25 @@
+.*: Assembler messages:
+.*:5: Error: .*
+.*:6: Error: .*
+.*:10: Error: .*
+.*:11: Error: .*
+GAS LISTING .*
+
+
+[ ]*1[ ]+\# Test SIZE32 relocation overflow
+[ ]*2[ ]+\.local yyy
+[ ]*3[ ]+\.comm yyy,80,32
+[ ]*4[ ]+\.text
+[ ]*5[ ]+\?\?\?\? B85E0000 movl \$xxx@SIZE \+ 100, %eax
+[ ]*5[ ]+00
+[ ]*6[ ]+\?\?\?\? B8ECFFFF movl \$yyy@SIZE - 100, %eax
+[ ]*6[ ]+FF
+[ ]*7[ ]+\.local xxx
+[ ]*8[ ]+\.comm xxx,4294967290,32
+[ ]*9[ ]+\.data
+[ ]*10[ ]+\?\?\?\? 5E000000 \.long xxx@SIZE \+ 100
+[ ]*11[ ]+\?\?\?\? ECFFFFFF \.long yyy@SIZE - 100
+\*\*\*\* Error:symbol size computation overflow
+\*\*\*\* Error:symbol size computation overflow
+\*\*\*\* Error:symbol size computation overflow
+\*\*\*\* Error:symbol size computation overflow
diff --git a/gas/testsuite/gas/i386/x86-64-size-inval-1.s b/gas/testsuite/gas/i386/x86-64-size-inval-1.s
new file mode 100644
index 0000000..020eb10
--- /dev/null
+++ b/gas/testsuite/gas/i386/x86-64-size-inval-1.s
@@ -0,0 +1,11 @@
+# Test SIZE32 relocation overflow
+ .local yyy
+ .comm yyy,80,32
+ .text
+ movl $xxx@SIZE + 100, %eax
+ movl $yyy@SIZE - 100, %eax
+ .local xxx
+ .comm xxx,4294967290,32
+ .data
+ .long xxx@SIZE + 100
+ .long yyy@SIZE - 100