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

            Bug ID: 43627
           Summary: LTO + LLD fails with "SHF_MERGE section size must be a
                    multiple of sh_entsize"
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedb...@nondot.org
          Reporter: samitolva...@google.com
                CC: htmldevelo...@gmail.com, jgalen...@google.com,
                    llvm-bugs@lists.llvm.org, ndesaulni...@google.com,
                    r...@google.com

When compiling the Linux kernel with ThinLTO+LLD, we ran into an issue that can
be reproduced as follows:

$ cat test.c
#include <stdio.h>

#define SIZE_AB 2
#define SIZE_C  3

#define __initconst __attribute__((__section__(".init.rodata")))

static const unsigned int __initconst a[][SIZE_AB] = {
        { 0, 0 },
        { 0, 0 },
};

static const unsigned int __initconst b[][SIZE_AB] = {
        { 0, 0 },
        { 0, 0 },
};

static const unsigned int __initconst c[][SIZE_C] = {
        { 0, 0, 0 },
        { 0, 0, 0 },
};

int main() {
        for (int i = 0; i < 2; i++) {
                printf("%u\n", a[i][0]);
                printf("%u\n", b[i][0]);
                printf("%u\n", c[i][0]);
        }

        return 0;
}

$ clang -flto=thin -fvisibility=default -c -o test.o test.c
$ ld.lld -r -o all.o test.o
ld.lld: error: lto.tmp: SHF_MERGE section size must be a multiple of sh_entsize

Here, the section size is 56 bytes, while sh_entsize is 16 bytes.

In the kernel, we don't have this issue with full LTO, but the reproducer above
fails to compile also with -flto. Here's the ClangBuiltLinux bug:

https://github.com/ClangBuiltLinux/linux/issues/510

This issue is reproducible with a ToT LLVM.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to