[llvm-bugs] [Bug 38976] New: extern_weak creates invalid data

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Sep 17 07:28:19 PDT 2018


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

            Bug ID: 38976
           Summary: extern_weak creates invalid data
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: COFF
          Assignee: unassignedbugs at nondot.org
          Reporter: ck at remobjects.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 20885
  --> https://bugs.llvm.org/attachment.cgi?id=20885&action=edit
t.il

An extern_weak method that's *not* resolved ends up as a as a non 0 value once
linked with lld (it becomes IMAGEBASE + 80000000):

testcase:

target triple = "x86_64-pc-windows-msvc"

declare extern_weak i8 @__elements_dll_main(i8*, i32, i8*)

define x86_stdcallcc i8 @_DllMainCRTStartup(i8*, i32, i8*) {
BasicBlock256:
  %csLoc0 = alloca i8 (i8*, i32, i8*)*
  store i8 (i8*, i32, i8*)* @__elements_dll_main, i8 (i8*, i32, i8*)** %csLoc0
  %a = load i8 (i8*, i32, i8*)*, i8 (i8*, i32, i8*)** %csLoc0
  %b = icmp eq i8 (i8*, i32, i8*)* %a, null
  br i1 %b, label %BasicBlock258, label %BasicBlock259

BasicBlock258:                                    ; preds = %BasicBlock256
  ret i8 1
BasicBlock259:                                     ; preds = %BasicBlock256
  %c = call i8 %a(i8* null, i32 0, i8* null)
  ret i8 %c
}

steps:

llc t.il -filetype=obj
lld -flavor link /dll t.il.obj

-- 
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/20180917/e2276788/attachment.html>


More information about the llvm-bugs mailing list