* PATCH: Warn relocation in readonly section in a shared object
@ 2011-04-23 1:17 H.J. Lu
2011-06-01 19:46 ` H.J. Lu
0 siblings, 1 reply; 2+ messages in thread
From: H.J. Lu @ 2011-04-23 1:17 UTC (permalink / raw)
To: binutils
Hi,
I checked in this patch to warn relocation in readonly section in a
shared object.
H.J.
---
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 4d98456..cc10c52 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,11 @@
+2011-04-22 H.J. Lu <hongjiu.lu@intel.com>
+
+ * elf32-i386.c (elf_i386_readonly_dynrelocs): Warn relocation
+ in readonly section in a shared object.
+ (elf_i386_size_dynamic_sections): Likewise.
+ * elf64-x86-64.c (elf_x86_64_readonly_dynrelocs): Likewise.
+ (elf_x86_64_size_dynamic_sections): Likewise.
+
2011-04-21 H.J. Lu <hongjiu.lu@intel.com>
PR ld/12694
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index bb79f89..e32ec83 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -2399,6 +2399,11 @@ elf_i386_readonly_dynrelocs (struct elf_link_hash_entry *h, void *inf)
info->flags |= DF_TEXTREL;
+ if (info->warn_shared_textrel && info->shared)
+ info->callbacks->einfo (_("%P: %B: warning: relocation against `%s' in readonly section `%A'.\n"),
+ p->sec->owner, h->root.root.string,
+ p->sec);
+
/* Not an error, just cut short the traversal. */
return FALSE;
}
@@ -2482,7 +2487,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)
- info->flags |= DF_TEXTREL;
+ {
+ 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 8d00edd..a02b3e8 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -2314,6 +2314,11 @@ elf_x86_64_readonly_dynrelocs (struct elf_link_hash_entry *h,
info->flags |= DF_TEXTREL;
+ if (info->warn_shared_textrel && info->shared)
+ info->callbacks->einfo (_("%P: %B: warning: relocation against `%s' in readonly section `%A'.\n"),
+ p->sec->owner, h->root.root.string,
+ p->sec);
+
/* Not an error, just cut short the traversal. */
return FALSE;
}
@@ -2393,7 +2398,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)
- info->flags |= DF_TEXTREL;
+ {
+ 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;
+ }
}
}
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: PATCH: Warn relocation in readonly section in a shared object
2011-04-23 1:17 PATCH: Warn relocation in readonly section in a shared object H.J. Lu
@ 2011-06-01 19:46 ` H.J. Lu
0 siblings, 0 replies; 2+ messages in thread
From: H.J. Lu @ 2011-06-01 19:46 UTC (permalink / raw)
To: binutils
On Fri, Apr 22, 2011 at 06:17:18PM -0700, H.J. Lu wrote:
> Hi,
>
> I checked in this patch to warn relocation in readonly section in a
> shared object.
>
> H.J.
> ---
> diff --git a/bfd/ChangeLog b/bfd/ChangeLog
> index 4d98456..cc10c52 100644
> --- a/bfd/ChangeLog
> +++ b/bfd/ChangeLog
> @@ -1,3 +1,11 @@
> +2011-04-22 H.J. Lu <hongjiu.lu@intel.com>
> +
> + * elf32-i386.c (elf_i386_readonly_dynrelocs): Warn relocation
> + in readonly section in a shared object.
> + (elf_i386_size_dynamic_sections): Likewise.
> + * elf64-x86-64.c (elf_x86_64_readonly_dynrelocs): Likewise.
> + (elf_x86_64_size_dynamic_sections): Likewise.
> +
> 2011-04-21 H.J. Lu <hongjiu.lu@intel.com>
>
> PR ld/12694
> diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
> index bb79f89..e32ec83 100644
> --- a/bfd/elf32-i386.c
> +++ b/bfd/elf32-i386.c
> @@ -2399,6 +2399,11 @@ elf_i386_readonly_dynrelocs (struct elf_link_hash_entry *h, void *inf)
>
> info->flags |= DF_TEXTREL;
>
> + if (info->warn_shared_textrel && info->shared)
> + info->callbacks->einfo (_("%P: %B: warning: relocation against `%s' in readonly section `%A'.\n"),
> + p->sec->owner, h->root.root.string,
> + p->sec);
> +
> /* Not an error, just cut short the traversal. */
> return FALSE;
> }
> @@ -2482,7 +2487,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)
> - info->flags |= DF_TEXTREL;
> + {
> + 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 8d00edd..a02b3e8 100644
> --- a/bfd/elf64-x86-64.c
> +++ b/bfd/elf64-x86-64.c
> @@ -2314,6 +2314,11 @@ elf_x86_64_readonly_dynrelocs (struct elf_link_hash_entry *h,
>
> info->flags |= DF_TEXTREL;
>
> + if (info->warn_shared_textrel && info->shared)
> + info->callbacks->einfo (_("%P: %B: warning: relocation against `%s' in readonly section `%A'.\n"),
> + p->sec->owner, h->root.root.string,
> + p->sec);
> +
> /* Not an error, just cut short the traversal. */
> return FALSE;
> }
> @@ -2393,7 +2398,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)
> - info->flags |= DF_TEXTREL;
> + {
> + 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;
> + }
> }
> }
> }
Hi,
This is a bug in this patch. I added a "break", which shouldn't be
there. I checcked in this patch to fix it. It will only issue
one warning of relocation in readonly section in a shared object.
H.J.
---
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 2591ab8..a3ca64b 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2011-06-01 H.J. Lu <hongjiu.lu@intel.com>
+
+ * 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 <nickc@redhat.com>
* archive.c (adjust_relative_path): Fix comment to prevent it
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index ee1511f..eea2263 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 5cbaff8..9d6d4a4 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;
}
}
}
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-06-01 19:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-23 1:17 PATCH: Warn relocation in readonly section in a shared object H.J. Lu
2011-06-01 19:46 ` H.J. Lu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).