[llvm-bugs] [Bug 43911] New: [COFF] specifying alignment argument produces non-runnable output

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Nov 5 10:13:50 PST 2019


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

            Bug ID: 43911
           Summary: [COFF] specifying alignment argument produces
                    non-runnable output
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: other
            Status: NEW
          Severity: normal
          Priority: P
         Component: COFF
          Assignee: unassignedbugs at nondot.org
          Reporter: petr.penzin at intel.com
                CC: llvm-bugs at lists.llvm.org

Specifying alignment to MSVC-compatible linker creates invalid image.

OS: Windows 10
Visual Studio 2019, 14.23.28106.4

LLVM trunk at cecc0d27ad58c0aed8ef9ed99bbf691e137a0f26, also release 9.0 (from
the installer). Release 8 works fine.

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

int
main(void) {
  printf("Hello world\n");
  return 0;
}

$ clang-cl /c hello.c

$ lld-link hello.obj

$ hello.exe
Hello world

$ lld-link /align:16 hello.obj

$ hello.exe
Access is denied.

$ dumpbin /all /rawdata:none hello.exe

SECTION HEADER #1
   .text name
   10CF6 virtual size
     400 virtual address (0000000140000400 to 00000001400110F5)
   10E00 size of raw data
     400 file pointer to raw data (00000400 to 000111FF)
       0 file pointer to relocation table
       0 file pointer to line numbers
       0 number of relocations
       0 number of line numbers
60000020 flags
         Code
         Execute Read
LINK : warning LNK4030: invalid file offset 0x11110 for LOADCONFIG; category
not dumped

  Section contains the following load config:

            CCCCCCCC size
            CCCCCCCC time date stamp Thu Nov 17 21:10:36 2078
         52428.52428 Version
            CCCCCCCC GlobalFlags Clear
            CCCCCCCC GlobalFlags Set
          3435973836 Critical Section Default Timeout
    CCCCCCCCCCCCCCCC Decommit Free Block Threshold
    CCCCCCCCCCCCCCCC Decommit Total Free Threshold
    CCCCCCCCCCCCCCCC Lock Prefix Table
    CCCCCCCCCCCCCCCC Maximum Allocation Size
    CCCCCCCCCCCCCCCC Virtual Memory Threshold
            CCCCCCCC Process Heap Flags
    CCCCCCCCCCCCCCCC Process Affinity Mask
               52428 CSD Version
                CCCC Dependent Load Flag
    CCCCCCCCCCCCCCCC Edit List
    CCCCCCCCCCCCCCCC Security Cookie
    CCCCCCCCCCCCCCCC Guard CF address of check-function pointer
    CCCCCCCCCCCCCCCC Guard CF address of dispatch-function pointer
    CCCCCCCCCCCCCCCC Guard CF function table
            CCCCCCCC Guard CF function count
            CCCCCCCC Guard Flags
                       FID table present
                       Security cookie unused
                       Export suppression info present
                       Export suppression enabled
                       RFG enabled
                       RFG in strict mode
                CCCC Code Integrity Flags
                CCCC Code Integrity Catalog
            CCCCCCCC Code Integrity Catalog Offset
            CCCCCCCC Code Integrity Reserved
    CCCCCCCCCCCCCCCC Guard CF address taken IAT entry table
            CCCCCCCC Guard CF address taken IAT entry count
    CCCCCCCCCCCCCCCC Guard CF long jump target table
            CCCCCCCC Guard CF long jump target count
    CCCCCCCCCCCCCCCC Dynamic value relocation table
    CCCCCCCCCCCCCCCC Hybrid metadata pointer
    CCCCCCCCCCCCCCCC Guard RF address of failure-function
    CCCCCCCCCCCCCCCC Guard RF address of failure-function pointer
            CCCCCCCC Dynamic value relocation table offset
                CCCC Dynamic value relocation table section
                CCCC Reserved2

LINK : fatal error LNK1000: Internal error during DumpLoadConfig

Specifying matching file alignment value is a remedy to dumpbin crash, but the
executable would not still run:

$ lld-link /align:16 /filealign:16 hello.obj

$ hello.exe
Access is denied.

LINK handles both /align and /align+/filealign:

$ link /align:16 /filealign:16 hello.obj
Microsoft (R) Incremental Linker Version 14.23.28106.4
Copyright (C) Microsoft Corporation.  All rights reserved.

LINK : warning LNK4108: /ALIGN specified without /DRIVER; image may not run

$ hello.exe
Hello world

$ link /align:16 hello.obj
Microsoft (R) Incremental Linker Version 14.23.28106.4
Copyright (C) Microsoft Corporation.  All rights reserved.

LINK : warning LNK4108: /ALIGN specified without /DRIVER; image may not run

$ hello.exe
Hello world

-- 
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/20191105/387b1f16/attachment-0001.html>


More information about the llvm-bugs mailing list