ld: warn when duplicated QNX stack note are detected
authorClément Chigot <chigot@adacore.com>
Fri, 6 Oct 2023 12:38:40 +0000 (14:38 +0200)
committerClément Chigot <chigot@adacore.com>
Fri, 13 Oct 2023 14:23:39 +0000 (16:23 +0200)
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

index b1a6133841217ce587c5f2f519ced919ffa7783f..f4c76f18fc2fb540d438d4068a17bb6fd6ae11ee 100644 (file)
@@ -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;
+           }
        }
     }