public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: "Clément Chigot" <chigot@adacore.com>
To: binutils@sourceware.org
Cc: "Clément Chigot" <chigot@adacore.com>
Subject: [PATCH 3/3] ld: warn when duplicated QNX stack note are detected
Date: Fri, 13 Oct 2023 10:02:48 +0200	[thread overview]
Message-ID: <20231013080248.219837-3-chigot@adacore.com> (raw)
In-Reply-To: <20231013080248.219837-1-chigot@adacore.com>

This warning is triggered only when a stack parameter is given to
the linker.

ld/ChangeLog:

        * emultempl/nto.em: Add warning when several QNX .note are
        detected.
---
 ld/emultempl/nto.em | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/ld/emultempl/nto.em b/ld/emultempl/nto.em
index b1a61338412..f4c76f18fc2 100644
--- a/ld/emultempl/nto.em
+++ b/ld/emultempl/nto.em
@@ -86,6 +86,7 @@ nto_lookup_QNX_note_section(int type)
 {
   asection *stack_note_sec = NULL;
   bfd *abfd;
+  bool duplicated_notes_detected = false;
   for (abfd = link_info.input_bfds; abfd != NULL; abfd = abfd->link.next)
     {
       Elf_External_Note *e_note;
@@ -106,10 +107,23 @@ nto_lookup_QNX_note_section(int type)
       e_note = (Elf_External_Note *) sec->contents;
       if (! strcmp("QNX", e_note->name) && *e_note->type == type)
 	{
-	  stack_note_sec = sec;
-	  /* Allow modification of this .note content.  */
-	  stack_note_sec->flags |= SEC_IN_MEMORY;
-	  break;
+	  if (stack_note_sec)
+	    {
+	      if (!duplicated_notes_detected)
+		{
+		  einfo (_("%P: %pB: warning: duplicated QNX stack .note detected\n"),
+			 stack_note_sec->owner);
+		  duplicated_notes_detected = true;
+		}
+	      einfo (_("%P: %pB: warning: duplicated QNX stack .note detected\n"),
+		     sec->owner);
+	    }
+	  else
+	    {
+	      stack_note_sec = sec;
+	      /* Allow modification of this .note content.  */
+	      stack_note_sec->flags |= SEC_IN_MEMORY;
+	    }
 	}
     }
 
-- 
2.25.1


  parent reply	other threads:[~2023-10-13  8:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-13  8:02 [PATCH 1/3] ld: allow update of existing QNX stack note Clément Chigot
2023-10-13  8:02 ` [PATCH 2/3] ld: correctly handle QNX --lazy-stack without -zstack-size Clément Chigot
2023-10-13 14:06   ` Nick Clifton
2023-10-13  8:02 ` Clément Chigot [this message]
2023-10-13 14:07   ` [PATCH 3/3] ld: warn when duplicated QNX stack note are detected Nick Clifton
2023-10-13 14:06 ` [PATCH 1/3] ld: allow update of existing QNX stack note Nick Clifton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231013080248.219837-3-chigot@adacore.com \
    --to=chigot@adacore.com \
    --cc=binutils@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).