[LLVMbugs] [Bug 3897] New: Can't execute *.bc with lli on Cygwin
bugzilla-daemon at cs.uiuc.edu
bugzilla-daemon at cs.uiuc.edu
Sat Mar 28 21:58:22 PDT 2009
http://llvm.org/bugs/show_bug.cgi?id=3897
Summary: Can't execute *.bc with lli on Cygwin
Product: libraries
Version: 2.5
Platform: PC
OS/Version: Windows XP
Status: NEW
Severity: normal
Priority: P2
Component: Backend: X86
AssignedTo: unassignedbugs at nondot.org
ReportedBy: vmi at nifty.com
CC: llvmbugs at cs.uiuc.edu
Created an attachment (id=2767)
--> (http://llvm.org/bugs/attachment.cgi?id=2767)
llvm-2.5 patch for cygwin
There are two problems.
1> lli test/ExecutionEngine/hello.bc
ERROR: Program used external function 'puts' which could not be resolved!
Aborted
The following problem occurs when the above problem is solved:
2> lli test/ExecutionEngine/hello.bc
assertion "Inserted && "Pass registered multiple times!"" failed: file
"Pass.cpp", line 149
1st problem:
- dlopen(0, ...) is not correctly executed.
----------------------------------------------------------------------
#include <stdio.h>
#include <dlfcn.h>
int main(void) {
void *d;
int (*f1)(const char *);
int (*f2)(const char *);
d = dlopen(0, RTLD_LAZY|RTLD_GLOBAL);
f1 = dlsym(d, "puts");
f2 = dlsym(0, "puts");
printf("dlopen = %p\nputs(1) = %p\nputs(2) = %p\n", d, f1, f2);
if (f1 != 0) f1("Run puts(1).");
if (f2 != 0) f2("Run puts(2).");
return 0;
}
----------------------------------------------------------------------
* Linux (Debian Lenny x64)
dlopen = 0x7f4d2b17c000
puts(1) = 0x7f4d2aa711c0
puts(2) = 0x7f4d2aa711c0
Run puts(1).
Run puts(2).
* Cygwin on Windows XP:
dlopen = 0x400000
puts(1) = 0x0
puts(2) = 0x610969b4
Run puts(2).
I patched to lib/System/DynamicLibrary.cpp. (see attached file)
2nd problem:
If run on Cygwin (or MinGW?), the following code is executed:
[lib/Target/X86/X86ISelDAGToDAG.cpp]
----------------------------------------------------------------------
/// EmitSpecialCodeForMain - Emit any code that needs to be executed only in
/// the main function.
void X86DAGToDAGISel::EmitSpecialCodeForMain(MachineBasicBlock *BB,
MachineFrameInfo *MFI) {
const TargetInstrInfo *TII = TM.getInstrInfo();
if (Subtarget->isTargetCygMing())
BuildMI(BB, DebugLoc::getUnknownLoc(),
TII->get(X86::CALLpcrel32)).addExternalSymbol("__main");
}
----------------------------------------------------------------------
However, this brings the following results when execute *.bc with lli:
1) Before executing main of lli, execute __main -> do_do_global_ctors ->
constructors of global variables -> ... -> RegisterPass at lib/VMCore/Pass.cpp
2) When executting main of *.bc, re-execute __main -> do_do_global_ctors ->
constructors of global variables -> ... -> RegisterPass at lib/VMCore/Pass.cpp ->
assert!!
I think that I should not execute __main.
I patched to lib/Target/X86/X86ISelDAGToDAG.cpp. (see attached file)
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list