diff options
author | Richard Sandiford <rdsandiford@googlemail.com> | 2013-02-13 14:08:58 +0000 |
---|---|---|
committer | Richard Sandiford <rdsandiford@googlemail.com> | 2013-02-13 14:08:58 +0000 |
commit | 13db6b44eaf75fce5624b518185d98f81a48e603 (patch) | |
tree | aff93f9b46f4f6ebbc51459271510e53bc3b9f46 /ld | |
parent | 1d3ffd6bfef1e9c7ceabba65a1d4cb0e7000c3aa (diff) | |
download | gdb-13db6b44eaf75fce5624b518185d98f81a48e603.zip gdb-13db6b44eaf75fce5624b518185d98f81a48e603.tar.gz gdb-13db6b44eaf75fce5624b518185d98f81a48e603.tar.bz2 |
bfd/
* elfxx-mips.c (mips_got_page_ref): New structure.
(mips_got_page_entry): Use a section rather than a (bfd, symndx)
pair to represent the anchor point.
(mips_got_info): Add a got_page_refs field.
(mips_elf_link_hash_table): Add a sym_cache field.
(mips_got_page_ref_hash, mips_got_page_ref_eq): New functions.
(mips_got_page_entry_hash, mips_got_page_entry_eq): Update for
new anchor representation.
(mips_elf_create_got_info): Create got_page_refs rather than
got_page_entries.
(mips_elf_record_got_page_ref): New function.
(mips_elf_pages_for_range): Move further down file.
(mips_elf_record_got_page_entry): Likewise. Take a got as argument.
Use a section rather than a (bfd, symndx) pair to represent the
anchor point.
(mips_elf_resolve_got_page_ref): New function.
(mips_elf_resolve_final_got_entries): Use it to populate
got_page_entries.
(_bfd_mips_elf_check_relocs): Call mips_elf_record_got_page_ref
rather than mips_elf_record_got_page_entry. Only nullify h
afterwards.
(mips_elf_lay_out_got): Call mips_elf_resolve_final_got_entries
earlier.
ld/testsuite/
* ld-mips-elf/mips16-pic-2.dd,
ld-mips-elf/mips16-pic-2.gd: Remove 3 unused local GOT entries.
* ld-mips-elf/got-page-4a.s, ld-mips-elf/got-page-4b.s,
ld-mips-elf/got-page-4a.d, ld-mips-elf/got-page-4a.got,
ld-mips-elf/got-page-4b.d, ld-mips-elf/got-page-4b.got,
ld-mips-elf/got-page-5.s, ld-mips-elf/got-page-5.d,
ld-mips-elf/got-page-5.got, ld-mips-elf/got-page-6.s,
ld-mips-elf/got-page-6.d, ld-mips-elf/got-page-6.got,
ld-mips-elf/got-page-7a.s, ld-mips-elf/got-page-7b.s,
ld-mips-elf/got-page-7c.s, ld-mips-elf/got-page-7d.s,
ld-mips-elf/got-page-7e.s, ld-mips-elf/got-page-7.d,
ld-mips-elf/got-page-7.got: New tests.
* ld-mips-elf/mips-elf.exp: Run them.
Diffstat (limited to 'ld')
23 files changed, 342 insertions, 9 deletions
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index 376b119..e1a7e4a 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,19 @@ +2013-02-13 Richard Sandiford <rdsandiford@googlemail.com> + + * ld-mips-elf/mips16-pic-2.dd, + ld-mips-elf/mips16-pic-2.gd: Remove 3 unused local GOT entries. + * ld-mips-elf/got-page-4a.s, ld-mips-elf/got-page-4b.s, + ld-mips-elf/got-page-4a.d, ld-mips-elf/got-page-4a.got, + ld-mips-elf/got-page-4b.d, ld-mips-elf/got-page-4b.got, + ld-mips-elf/got-page-5.s, ld-mips-elf/got-page-5.d, + ld-mips-elf/got-page-5.got, ld-mips-elf/got-page-6.s, + ld-mips-elf/got-page-6.d, ld-mips-elf/got-page-6.got, + ld-mips-elf/got-page-7a.s, ld-mips-elf/got-page-7b.s, + ld-mips-elf/got-page-7c.s, ld-mips-elf/got-page-7d.s, + ld-mips-elf/got-page-7e.s, ld-mips-elf/got-page-7.d, + ld-mips-elf/got-page-7.got: New tests. + * ld-mips-elf/mips-elf.exp: Run them. + 2013-02-11 Richard Sandiford <rdsandiford@googlemail.com> * ld-mips-elf/tlsdyn-o32-1.d, ld-mips-elf/tlsdyn-o32-1.got, diff --git a/ld/testsuite/ld-mips-elf/got-page-4a.d b/ld/testsuite/ld-mips-elf/got-page-4a.d new file mode 100644 index 0000000..0ff341e --- /dev/null +++ b/ld/testsuite/ld-mips-elf/got-page-4a.d @@ -0,0 +1,35 @@ +#... +.* <foo>: +.* lw a0,-32744\(gp\) +.* addiu a0,a0,0 +.* lw a0,-32744\(gp\) +.* addiu a0,a0,4 +.* lw a0,-32744\(gp\) +.* addiu a0,a0,8 +.* lw a0,-32744\(gp\) +.* addiu a0,a0,12 +.* lw a0,-32744\(gp\) +.* addiu a0,a0,16 +.* lw a0,-32744\(gp\) +.* addiu a0,a0,20 +.* lw a0,-32744\(gp\) +.* addiu a0,a0,24 +.* lw a0,-32744\(gp\) +.* addiu a0,a0,28 +.* lw a0,-32744\(gp\) +.* addiu a0,a0,32 +.* lw a0,-32744\(gp\) +.* addiu a0,a0,36 +.* lw a0,-32744\(gp\) +.* addiu a0,a0,40 +.* lw a0,-32744\(gp\) +.* addiu a0,a0,44 +.* lw a0,-32744\(gp\) +.* addiu a0,a0,48 +.* lw a0,-32744\(gp\) +.* addiu a0,a0,52 +.* lw a0,-32744\(gp\) +.* addiu a0,a0,56 +.* lw a0,-32744\(gp\) +.* addiu a0,a0,60 +#pass diff --git a/ld/testsuite/ld-mips-elf/got-page-4a.got b/ld/testsuite/ld-mips-elf/got-page-4a.got new file mode 100644 index 0000000..9b1308e --- /dev/null +++ b/ld/testsuite/ld-mips-elf/got-page-4a.got @@ -0,0 +1,7 @@ +#... + Local entries: + Address Access Initial + 00090008 -32744\(gp\) 00080000 + 0009000c -32740\(gp\) 00000000 + +#pass diff --git a/ld/testsuite/ld-mips-elf/got-page-4a.s b/ld/testsuite/ld-mips-elf/got-page-4a.s new file mode 100644 index 0000000..4c8163e --- /dev/null +++ b/ld/testsuite/ld-mips-elf/got-page-4a.s @@ -0,0 +1,14 @@ + .section .rodata.cst4,"aM",@progbits,4 + .set x,0x01000000 + .set y,0x02000000 + # Add the 16 values that the next input file wants, but in such + # a way that each one lives on a separate page. + .rept 15 + .word y + .set y,y+1 + .rept 0x4000 + .word x + .set x,x+1 + .endr + .endr + .word y diff --git a/ld/testsuite/ld-mips-elf/got-page-4b.d b/ld/testsuite/ld-mips-elf/got-page-4b.d new file mode 100644 index 0000000..2917c33 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/got-page-4b.d @@ -0,0 +1,36 @@ +#... +.* <foo>: +.* lw a0,-32744\(gp\) +.* addiu a0,a0,0 +.* lw a0,-32740\(gp\) +.* addiu a0,a0,4 +.* lw a0,-32736\(gp\) +.* addiu a0,a0,8 +.* lw a0,-32732\(gp\) +.* addiu a0,a0,12 +.* lw a0,-32728\(gp\) +.* addiu a0,a0,16 +.* lw a0,-32724\(gp\) +.* addiu a0,a0,20 +.* lw a0,-32720\(gp\) +.* addiu a0,a0,24 +.* lw a0,-32716\(gp\) +.* addiu a0,a0,28 +.* lw a0,-32712\(gp\) +.* addiu a0,a0,32 +.* lw a0,-32708\(gp\) +.* addiu a0,a0,36 +.* lw a0,-32704\(gp\) +.* addiu a0,a0,40 +.* lw a0,-32700\(gp\) +.* addiu a0,a0,44 +.* lw a0,-32696\(gp\) +.* addiu a0,a0,48 +.* lw a0,-32692\(gp\) +.* addiu a0,a0,52 +.* lw a0,-32688\(gp\) +.* addiu a0,a0,56 +.* lw a0,-32684\(gp\) +.* addiu a0,a0,60 + +#pass diff --git a/ld/testsuite/ld-mips-elf/got-page-4b.got b/ld/testsuite/ld-mips-elf/got-page-4b.got new file mode 100644 index 0000000..0e223b5 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/got-page-4b.got @@ -0,0 +1,21 @@ +#... + Local entries: + Address Access Initial + 00180008 -32744\(gp\) 00080000 + 0018000c -32740\(gp\) 00090000 + 00180010 -32736\(gp\) 000a0000 + 00180014 -32732\(gp\) 000b0000 + 00180018 -32728\(gp\) 000c0000 + 0018001c -32724\(gp\) 000d0000 + 00180020 -32720\(gp\) 000e0000 + 00180024 -32716\(gp\) 000f0000 + 00180028 -32712\(gp\) 00100000 + 0018002c -32708\(gp\) 00110000 + 00180030 -32704\(gp\) 00120000 + 00180034 -32700\(gp\) 00130000 + 00180038 -32696\(gp\) 00140000 + 0018003c -32692\(gp\) 00150000 + 00180040 -32688\(gp\) 00160000 + 00180044 -32684\(gp\) 00170000 + +#pass diff --git a/ld/testsuite/ld-mips-elf/got-page-4b.s b/ld/testsuite/ld-mips-elf/got-page-4b.s new file mode 100644 index 0000000..eab5277 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/got-page-4b.s @@ -0,0 +1,21 @@ + .globl foo + .ent foo +foo: + # Create page references to 16 values. The layout of the values + # in this input file requires at most 2 page entries. + .set y,0x02000000 + .rept 16 + lw $4,%got_page(1f)($gp) + addiu $4,$4,%got_ofst(1f) + .section .rodata.cst4,"aM",@progbits,4 +1: .word y + .set y,y+1 + .text + .endr + .end foo + + # Make sure the loadable size of the library is large. + .section .bss + .globl g +g: + .space 0x800000 diff --git a/ld/testsuite/ld-mips-elf/got-page-5.d b/ld/testsuite/ld-mips-elf/got-page-5.d new file mode 100644 index 0000000..5706d98 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/got-page-5.d @@ -0,0 +1,10 @@ +#... +.* <foo>: +.* lw a0,-32744\(gp\) +.* addiu a0,a0,0 +.* lw a0,-32740\(gp\) +.* addiu a0,a0,-32768 +.* lw a0,-32740\(gp\) +.* addiu a0,a0,0 +.* lw a0,-32736\(gp\) +.* addiu a0,a0,-32768 diff --git a/ld/testsuite/ld-mips-elf/got-page-5.got b/ld/testsuite/ld-mips-elf/got-page-5.got new file mode 100644 index 0000000..0a76be8 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/got-page-5.got @@ -0,0 +1,8 @@ +#... + Local entries: + Address Access Initial + 00090008 -32744\(gp\) 00080000 + 0009000c -32740\(gp\) 00090000 + 00090010 -32736\(gp\) 000a0000 + +#pass diff --git a/ld/testsuite/ld-mips-elf/got-page-5.s b/ld/testsuite/ld-mips-elf/got-page-5.s new file mode 100644 index 0000000..5051263 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/got-page-5.s @@ -0,0 +1,31 @@ + # Create a mergeable section full of a single value, + # and page references relative to one entry called "data". + # + # The mergeable entries collapse to one, but the offsets + # from "data" must still be retained, and need 3 page entries. + # + # Technically this isn't valid, because it creates out-of-section + # page references. It's still a useful way of making sure that + # offsets in mergeable sections are handled correctly. + .globl foo + .ent foo +foo: + .set y,0 + .rept 4 + lw $4,%got_page(data + y)($gp) + addiu $4,$4,%got_ofst(data + y) + .set y,y+0x8000 + .endr + .end foo + + .section .rodata.cst4,"aM",@progbits,4 +data: + .rept 0x8000*4 + .word 123456 + .endr + + # Make sure the loadable size of the library is large. + .section .bss + .globl g +g: + .space 0x800000 diff --git a/ld/testsuite/ld-mips-elf/got-page-6.d b/ld/testsuite/ld-mips-elf/got-page-6.d new file mode 100644 index 0000000..90d6638 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/got-page-6.d @@ -0,0 +1,10 @@ +#... +.* <foo>: +.* lw a0,-32744\(gp\) +.* addiu a0,a0,0 +.* lw a0,-32744\(gp\) +.* addiu a0,a0,0 +.* lw a0,-32744\(gp\) +.* addiu a0,a0,0 +.* lw a0,-32744\(gp\) +.* addiu a0,a0,0 diff --git a/ld/testsuite/ld-mips-elf/got-page-6.got b/ld/testsuite/ld-mips-elf/got-page-6.got new file mode 100644 index 0000000..e385e8c --- /dev/null +++ b/ld/testsuite/ld-mips-elf/got-page-6.got @@ -0,0 +1,6 @@ +#... + Local entries: + Address Access Initial + 00090008 -32744\(gp\) 00080000 + +#pass diff --git a/ld/testsuite/ld-mips-elf/got-page-6.s b/ld/testsuite/ld-mips-elf/got-page-6.s new file mode 100644 index 0000000..c419e00 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/got-page-6.s @@ -0,0 +1,27 @@ + # Create a mergeable section full of a single value. + # Create page references relative to instances of the value + # that are large distances apart. + # + # The mergeable entries collapse to one, so even with the + # large distances in the original file, we should end + # up with a single page entry. + .globl foo + .ent foo +foo: + .rept 4 + lw $4,%got_page(1f)($gp) + addiu $4,$4,%got_ofst(1f) + .section .rodata.cst4,"aM",@progbits,4 +1: + .rept 0x8000 + .word 123456 + .endr + .text + .endr + .end foo + + # Make sure the loadable size of the library is large. + .section .bss + .globl g +g: + .space 0x800000 diff --git a/ld/testsuite/ld-mips-elf/got-page-7.d b/ld/testsuite/ld-mips-elf/got-page-7.d new file mode 100644 index 0000000..12990b5 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/got-page-7.d @@ -0,0 +1,17 @@ +#... +.* <f1>: +.* lw a0,-32744\(gp\) +.* addiu a0,a0,1024 +#... +.* <f2>: +.* lw a0,-32744\(gp\) +.* addiu a0,a0,17408 +#... +.* <f3>: +.* lw a0,-32740\(gp\) +.* addiu a0,a0,-31744 +#... +.* <f4>: +.* lw a0,-32740\(gp\) +.* addiu a0,a0,1024 +#pass diff --git a/ld/testsuite/ld-mips-elf/got-page-7.got b/ld/testsuite/ld-mips-elf/got-page-7.got new file mode 100644 index 0000000..0b5df20 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/got-page-7.got @@ -0,0 +1,7 @@ +#... + Local entries: + Address Access Initial + 00090008 -32744\(gp\) 00090000 + 0009000c -32740\(gp\) 000a0000 + +#pass diff --git a/ld/testsuite/ld-mips-elf/got-page-7a.s b/ld/testsuite/ld-mips-elf/got-page-7a.s new file mode 100644 index 0000000..f03220b --- /dev/null +++ b/ld/testsuite/ld-mips-elf/got-page-7a.s @@ -0,0 +1,6 @@ + .globl f1 + .ent f1 +f1: + lw $4,%got_page(g)($gp) + addiu $4,$4,%got_ofst(g) + .end f1 diff --git a/ld/testsuite/ld-mips-elf/got-page-7b.s b/ld/testsuite/ld-mips-elf/got-page-7b.s new file mode 100644 index 0000000..4c9a0df --- /dev/null +++ b/ld/testsuite/ld-mips-elf/got-page-7b.s @@ -0,0 +1,6 @@ + .globl f2 + .ent f2 +f2: + lw $4,%got_page(g + 0x4000)($gp) + addiu $4,$4,%got_ofst(g + 0x4000) + .end f2 diff --git a/ld/testsuite/ld-mips-elf/got-page-7c.s b/ld/testsuite/ld-mips-elf/got-page-7c.s new file mode 100644 index 0000000..b957ecf --- /dev/null +++ b/ld/testsuite/ld-mips-elf/got-page-7c.s @@ -0,0 +1,6 @@ + .globl f3 + .ent f3 +f3: + lw $4,%got_page(g + 0x8000)($gp) + addiu $4,$4,%got_ofst(g + 0x8000) + .end f3 diff --git a/ld/testsuite/ld-mips-elf/got-page-7d.s b/ld/testsuite/ld-mips-elf/got-page-7d.s new file mode 100644 index 0000000..83ddb3a --- /dev/null +++ b/ld/testsuite/ld-mips-elf/got-page-7d.s @@ -0,0 +1,6 @@ + .globl f4 + .ent f4 +f4: + lw $4,%got_page(g + 0x10000)($gp) + addiu $4,$4,%got_ofst(g + 0x10000) + .end f4 diff --git a/ld/testsuite/ld-mips-elf/got-page-7e.s b/ld/testsuite/ld-mips-elf/got-page-7e.s new file mode 100644 index 0000000..c23382e --- /dev/null +++ b/ld/testsuite/ld-mips-elf/got-page-7e.s @@ -0,0 +1,6 @@ + # Make sure the loadable size of the library is large. + .section .bss + .globl g + .hidden g +g: + .space 0x800000 diff --git a/ld/testsuite/ld-mips-elf/mips-elf.exp b/ld/testsuite/ld-mips-elf/mips-elf.exp index 62c6cb0..9860488 100644 --- a/ld/testsuite/ld-mips-elf/mips-elf.exp +++ b/ld/testsuite/ld-mips-elf/mips-elf.exp @@ -453,6 +453,46 @@ if { $linux_gnu } { run_dump_test "dyn-sec64" } run_dump_test "got-page-3" + run_ld_link_tests [subst { + {"GOT page 4 (one file)" "-shared $abi_ldflags(o32) -T got-page-1.ld" + "$abi_asflags(o32) -mips2" {got-page-4b.s} + {{objdump -dr got-page-4a.d} + {readelf -A got-page-4a.got}} + "got-page-4a.so"} + {"GOT page 4 (two files)" "-shared $abi_ldflags(o32) -T got-page-1.ld" + "$abi_asflags(o32) -mips2" {got-page-4a.s got-page-4b.s} + {{objdump -dr got-page-4b.d} + {readelf -A got-page-4b.got}} + "got-page-4b.so"} + }] + if $has_newabi { + run_ld_link_tests [subst { + {"GOT page 5" "-shared $abi_ldflags(n32) -T got-page-1.ld" + "$abi_asflags(n32)" {got-page-5.s} + {{objdump -dr got-page-5.d} + {readelf -A got-page-5.got}} + "got-page-5.so"} + {"GOT page 6" "-shared $abi_ldflags(n32) -T got-page-1.ld" + "$abi_asflags(n32)" {got-page-6.s} + {{objdump -dr got-page-6.d} + {readelf -A got-page-6.got}} + "got-page-6.so"} + {"GOT page 7 (order 1)" "-shared $abi_ldflags(n32) -T got-page-1.ld" + "$abi_asflags(n32)" + {got-page-7a.s got-page-7b.s got-page-7c.s got-page-7d.s + got-page-7e.s} + {{objdump -dr got-page-7.d} + {readelf -A got-page-7.got}} + "got-page-7a.so"} + {"GOT page 7 (order 2)" "-shared $abi_ldflags(n32) -T got-page-1.ld" + "$abi_asflags(n32)" + {got-page-7e.s got-page-7a.s got-page-7b.s got-page-7c.s + got-page-7d.s} + {{objdump -dr got-page-7.d} + {readelf -A got-page-7.got}} + "got-page-7b.so"} + }] + } run_dump_test "got-dump-1" if $has_newabi { run_dump_test "got-dump-2" diff --git a/ld/testsuite/ld-mips-elf/mips16-pic-2.dd b/ld/testsuite/ld-mips-elf/mips16-pic-2.dd index 7052057..b2bdff2 100644 --- a/ld/testsuite/ld-mips-elf/mips16-pic-2.dd +++ b/ld/testsuite/ld-mips-elf/mips16-pic-2.dd @@ -77,7 +77,7 @@ Disassembly of section \.text: .*: [^\t]* move t9,v0 .*: [^\t]* lw v0,16\(sp\) .*: [^\t]* move gp,v0 -.*: [^\t]* lw v0,-32716\(v0\) +.*: [^\t]* lw v0,-32728\(v0\) .*: [^\t]* jalr v0 .*: [^\t]* move t9,v0 .*: [^\t]* lw v0,16\(sp\) @@ -101,7 +101,7 @@ Disassembly of section \.text: .*: [^\t]* move t9,v0 .*: [^\t]* lw v0,16\(sp\) .*: [^\t]* move gp,v0 -.*: [^\t]* lw v0,-32712\(v0\) +.*: [^\t]* lw v0,-32724\(v0\) .*: [^\t]* jalr v0 .*: [^\t]* move t9,v0 .*: [^\t]* lw v0,16\(sp\) diff --git a/ld/testsuite/ld-mips-elf/mips16-pic-2.gd b/ld/testsuite/ld-mips-elf/mips16-pic-2.gd index d8d1451..c291bc8 100644 --- a/ld/testsuite/ld-mips-elf/mips16-pic-2.gd +++ b/ld/testsuite/ld-mips-elf/mips16-pic-2.gd @@ -13,14 +13,11 @@ Primary GOT: 0005000c -32740\(gp\) 00040409 00050010 -32736\(gp\) 0004040d 00050014 -32732\(gp\) 00000000 - 00050018 -32728\(gp\) 00000000 - 0005001c -32724\(gp\) 00000000 - 00050020 -32720\(gp\) 00000000 Global entries: Address Access Initial Sym\.Val\. Type Ndx Name - 00050024 -32716\(gp\) 00040574 00040574 FUNC 6 used6 - 00050028 -32712\(gp\) 00040598 00040598 FUNC 6 used7 - 0005002c -32708\(gp\) 00040550 00040550 FUNC 6 used5 - 00050030 -32704\(gp\) 0004052c 0004052c FUNC 6 used4 + 00050018 -32728\(gp\) 00040574 00040574 FUNC 6 used6 + 0005001c -32724\(gp\) 00040598 00040598 FUNC 6 used7 + 00050020 -32720\(gp\) 00040550 00040550 FUNC 6 used5 + 00050024 -32716\(gp\) 0004052c 0004052c FUNC 6 used4 |