aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2017-11-02 08:05:03 +1030
committerAlan Modra <amodra@gmail.com>2017-11-05 09:37:33 +1030
commit98bbb1b86180324b278842d8d73c79cb5d76d349 (patch)
tree432703f6d0d970b0fc2ceb69009d71a50f281bc6
parent2e684e75ae3939f5f14fb89ca8a300b610d093dd (diff)
downloadgdb-98bbb1b86180324b278842d8d73c79cb5d76d349.zip
gdb-98bbb1b86180324b278842d8d73c79cb5d76d349.tar.gz
gdb-98bbb1b86180324b278842d8d73c79cb5d76d349.tar.bz2
PowerPC readonly_dynrelocs
PowerPC64 lacked the mapfile textrel warning on finding dynamic relocs in read-only sections. This patch adds it, and tidies the readonly_dynrelocs interface. PowerPC doesn't need a SEC_ALLOC test because !SEC_ALLOC sections are excluded by check_relocs so will never have dyn_relocs. * elf32-ppc.c (readonly_dynrelocs): Delete info param. Update all callers. Don't bother with SEC_ALLOC test. Return section pointer. Move minfo call to.. (maybe_set_textrel): ..here. * elf64-ppc.c (readonly_dynrelocs): Return section pointer. (maybe_set_textrel): Call minfo to print textrel warning to map file.
-rw-r--r--bfd/ChangeLog9
-rw-r--r--bfd/elf32-ppc.c36
-rw-r--r--bfd/elf64-ppc.c23
3 files changed, 40 insertions, 28 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 6401301..37267e2 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,14 @@
2017-11-04 Alan Modra <amodra@gmail.com>
+ * elf32-ppc.c (readonly_dynrelocs): Delete info param. Update all
+ callers. Don't bother with SEC_ALLOC test. Return section pointer.
+ Move minfo call to..
+ (maybe_set_textrel): ..here.
+ * elf64-ppc.c (readonly_dynrelocs): Return section pointer.
+ (maybe_set_textrel): Call minfo to print textrel warning to map file.
+
+2017-11-04 Alan Modra <amodra@gmail.com>
+
* elf32-hppa.c (enum _tls_type): Move.
(struct elf32_hppa_link_hash_entry): Make tls_type a bitfield.
(elf32_hppa_check_relocs): Set DF_STATIC_TLS only for shared libraries.
diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c
index bd62c42..d98cbcf 100644
--- a/bfd/elf32-ppc.c
+++ b/bfd/elf32-ppc.c
@@ -5424,11 +5424,10 @@ ppc_elf_tls_optimize (bfd *obfd ATTRIBUTE_UNUSED,
return TRUE;
}
-/* Return true if we have dynamic relocs that apply to read-only sections. */
+/* Find dynamic relocs for H that apply to read-only sections. */
-static bfd_boolean
-readonly_dynrelocs (struct elf_link_hash_entry *h,
- struct bfd_link_info *info)
+static asection *
+readonly_dynrelocs (struct elf_link_hash_entry *h)
{
struct elf_dyn_relocs *p;
@@ -5436,18 +5435,10 @@ readonly_dynrelocs (struct elf_link_hash_entry *h,
{
asection *s = p->sec->output_section;
- if (s != NULL
- && ((s->flags & (SEC_READONLY | SEC_ALLOC))
- == (SEC_READONLY | SEC_ALLOC)))
- {
- if (info)
- info->callbacks->minfo (_("%B: dynamic relocation in read-only section `%A'\n"),
- p->sec->owner, p->sec);
-
- return TRUE;
- }
+ if (s != NULL && (s->flags & SEC_READONLY) != 0)
+ return p->sec;
}
- return FALSE;
+ return NULL;
}
/* Adjust a symbol defined by a dynamic object and referenced by a
@@ -5535,7 +5526,7 @@ ppc_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
&& !UNDEFWEAK_NO_DYNAMIC_RELOC (info, h)))
&& !htab->is_vxworks
&& !ppc_elf_hash_entry (h)->has_sda_refs
- && !readonly_dynrelocs (h, NULL))
+ && !readonly_dynrelocs (h))
{
h->pointer_equality_needed = 0;
/* Say that we do want dynamic relocs. */
@@ -5621,7 +5612,7 @@ ppc_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
&& !ppc_elf_hash_entry (h)->has_sda_refs
&& !htab->is_vxworks
&& !h->def_regular
- && !readonly_dynrelocs (h, NULL))
+ && !readonly_dynrelocs (h))
{
h->non_got_ref = 0;
return TRUE;
@@ -6112,15 +6103,20 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
static bfd_boolean
maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p)
{
- struct bfd_link_info *info;
+ asection *sec;
if (h->root.type == bfd_link_hash_indirect)
return TRUE;
- info = (struct bfd_link_info *) info_p;
- if (readonly_dynrelocs (h, info))
+ sec = readonly_dynrelocs (h);
+ if (sec != NULL)
{
+ struct bfd_link_info *info = (struct bfd_link_info *) info_p;
+
info->flags |= DF_TEXTREL;
+ info->callbacks->minfo
+ (_("%B: dynamic relocation in read-only section `%A'\n"),
+ sec->owner, sec);
/* Not an error, just cut short the traversal. */
return FALSE;
diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c
index 5cf862b..bd42af0 100644
--- a/bfd/elf64-ppc.c
+++ b/bfd/elf64-ppc.c
@@ -7084,10 +7084,9 @@ ppc64_elf_func_desc_adjust (bfd *obfd ATTRIBUTE_UNUSED,
return TRUE;
}
-/* Return true if we have dynamic relocs against H that apply to
- read-only sections. */
+/* Find dynamic relocs for H that apply to read-only sections. */
-static bfd_boolean
+static asection *
readonly_dynrelocs (struct elf_link_hash_entry *h)
{
struct ppc_link_hash_entry *eh;
@@ -7099,9 +7098,9 @@ readonly_dynrelocs (struct elf_link_hash_entry *h)
asection *s = p->sec->output_section;
if (s != NULL && (s->flags & SEC_READONLY) != 0)
- return TRUE;
+ return p->sec;
}
- return FALSE;
+ return NULL;
}
/* Return true if we have dynamic relocs against H or any of its weak
@@ -9934,14 +9933,22 @@ size_global_entry_stubs (struct elf_link_hash_entry *h, void *inf)
read-only sections. */
static bfd_boolean
-maybe_set_textrel (struct elf_link_hash_entry *h, void *info)
+maybe_set_textrel (struct elf_link_hash_entry *h, void *inf)
{
+ asection *sec;
+
if (h->root.type == bfd_link_hash_indirect)
return TRUE;
- if (readonly_dynrelocs (h))
+ sec = readonly_dynrelocs (h);
+ if (sec != NULL)
{
- ((struct bfd_link_info *) info)->flags |= DF_TEXTREL;
+ struct bfd_link_info *info = (struct bfd_link_info *) inf;
+
+ info->flags |= DF_TEXTREL;
+ info->callbacks->minfo
+ (_("%B: dynamic relocation in read-only section `%A'\n"),
+ sec->owner, sec);
/* Not an error, just cut short the traversal. */
return FALSE;