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.
This commit is contained in:
parent
c32d6f7bd4
commit
8fd4256dd0
@ -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
|
||||
|
@ -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:
|
||||
|
@ -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.
|
||||
|
@ -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"
|
||||
|
23
gas/testsuite/gas/i386/ilp32/x86-64-size-1.d
Normal file
23
gas/testsuite/gas/i386/ilp32/x86-64-size-1.d
Normal file
@ -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
|
20
gas/testsuite/gas/i386/ilp32/x86-64-size-2.d
Normal file
20
gas/testsuite/gas/i386/ilp32/x86-64-size-2.d
Normal file
@ -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
|
19
gas/testsuite/gas/i386/ilp32/x86-64-size-3.d
Normal file
19
gas/testsuite/gas/i386/ilp32/x86-64-size-3.d
Normal file
@ -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
|
18
gas/testsuite/gas/i386/ilp32/x86-64-size-4.d
Normal file
18
gas/testsuite/gas/i386/ilp32/x86-64-size-4.d
Normal file
@ -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
|
17
gas/testsuite/gas/i386/ilp32/x86-64-size-5.d
Normal file
17
gas/testsuite/gas/i386/ilp32/x86-64-size-5.d
Normal file
@ -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
|
22
gas/testsuite/gas/i386/size-1.d
Normal file
22
gas/testsuite/gas/i386/size-1.d
Normal file
@ -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
|
27
gas/testsuite/gas/i386/size-1.s
Normal file
27
gas/testsuite/gas/i386/size-1.s
Normal file
@ -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
|
20
gas/testsuite/gas/i386/size-2.d
Normal file
20
gas/testsuite/gas/i386/size-2.d
Normal file
@ -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
|
26
gas/testsuite/gas/i386/size-2.s
Normal file
26
gas/testsuite/gas/i386/size-2.s
Normal file
@ -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
|
18
gas/testsuite/gas/i386/size-3.d
Normal file
18
gas/testsuite/gas/i386/size-3.d
Normal file
@ -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
|
22
gas/testsuite/gas/i386/size-3.s
Normal file
22
gas/testsuite/gas/i386/size-3.s
Normal file
@ -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
|
17
gas/testsuite/gas/i386/size-4.d
Normal file
17
gas/testsuite/gas/i386/size-4.d
Normal file
@ -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
|
20
gas/testsuite/gas/i386/size-4.s
Normal file
20
gas/testsuite/gas/i386/size-4.s
Normal file
@ -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
|
23
gas/testsuite/gas/i386/x86-64-size-1.d
Normal file
23
gas/testsuite/gas/i386/x86-64-size-1.d
Normal file
@ -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
|
21
gas/testsuite/gas/i386/x86-64-size-2.d
Normal file
21
gas/testsuite/gas/i386/x86-64-size-2.d
Normal file
@ -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
|
19
gas/testsuite/gas/i386/x86-64-size-3.d
Normal file
19
gas/testsuite/gas/i386/x86-64-size-3.d
Normal file
@ -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
|
18
gas/testsuite/gas/i386/x86-64-size-4.d
Normal file
18
gas/testsuite/gas/i386/x86-64-size-4.d
Normal file
@ -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
|
16
gas/testsuite/gas/i386/x86-64-size-5.d
Normal file
16
gas/testsuite/gas/i386/x86-64-size-5.d
Normal file
@ -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
|
21
gas/testsuite/gas/i386/x86-64-size-5.s
Normal file
21
gas/testsuite/gas/i386/x86-64-size-5.s
Normal file
@ -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
|
25
gas/testsuite/gas/i386/x86-64-size-inval-1.l
Normal file
25
gas/testsuite/gas/i386/x86-64-size-inval-1.l
Normal file
@ -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
|
11
gas/testsuite/gas/i386/x86-64-size-inval-1.s
Normal file
11
gas/testsuite/gas/i386/x86-64-size-inval-1.s
Normal file
@ -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
|
@ -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.
|
||||
|
12
ld/testsuite/ld-size/size-3.c
Normal file
12
ld/testsuite/ld-size/size-3.c
Normal file
@ -0,0 +1,12 @@
|
||||
#include <stdio.h>
|
||||
|
||||
extern int bar_size;
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
if (bar_size == 10)
|
||||
printf ("OK\n");
|
||||
|
||||
return 0;
|
||||
}
|
1
ld/testsuite/ld-size/size-3.out
Normal file
1
ld/testsuite/ld-size/size-3.out
Normal file
@ -0,0 +1 @@
|
||||
OK
|
3
ld/testsuite/ld-size/size-3a.c
Normal file
3
ld/testsuite/ld-size/size-3a.c
Normal file
@ -0,0 +1,3 @@
|
||||
char bar[10] __attribute__ ((visibility("hidden")));
|
||||
extern char size_of_bar asm ("bar@SIZE");
|
||||
char *bar_size = &size_of_bar;
|
4
ld/testsuite/ld-size/size-3b.c
Normal file
4
ld/testsuite/ld-size/size-3b.c
Normal file
@ -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;
|
3
ld/testsuite/ld-size/size-3c.c
Normal file
3
ld/testsuite/ld-size/size-3c.c
Normal file
@ -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;
|
2
ld/testsuite/ld-size/size-4.out
Normal file
2
ld/testsuite/ld-size/size-4.out
Normal file
@ -0,0 +1,2 @@
|
||||
OK
|
||||
OK
|
24
ld/testsuite/ld-size/size-4a.c
Normal file
24
ld/testsuite/ld-size/size-4a.c
Normal file
@ -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;
|
||||
}
|
35
ld/testsuite/ld-size/size-4b.c
Normal file
35
ld/testsuite/ld-size/size-4b.c
Normal file
@ -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;
|
||||
}
|
2
ld/testsuite/ld-size/size-5.out
Normal file
2
ld/testsuite/ld-size/size-5.out
Normal file
@ -0,0 +1,2 @@
|
||||
OK
|
||||
OK
|
24
ld/testsuite/ld-size/size-5a.c
Normal file
24
ld/testsuite/ld-size/size-5a.c
Normal file
@ -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;
|
||||
}
|
37
ld/testsuite/ld-size/size-5b.c
Normal file
37
ld/testsuite/ld-size/size-5b.c
Normal file
@ -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;
|
||||
}
|
1
ld/testsuite/ld-size/size-6.out
Normal file
1
ld/testsuite/ld-size/size-6.out
Normal file
@ -0,0 +1 @@
|
||||
OK
|
15
ld/testsuite/ld-size/size-6a.c
Normal file
15
ld/testsuite/ld-size/size-6a.c
Normal file
@ -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;
|
||||
}
|
7
ld/testsuite/ld-size/size-6b.c
Normal file
7
ld/testsuite/ld-size/size-6b.c
Normal file
@ -0,0 +1,7 @@
|
||||
char bar[10];
|
||||
|
||||
void
|
||||
set_bar (int i, int v)
|
||||
{
|
||||
bar[i] = v;
|
||||
}
|
3
ld/testsuite/ld-size/size-7.rd
Normal file
3
ld/testsuite/ld-size/size-7.rd
Normal file
@ -0,0 +1,3 @@
|
||||
#...
|
||||
[0-9a-f]+ +[0-9a-f]+ +R_.*_SIZE(32|64) +.*
|
||||
#pass
|
12
ld/testsuite/ld-size/size-7a.c
Normal file
12
ld/testsuite/ld-size/size-7a.c
Normal file
@ -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;
|
||||
}
|
1
ld/testsuite/ld-size/size-7b.c
Normal file
1
ld/testsuite/ld-size/size-7b.c
Normal file
@ -0,0 +1 @@
|
||||
char bar[10];
|
3
ld/testsuite/ld-size/size-8.rd
Normal file
3
ld/testsuite/ld-size/size-8.rd
Normal file
@ -0,0 +1,3 @@
|
||||
#...
|
||||
[0-9a-f]+ +[0-9a-f]+ +R_.*_SIZE(32|64) +.*
|
||||
#pass
|
15
ld/testsuite/ld-size/size-8a.c
Normal file
15
ld/testsuite/ld-size/size-8a.c
Normal file
@ -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;
|
||||
}
|
7
ld/testsuite/ld-size/size-8b.c
Normal file
7
ld/testsuite/ld-size/size-8b.c
Normal file
@ -0,0 +1,7 @@
|
||||
__thread char bar[10];
|
||||
|
||||
void
|
||||
set_bar (int i, int v)
|
||||
{
|
||||
bar[i] = v;
|
||||
}
|
122
ld/testsuite/ld-size/size.exp
Normal file
122
ld/testsuite/ld-size/size.exp
Normal file
@ -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
|
22
ld/testsuite/ld-size/size32-1-i386.d
Normal file
22
ld/testsuite/ld-size/size32-1-i386.d
Normal file
@ -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 ............
|
22
ld/testsuite/ld-size/size32-1-x32.d
Normal file
22
ld/testsuite/ld-size/size32-1-x32.d
Normal file
@ -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 ............
|
22
ld/testsuite/ld-size/size32-1-x86-64.d
Normal file
22
ld/testsuite/ld-size/size32-1-x86-64.d
Normal file
@ -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 ............
|
14
ld/testsuite/ld-size/size32-1.s
Normal file
14
ld/testsuite/ld-size/size32-1.s
Normal file
@ -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
|
20
ld/testsuite/ld-size/size32-2-i386.d
Normal file
20
ld/testsuite/ld-size/size32-2-i386.d
Normal file
@ -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 ....
|
20
ld/testsuite/ld-size/size32-2-x32.d
Normal file
20
ld/testsuite/ld-size/size32-2-x32.d
Normal file
@ -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 ....
|
20
ld/testsuite/ld-size/size32-2-x86-64.d
Normal file
20
ld/testsuite/ld-size/size32-2-x86-64.d
Normal file
@ -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 ....
|
22
ld/testsuite/ld-size/size32-2.s
Normal file
22
ld/testsuite/ld-size/size32-2.s
Normal file
@ -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
|
23
ld/testsuite/ld-size/size64-1-x32.d
Normal file
23
ld/testsuite/ld-size/size64-1-x32.d
Normal file
@ -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 ................
|
23
ld/testsuite/ld-size/size64-1-x86-64.d
Normal file
23
ld/testsuite/ld-size/size64-1-x86-64.d
Normal file
@ -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 ................
|
14
ld/testsuite/ld-size/size64-1.s
Normal file
14
ld/testsuite/ld-size/size64-1.s
Normal file
@ -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
|
21
ld/testsuite/ld-size/size64-2-x32.d
Normal file
21
ld/testsuite/ld-size/size64-2-x32.d
Normal file
@ -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 ........
|
21
ld/testsuite/ld-size/size64-2-x86-64.d
Normal file
21
ld/testsuite/ld-size/size64-2-x86-64.d
Normal file
@ -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 ........
|
22
ld/testsuite/ld-size/size64-2.s
Normal file
22
ld/testsuite/ld-size/size64-2.s
Normal file
@ -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
|
Loading…
x
Reference in New Issue
Block a user