diff options
author | Alan Modra <amodra@gmail.com> | 2017-11-30 19:46:17 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2017-12-01 17:23:56 +1030 |
commit | 63c1f59d665542359de4737e3e48033c588f44dc (patch) | |
tree | 4a7cd6ca5ba13f6b413d608c5968f57eede6f0e8 /bfd/elfxx-tilegx.c | |
parent | 254cefe35f012977d567af0bbad2a8091d90e22b (diff) | |
download | gdb-63c1f59d665542359de4737e3e48033c588f44dc.zip gdb-63c1f59d665542359de4737e3e48033c588f44dc.tar.gz gdb-63c1f59d665542359de4737e3e48033c588f44dc.tar.bz2 |
readonly_dynrelocs
In early October, HJ Lu added support for a number of targets to "Dump
dynamic relocation in read-only section with minfo". This extends
that support to more targets, displays the symbol involved, and splits
the existing function that sets TEXTREL into a "readonly_dynrelocs"
and "maybe_set_textrel" function. I'll need "readonly_dynrelocs" if I
ever get around to fixing "pr22374 function pointer initialization"
fails.
am33_2.0, arc, bfin, hppa64, mn10300, and nios2 fail to mark a binary
needing text relocations with DT_TEXTREL. That's not good. xtensa also
fails to do so but complains about "dangerous relocation: dynamic
relocation in read-only section" so I reckon that is fine and have
marked the test as an xfail. The other targets need maintainer
attention.
Curiously, the map file dump wasn't added for x86, so the map test
currently fail on x86. It also fails on alpha, am33_2.0, arc, bfin,
hppa64, ia64, m68k, mips, mn10300, nios2, score and vax. cris
complains with "tmpdir/textrel.o, section .rodata: relocation
R_CRIS_32 should not be used in a shared object; recompile with -fPIC"
so I've marked it as an xfail.
bfd/
* elf32-hppa.c (maybe_set_textrel): Print symbol for map file output.
* elf32-ppc.c (maybe_set_textrel): Likewise.
* elf64-ppc.c (maybe_set_textrel): Likewise.
* elf32-arm.c (readonly_dynrelocs): New function.
(maybe_set_textrel): New function, replacing..
(elf32_arm_readonly_dynrelocs): ..this.
* elf32-lm32.c (readonly_dynrelocs): New function.
(maybe_set_textrel): New function, replacing old version of..
(readonly_dynrelocs): ..this.
* elf32-m32r.c (readonly_dynrelocs): New function.
(maybe_set_textrel): New function, replacing old version of..
(readonly_dynrelocs): ..this.
* elf32-metag.c (readonly_dynrelocs): New function.
(maybe_set_textrel): New function, replacing old version of..
(readonly_dynrelocs): ..this.
* elf32-nds32.c: Delete unnecessary forward declarations.
(readonly_dynrelocs): New function.
(maybe_set_textrel): New function, replacing old version of..
(readonly_dynrelocs): ..this.
* elf32-or1k.c (readonly_dynrelocs): New function.
(maybe_set_textrel): New function, replacing old version of..
(readonly_dynrelocs): ..this.
* elf32-s390.c (readonly_dynrelocs): New function.
(maybe_set_textrel): New function, replacing old version of..
(readonly_dynrelocs): ..this.
* elf32-sh.c (readonly_dynrelocs): New function.
(maybe_set_textrel): New function, replacing old version of..
(readonly_dynrelocs): ..this.
* elf32-tic6x.c (readonly_dynrelocs): New function.
(maybe_set_textrel): New function, replacing..
(elf32_tic6x_readonly_dynrelocs): ..this.
* elf32-tilepro.c (readonly_dynrelocs): New function.
(maybe_set_textrel): New function, replacing old version of..
(readonly_dynrelocs): ..this.
* elf64-s390.c (readonly_dynrelocs): New function.
(maybe_set_textrel): New function, replacing old version of..
(readonly_dynrelocs): ..this.
* elfnn-aarch64.c (readonly_dynrelocs): New function.
(maybe_set_textrel): New function, replacing..
(aarch64_readonly_readonly_dynrelocs): ..this.
* elfnn-riscv.c (readonly_dynrelocs): New function.
(maybe_set_textrel): New function, replacing old version of..
(readonly_dynrelocs): ..this.
* elfxx-sparc.c (readonly_dynrelocs): New function.
(maybe_set_textrel): New function, replacing old version of..
(readonly_dynrelocs): ..this.
* elfxx-tilegx.c (readonly_dynrelocs): New function.
(maybe_set_textrel): New function, replacing old version of..
(readonly_dynrelocs): ..this.
ld/
* testsuite/ld-elf/shared.exp: Run new textrel tests.
* testsuite/ld-elf/textrel.map: New file.
* testsuite/ld-elf/textrel.rd: New file.
* testsuite/ld-elf/textrel.s: New file.
* testsuite/ld-elf/textrel.warn: New file.
Diffstat (limited to 'bfd/elfxx-tilegx.c')
-rw-r--r-- | bfd/elfxx-tilegx.c | 53 |
1 files changed, 34 insertions, 19 deletions
diff --git a/bfd/elfxx-tilegx.c b/bfd/elfxx-tilegx.c index 5f6622a..19c5541 100644 --- a/bfd/elfxx-tilegx.c +++ b/bfd/elfxx-tilegx.c @@ -2128,6 +2128,23 @@ tilegx_elf_gc_mark_hook (asection *sec, return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym); } +/* Find dynamic relocs for H that apply to read-only sections. */ + +static asection * +readonly_dynrelocs (struct elf_link_hash_entry *h) +{ + struct tilegx_elf_dyn_relocs *p; + + for (p = tilegx_elf_hash_entry (h)->dyn_relocs; p != NULL; p = p->next) + { + asection *s = p->sec->output_section; + + if (s != NULL && (s->flags & SEC_READONLY) != 0) + return p->sec; + } + return NULL; +} + /* Adjust a symbol defined by a dynamic object and referenced by a regular object. The current definition is in some section of the dynamic object, but we're not including those sections. We have to @@ -2471,31 +2488,29 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) return TRUE; } -/* Find any dynamic relocs that apply to read-only sections. */ +/* Set DF_TEXTREL if we find any dynamic relocs that apply to + read-only sections. */ static bfd_boolean -readonly_dynrelocs (struct elf_link_hash_entry *h, void *inf) +maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p) { - struct tilegx_elf_link_hash_entry *eh; - struct tilegx_elf_dyn_relocs *p; - - eh = (struct tilegx_elf_link_hash_entry *) h; - for (p = eh->dyn_relocs; p != NULL; p = p->next) - { - asection *s = p->sec->output_section; + asection *sec; - if (s != NULL && (s->flags & SEC_READONLY) != 0) - { - struct bfd_link_info *info = (struct bfd_link_info *) inf; + if (h->root.type == bfd_link_hash_indirect) + return TRUE; - info->flags |= DF_TEXTREL; + sec = readonly_dynrelocs (h); + if (sec != NULL) + { + struct bfd_link_info *info = (struct bfd_link_info *) info_p; - info->callbacks->minfo (_("%B: dynamic relocation in read-only section `%A'\n"), - p->sec->owner, p->sec); + info->flags |= DF_TEXTREL; + info->callbacks->minfo + (_("%B: dynamic relocation against `%T' in read-only section `%A'\n"), + sec->owner, h->root.root.string, sec); - /* Not an error, just cut short the traversal. */ - return FALSE; - } + /* Not an error, just cut short the traversal. */ + return FALSE; } return TRUE; } @@ -2740,7 +2755,7 @@ tilegx_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, /* If any dynamic relocs apply to a read-only section, then we need a DT_TEXTREL entry. */ if ((info->flags & DF_TEXTREL) == 0) - elf_link_hash_traverse (&htab->elf, readonly_dynrelocs, info); + elf_link_hash_traverse (&htab->elf, maybe_set_textrel, info); if (info->flags & DF_TEXTREL) { |