aboutsummaryrefslogtreecommitdiff
path: root/gas
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
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')
-rw-r--r--gas/ChangeLog10
-rw-r--r--gas/config/tc-i386.c38
-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
25 files changed, 508 insertions, 3 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index 2c64f68..a011624 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,13 @@
+2013-01-16 H.J. Lu <hongjiu.lu@intel.com>
+
+ * 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.
+
2013-01-16 Alan Modra <amodra@gmail.com>
* config/tc-ppc.c (md_assemble <TE_PE>): Ignore line after
diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c
index 641af39..c96229e 100644
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -2686,6 +2686,14 @@ reloc (unsigned int size,
break;
}
+ if (other == BFD_RELOC_SIZE32)
+ {
+ if (size == 8)
+ return BFD_RELOC_SIZE64;
+ if (pcrel)
+ as_bad (_("there are no pc-relative size relocations"));
+ }
+
/* Sign-checking 4-byte relocations in 16-/32-bit code is pointless. */
if (size == 4 && (flag_code != CODE_64BIT || disallow_64bit_reloc))
sign = -1;
@@ -2769,8 +2777,11 @@ tc_i386_fix_adjustable (fixS *fixP ATTRIBUTE_UNUSED)
&& fixP->fx_r_type == BFD_RELOC_32_PCREL)
return 0;
- /* adjust_reloc_syms doesn't know about the GOT. */
- if (fixP->fx_r_type == BFD_RELOC_386_GOTOFF
+ /* Adjust_reloc_syms doesn't know about the GOT. Need to keep symbol
+ for size relocations. */
+ if (fixP->fx_r_type == BFD_RELOC_SIZE32
+ || fixP->fx_r_type == BFD_RELOC_SIZE64
+ || fixP->fx_r_type == BFD_RELOC_386_GOTOFF
|| fixP->fx_r_type == BFD_RELOC_386_PLT32
|| fixP->fx_r_type == BFD_RELOC_386_GOT32
|| fixP->fx_r_type == BFD_RELOC_386_TLS_GD
@@ -6708,6 +6719,9 @@ lex_got (enum bfd_reloc_code_real *rel,
const enum bfd_reloc_code_real rel[2];
const i386_operand_type types64;
} gotrel[] = {
+ { STRING_COMMA_LEN ("SIZE"), { BFD_RELOC_SIZE32,
+ BFD_RELOC_SIZE32 },
+ OPERAND_TYPE_IMM32_64 },
{ STRING_COMMA_LEN ("PLTOFF"), { _dummy_first_bfd_reloc_code_real,
BFD_RELOC_X86_64_PLTOFF64 },
OPERAND_TYPE_IMM64 },
@@ -6795,7 +6809,7 @@ lex_got (enum bfd_reloc_code_real *rel,
*types = gotrel[j].types64;
}
- if (GOT_symbol == NULL)
+ if (j != 0 && GOT_symbol == NULL)
GOT_symbol = symbol_find_or_make (GLOBAL_OFFSET_TABLE_NAME);
/* The length of the first part of our input line. */
@@ -9231,6 +9245,24 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
switch (fixp->fx_r_type)
{
+ case BFD_RELOC_SIZE32:
+ case BFD_RELOC_SIZE64:
+ if (S_IS_DEFINED (fixp->fx_addsy)
+ && !S_IS_EXTERNAL (fixp->fx_addsy))
+ {
+ /* Resolve size relocation against local symbol to size of
+ the symbol plus addend. */
+ valueT value = S_GET_SIZE (fixp->fx_addsy) + fixp->fx_offset;
+ if (fixp->fx_r_type == BFD_RELOC_SIZE32
+ && !fits_in_unsigned_long (value))
+ as_bad_where (fixp->fx_file, fixp->fx_line,
+ _("symbol size computation overflow"));
+ fixp->fx_addsy = NULL;
+ fixp->fx_subsy = NULL;
+ md_apply_fix (fixp, (valueT *) &value, NULL);
+ return NULL;
+ }
+
case BFD_RELOC_X86_64_PLT32:
case BFD_RELOC_X86_64_GOT32:
case BFD_RELOC_X86_64_GOTPCREL:
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