[llvm-bugs] [Bug 33443] New: COFF: minimal program links in unnecessary parts of libcmt.lib due to _load_cfg_used resolution

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jun 13 15:45:54 PDT 2017


            Bug ID: 33443
           Summary: COFF: minimal program links in unnecessary parts of
                    libcmt.lib due to _load_cfg_used resolution
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: COFF
          Assignee: unassignedbugs at nondot.org
          Reporter: rnk at google.com
                CC: llvm-bugs at lists.llvm.org

In LLD, if any input object added to the symbol table defines _load_cfg_used,
then we mark it as undefined to pull in that object and anything it references.

I don't think this is quite what the MSVC linker does.

This behavior was added back in r243182 for /safeseh handling.

This makes small examples with two object files that happen to contain
/defaultlib:libcmt slightly larger:

$ cat t.c
extern void foo();
int main() {
  return 42;

$ cat a.c
void foo() {}

$ cl -c t.c a.c

$ lld-link t.obj a.obj -entry:main -verbose
C:\src\llvm-project\build\bin\lld-link.exe: Reading t.obj
C:\src\llvm-project\build\bin\lld-link.exe: Directives: t.obj:
C:\src\llvm-project\build\bin\lld-link.exe: Reading a.obj
C:\src\llvm-project\build\bin\lld-link.exe: Directives: a.obj:
C:\src\llvm-project\build\bin\lld-link.exe: Reading
C:\src\llvm-project\build\bin\lld-link.exe: Reading
C:\src\llvm-project\build\bin\lld-link.exe: Reading libcmt.lib(loadcfg.obj)
C:\src\llvm-project\build\bin\lld-link.exe: Loaded libcmt.lib(loadcfg.obj) for
C:\src\llvm-project\build\bin\lld-link.exe: Reading libcmt.lib(gs_cookie.obj)
C:\src\llvm-project\build\bin\lld-link.exe: Loaded libcmt.lib(gs_cookie.obj)
for __security_cookie
C:\src\llvm-project\build\bin\lld-link.exe: Reading
C:\src\llvm-project\build\bin\lld-link.exe: Loaded
libcmt.lib(guard_support.obj) for __guard_check_icall_fptr
C:\src\llvm-project\build\bin\lld-link.exe: Reading
C:\src\llvm-project\build\bin\lld-link.exe: Loaded
libcmt.lib(_guard_dispatch_.obj) for _guard_dispatch_icall_nop
C:\src\llvm-project\build\bin\lld-link.exe: ICF needed 2 iterations
Discarded _guard_icall_checks_enforced
Discarded __guard_fids__guard_icall_checks_enforced

My marking _load_cfg_used undefined, LLD links in four more object files from
libcmt.lib than MSVC. This isn't really a major size problem, but it's annoying
when trying to produce very reduced examples that have very minimal inputs.

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/20170613/e5ede26a/attachment.html>

More information about the llvm-bugs mailing list