[llvm-bugs] [Bug 43627] New: LTO + LLD fails with "SHF_MERGE section size must be a multiple of sh_entsize"

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Oct 9 13:21:26 PDT 2019


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: unassignedbugs at nondot.org
          Reporter: samitolvanen at google.com
                CC: htmldeveloper at gmail.com, jgalenson at google.com,
                    llvm-bugs at lists.llvm.org, ndesaulniers at google.com,
                    ruiu at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20191009/3cb07317/attachment.html>


More information about the llvm-bugs mailing list