[llvm-bugs] [Bug 48201] New: [LLVM 11 regression] Linker check, new in LLVM 11, rejects common GCC code

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Nov 17 04:46:16 PST 2020


https://bugs.llvm.org/show_bug.cgi?id=48201

            Bug ID: 48201
           Summary: [LLVM 11 regression] Linker check, new in LLVM 11,
                    rejects common GCC code
           Product: libraries
           Version: 11.0
          Hardware: All
                OS: Linux
            Status: NEW
          Keywords: compile-fail, regression
          Severity: normal
          Priority: P
         Component: Linker
          Assignee: unassignedbugs at nondot.org
          Reporter: burnus at net-b.de
                CC: llvm-bugs at lists.llvm.org

LLVM's linker added a reasonable check in https://reviews.llvm.org/D73999

Such as (from the testsuite):

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


However, it also now causes an error for:
        .section        .rodata.cst8,"aM", at 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
  https://sourceware.org/legacy-ml/binutils/2020-02/msg00091.html
and the GAS patch to turn a warning to an error:
  https://sourceware.org/legacy-ml/binutils/2020-02/msg00129.html


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)
...

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20201117/dcb89d29/attachment.html>


More information about the llvm-bugs mailing list