]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - ld/ldlang.c
bfd/
[thirdparty/binutils-gdb.git] / ld / ldlang.c
index f417a30bfd521a9878987a208a4eeb580742dc3d..dbe0697d0c87d17bdfcb5b0bc16c503a8cda149e 100644 (file)
@@ -1176,8 +1176,22 @@ wild_doit (ptr, section, output, file)
       if (! first && (section->output_section->flags & SEC_READONLY) == 0)
        flags &= ~ SEC_READONLY;
 
+      /* Keep SEC_MERGE and SEC_STRINGS only if they are the same.  */
+      if (! first
+         && ((section->output_section->flags & (SEC_MERGE | SEC_STRINGS))
+             != (flags & (SEC_MERGE | SEC_STRINGS))
+             || ((flags & SEC_MERGE)
+                 && section->output_section->entsize != section->entsize)))
+       {
+         section->output_section->flags &= ~ (SEC_MERGE | SEC_STRINGS);
+         flags &= ~ (SEC_MERGE | SEC_STRINGS);
+       }
+
       section->output_section->flags |= flags;
 
+      if (flags & SEC_MERGE)
+       section->output_section->entsize = section->entsize;
+
       /* If SEC_READONLY is not set in the input section, then clear
          it from the output section.  */
       if ((section->flags & SEC_READONLY) == 0)