This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: readonly_dynrelocs


On Thu, Nov 30, 2017 at 10:52 PM, Alan Modra <amodra@gmail.com> wrote:
> 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.  (I can add the x86 support if you like HJ?)

x86 has

          if ((info->warn_shared_textrel && bfd_link_pic (info))
              || info->error_textrel)
            /* xgettext:c-format */
            info->callbacks->einfo (_("%P: %B: warning: relocation
against `%s' in readonly section `%A'\n"),
                                    p->sec->owner, h->root.root.string,
                                    p->sec);

It warns about relocation in read-only section when --warn-shared-textrel
is used.  I checked in this patch to fix it 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.


-- 
H.J.
From b9d48996ca3434f943ba2cccefd30e7147378950 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Fri, 1 Dec 2017 04:01:11 -0800
Subject: [PATCH] x86: Print dynreloc in readonly section for map file output

This fixed:

FAIL: DT_TEXTREL map file warning

on Linux/x86.

	* elfxx-x86.c (_bfd_x86_elf_readonly_dynrelocs): Print dynamic
	relocation in readonly section for map file output.
---
 bfd/ChangeLog   | 5 +++++
 bfd/elfxx-x86.c | 5 +++++
 2 files changed, 10 insertions(+)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index ae28970667..95fb5cdf2b 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,8 @@
+2017-12-01  H.J. Lu  <hongjiu.lu@intel.com>
+
+	* elfxx-x86.c (_bfd_x86_elf_readonly_dynrelocs): Print symbol
+	for map file output.
+
 2017-12-01  Alan Modra  <amodra@gmail.com>
 
 	* elf32-hppa.c (maybe_set_textrel): Print symbol for map file output.
diff --git a/bfd/elfxx-x86.c b/bfd/elfxx-x86.c
index ecb8b9dd10..3899c137dc 100644
--- a/bfd/elfxx-x86.c
+++ b/bfd/elfxx-x86.c
@@ -551,6 +551,11 @@ _bfd_x86_elf_readonly_dynrelocs (struct elf_link_hash_entry *h,
 	    info->callbacks->einfo (_("%P: %B: warning: relocation against `%s' in readonly section `%A'\n"),
 				    p->sec->owner, h->root.root.string,
 				    p->sec);
+	  else
+	    /* xgettext:c-format */
+	    info->callbacks->minfo
+	      (_("%B: dynamic relocation against `%T' in read-only section `%A'\n"),
+	       p->sec->owner, h->root.root.string, p->sec);
 
 	  /* Not an error, just cut short the traversal.  */
 	  return FALSE;
-- 
2.14.3


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]