From 4b819e1f6e40e09d3d2b73b76afa007b842b3857 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Wed, 1 Jun 2011 19:42:01 +0000 Subject: [PATCH] Properly warn relocation in readonly section in a shared object. 2011-06-01 H.J. Lu * elf32-i386.c (elf_i386_size_dynamic_sections): Properly warn relocation in readonly section in a shared object. * elf64-x86-64.c (elf_x86_64_size_dynamic_sections): Likewise. --- bfd/ChangeLog | 6 ++++++ bfd/elf32-i386.c | 4 ++-- bfd/elf64-x86-64.c | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 2591ab87569..a3ca64b21d6 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2011-06-01 H.J. Lu + + * elf32-i386.c (elf_i386_size_dynamic_sections): Properly warn + relocation in readonly section in a shared object. + * elf64-x86-64.c (elf_x86_64_size_dynamic_sections): Likewise. + 2011-05-31 Nick Clifton * archive.c (adjust_relative_path): Fix comment to prevent it diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index ee1511f216b..eea22633a5e 100644 --- a/bfd/elf32-i386.c +++ b/bfd/elf32-i386.c @@ -2488,13 +2488,13 @@ elf_i386_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, { srel = elf_section_data (p->sec)->sreloc; srel->size += p->count * sizeof (Elf32_External_Rel); - if ((p->sec->output_section->flags & SEC_READONLY) != 0) + if ((p->sec->output_section->flags & SEC_READONLY) != 0 + && (info->flags & DF_TEXTREL) == 0) { info->flags |= DF_TEXTREL; if (info->warn_shared_textrel && info->shared) info->callbacks->einfo (_("%P: %B: warning: relocation in readonly section `%A'.\n"), p->sec->owner, p->sec); - break; } } } diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c index 5cbaff87047..9d6d4a401aa 100644 --- a/bfd/elf64-x86-64.c +++ b/bfd/elf64-x86-64.c @@ -2399,13 +2399,13 @@ elf_x86_64_size_dynamic_sections (bfd *output_bfd, { srel = elf_section_data (p->sec)->sreloc; srel->size += p->count * bed->s->sizeof_rela; - if ((p->sec->output_section->flags & SEC_READONLY) != 0) + if ((p->sec->output_section->flags & SEC_READONLY) != 0 + && (info->flags & DF_TEXTREL) == 0) { info->flags |= DF_TEXTREL; if (info->warn_shared_textrel && info->shared) info->callbacks->einfo (_("%P: %B: warning: relocation in readonly section `%A'.\n"), p->sec->owner, p->sec); - break; } } } -- 2.30.2