https://sourceware.org/bugzilla/show_bug.cgi?id=16345

--- Comment #2 from H.J. Lu <hjl.tools at gmail dot com> ---
Both .init and .fini sections are special.  This
patch warns about using "ld -r" on them:

diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
index 9a2fe89..098f423 100644
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -1114,7 +1114,20 @@ gld${EMULATION_NAME}_after_open (void)
     }

   if (link_info.relocatable)
-    return;
+    {
+      bfd *abfd;
+
+      for (abfd = link_info.input_bfds; abfd; abfd = abfd->link_next)
+    {
+      if (bfd_get_section_by_name (abfd, ".init"))
+        einfo ("%P: warning: -r on %B with .init section may lead"
+           " to incorrect output.\n", abfd);
+      if (bfd_get_section_by_name (abfd, ".fini"))
+        einfo ("%P: warning: -r on %B with .fini section may lead"
+           " to incorrect output.\n", abfd);
+    }
+      return;
+    }

   if (link_info.eh_frame_hdr
       && !link_info.traditional_format)

-- 
You are receiving this mail because:
You are on the CC list for the bug.

_______________________________________________
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils

Reply via email to