[llvm-bugs] [Bug 40381] New: LLD leaves empty sections in header size calculation

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Jan 19 12:45:48 PST 2019


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

            Bug ID: 40381
           Summary: LLD leaves empty sections in header size calculation
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: COFF
          Assignee: unassignedbugs at nondot.org
          Reporter: rpjohnst at gmail.com
                CC: llvm-bugs at lists.llvm.org

When linking a PE image with empty sections, space for their section headers is
included in the size of the output headers, while the sections themselves are
removed.

For example, building this C file:

    int __stdcall mainCRTStartup(void) { return 0; }

with this invocation:

    clang-cl /Zl compiler.c -fuse-ld=lld /link /subsystem:console
/entry:mainCRTStartup

produces an image with SizeOfHeaders set to 0x400, but only a single section
(.text). The equivalent invocation of cl/link produces an image with
SizeOfHeaders set to 0x200:

    cl /Zl compiler.c /link /subsystem:console /entry:mainCRTStartup
/novcfeature /nocoffgrpinfo

This happens because of the dependence between Writer::assignAddresses and
Writer::removeEmptySections, in lld/COFF/Writer.cpp- section sizes (and thus
emptiness) are computed at the same time as the header size, before empty
sections are removed.

-- 
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/20190119/747e823a/attachment.html>


More information about the llvm-bugs mailing list