From 63897e2cf09f3f6a7df0a3c95820f73f6d4d4535 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Thu, 7 Aug 2008 19:50:05 +0000 Subject: [PATCH] bfd/ * elfxx-mips.c (allocate_dynrelocs): Ignore indirect and warning symbols. ld/testsuite/ * ld-mips-elf/reloc-estimate-1.d, ld-mips-elf/reloc-estimate-1.ld, ld-mips-elf/reloc-estimate-1a.s, ld-mips-elf/reloc-estimate-1b.s: New test. * ld-mips-elf/mips-elf.exp: Run it. --- bfd/ChangeLog | 5 ++++ bfd/elfxx-mips.c | 6 ++++ ld/testsuite/ChangeLog | 7 +++++ ld/testsuite/ld-mips-elf/mips-elf.exp | 1 + ld/testsuite/ld-mips-elf/reloc-estimate-1.d | 18 ++++++++++++ ld/testsuite/ld-mips-elf/reloc-estimate-1.ld | 29 ++++++++++++++++++++ ld/testsuite/ld-mips-elf/reloc-estimate-1a.s | 6 ++++ ld/testsuite/ld-mips-elf/reloc-estimate-1b.s | 7 +++++ 8 files changed, 79 insertions(+) create mode 100644 ld/testsuite/ld-mips-elf/reloc-estimate-1.d create mode 100644 ld/testsuite/ld-mips-elf/reloc-estimate-1.ld create mode 100644 ld/testsuite/ld-mips-elf/reloc-estimate-1a.s create mode 100644 ld/testsuite/ld-mips-elf/reloc-estimate-1b.s diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 93a132f6614..40a50853d49 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,8 @@ +2008-08-07 Richard Sandiford + + * elfxx-mips.c (allocate_dynrelocs): Ignore indirect and warning + symbols. + 2008-08-06 Richard Sandiford * elfxx-mips.c (mips_elf_link_hash_entry): Move bfd_boolean diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c index 24a36062de9..f3536fdd6ed 100644 --- a/bfd/elfxx-mips.c +++ b/bfd/elfxx-mips.c @@ -7460,6 +7460,12 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) if (htab->is_vxworks && !info->shared) return TRUE; + /* Ignore indirect and warning symbols. All relocations against + such symbols will be redirected to the target symbol. */ + if (h->root.type == bfd_link_hash_indirect + || h->root.type == bfd_link_hash_warning) + return TRUE; + /* If this symbol is defined in a dynamic object, or we are creating a shared library, we will need to copy any R_MIPS_32 or R_MIPS_REL32 relocs against it into the output file. */ diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index 2b50e53b5f6..7a90aadca02 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2008-08-07 Richard Sandiford + + * ld-mips-elf/reloc-estimate-1.d, ld-mips-elf/reloc-estimate-1.ld, + ld-mips-elf/reloc-estimate-1a.s, ld-mips-elf/reloc-estimate-1b.s: + New test. + * ld-mips-elf/mips-elf.exp: Run it. + 2008-08-06 Richard Sandiford * ld-mips-elf/tls-hidden3.ld: Remove the unused .MIPS.stubs section. diff --git a/ld/testsuite/ld-mips-elf/mips-elf.exp b/ld/testsuite/ld-mips-elf/mips-elf.exp index 29cd3bb8775..b4da7489e13 100644 --- a/ld/testsuite/ld-mips-elf/mips-elf.exp +++ b/ld/testsuite/ld-mips-elf/mips-elf.exp @@ -194,6 +194,7 @@ if { $linux_gnu } { if $has_newabi { run_dump_test "got-dump-2" } + run_dump_test "reloc-estimate-1" } if $has_newabi { diff --git a/ld/testsuite/ld-mips-elf/reloc-estimate-1.d b/ld/testsuite/ld-mips-elf/reloc-estimate-1.d new file mode 100644 index 00000000000..94dde8150c7 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/reloc-estimate-1.d @@ -0,0 +1,18 @@ +#name: MIPS reloc estimation 1 +#source: reloc-estimate-1a.s +#source: reloc-estimate-1b.s +#ld: -shared -T reloc-estimate-1.ld +#objdump: -R -sj.foo + +.* + +DYNAMIC RELOCATION RECORDS +OFFSET TYPE VALUE +00000000 R_MIPS_NONE \*ABS\* +00010000 R_MIPS_REL32 foo + + +# The address must be 0x810. We should only ever allocate one dynamic +# reloc over and above the first R_MIPS_NONE entry. +Contents of section \.foo: + 0810 deadbeef .... diff --git a/ld/testsuite/ld-mips-elf/reloc-estimate-1.ld b/ld/testsuite/ld-mips-elf/reloc-estimate-1.ld new file mode 100644 index 00000000000..776e503fec7 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/reloc-estimate-1.ld @@ -0,0 +1,29 @@ +SECTIONS +{ + . = 0; + .reginfo : { *(.reginfo) } + + . = ALIGN (0x400); + .dynamic : { *(.dynamic) } + .dynsym : { *(.dynsym) } + .dynstr : { *(.dynstr) } + + . = ALIGN (0x400); + .rel.dyn : { *(.rel.dyn) } + .foo : { *(.foo) } + .text : { *(.text) } + + . = ALIGN (0x400); + .MIPS.stubs : { *(.MIPS.stubs) } + + . = ALIGN (0x10000); + .data : { *(.data) } + + . = ALIGN (0x400); + _gp = . + 0x7ff0; + .got : { *(.got) } +} + +VERSION { + V2 { global: foo; local: *; }; +} diff --git a/ld/testsuite/ld-mips-elf/reloc-estimate-1a.s b/ld/testsuite/ld-mips-elf/reloc-estimate-1a.s new file mode 100644 index 00000000000..564c62acba1 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/reloc-estimate-1a.s @@ -0,0 +1,6 @@ + .section .foo,"a",@progbits + .word 0xdeadbeef + + .abicalls + .data + .word foo diff --git a/ld/testsuite/ld-mips-elf/reloc-estimate-1b.s b/ld/testsuite/ld-mips-elf/reloc-estimate-1b.s new file mode 100644 index 00000000000..dd308b43715 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/reloc-estimate-1b.s @@ -0,0 +1,7 @@ + .abicalls + .symver foo2,foo@@V2 + .global foo2 + .data + .type foo2,%object + .size foo2,4 +foo2: .word 0 -- 2.30.2