<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [LLVM 11 regression] Linker check, new in LLVM 11, rejects common GCC code"
   href="https://bugs.llvm.org/show_bug.cgi?id=48201">48201</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[LLVM 11 regression] Linker check, new in LLVM 11, rejects common GCC code
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>11.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Keywords</th>
          <td>compile-fail, regression
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Linker
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>burnus@net-b.de
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>LLVM's linker added a reasonable check in <a href="https://reviews.llvm.org/D73999">https://reviews.llvm.org/D73999</a>

Such as (from the testsuite):

  .section .foo,"aM",@progbits,1
  .section .foo,"aM",@progbits,4
 error: changed section entsize for .foo, expected: 1 


However, it also now causes an error for:
        .section        .rodata.cst8,"aM",@progbits,8
        .section        .rodata.cst8


The problem is that GCC generates this by default (gcc/varasm.c):


  /* If we have already declared this section, we can use an
     abbreviated form to switch back to it -- unless this section is
     part of a COMDAT groups, in which case GAS requires the full
     declaration every time.  */
  if (!(HAVE_COMDAT_GROUP && (flags & SECTION_LINKONCE))
      && (flags & SECTION_DECLARED))
    { 
      fprintf (asm_out_file, "\t.section\t%s\n", name);
      return;
    }


LLVM and GNU as ("gas") tried to align, cf. discussion
  <a href="https://sourceware.org/legacy-ml/binutils/2020-02/msg00091.html">https://sourceware.org/legacy-ml/binutils/2020-02/msg00091.html</a>
and the GAS patch to turn a warning to an error:
  <a href="https://sourceware.org/legacy-ml/binutils/2020-02/msg00129.html">https://sourceware.org/legacy-ml/binutils/2020-02/msg00129.html</a>


However, while llvm/lib/MC/MCParser/ELFAsmParser.cpp always issues an error:

+  if (Section->getType() != Type)
+    Error(loc, "changed section type for " + SectionName + ", expected: 0x" +
+                   utohexstr(Section->getType()));
etc.

The GNU assembler only does so if flags have been specified,
gas/config/obj-elf.c:

      if (attr != 0)
        { 
          /* If section attributes are specified the second time we see a
             particular section, then check that they are the same as we
             saw the first time.  */
          if (((old_sec->flags ^ flags)
...</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>