[LLVMbugs] [Bug 58] [linker] linkonce globals should link successfully to external globals

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Sat Sep 4 01:39:11 PDT 2004


http://llvm.cs.uiuc.edu/bugs/show_bug.cgi?id=58

rspencer at x10sys.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |



------- Additional Comments From rspencer at x10sys.com  2004-09-04 03:39 -------
Stacker produces linkonce globals and this bug is not resolved in 1.3.

The attached test case is reduced from a two bytecode files: the prime.st file
compiled to bytecode and the stacker runtime compiled to bytecode. One declares
that _stack_ variable extern, the other declares it linkonce. 

Attempting to run this with lli produces:
Could not resolve external global address: _stack_
lli((anonymous namespace)::PrintStackTrace()+0x1a)[0x85633e6]
lli((anonymous namespace)::SignalHandler(int)+0xc7)[0x8563653]
/lib/tls/libc.so.6[0x420277b8]
/lib/tls/libc.so.6(abort+0x1d5)[0x42028c55]
lli(llvm::JIT::getOrEmitGlobalVariable(llvm::GlobalVariable const*)+0xad)[0x83262fb]
lli((anonymous
namespace)::Emitter::getGlobalValueAddress(llvm::GlobalValue*)+0x59)[0x83243f3]
lli((anonymous
namespace)::Emitter::emitGlobalAddressForPtr(llvm::GlobalValue*)+0x25)[0x838a13f]
lli((anonymous namespace)::Emitter::emitInstruction(llvm::MachineInstr
const&)+0x5a7)[0x838afc7]
lli((anonymous namespace)::Emitter::emitBasicBlock(llvm::MachineBasicBlock
const&)+0xaa)[0x8389f70]
lli((anonymous
namespace)::Emitter::runOnMachineFunction(llvm::MachineFunction&)+0xc6)[0x8389dd4]
lli(llvm::MachineFunctionPass::runOnFunction(llvm::Function&)+0x29)[0x8347df1]
lli(llvm::PassManagerTraits<llvm::Function>::runPass(llvm::FunctionPass*,
llvm::Function*)+0x1f)[0x84db56f]
lli(llvm::PassManagerT<llvm::Function>::runOnUnit(llvm::Function*)+0x5c0)[0x84dae2c]
lli(llvm::PassManagerTraits<llvm::Function>::runOnFunction(llvm::Function&)+0x1f)[0x84dbaa1]
lli(llvm::FunctionPass::run(llvm::Function&)+0x6a)[0x848314a]
lli(llvm::FunctionPassManager::run(llvm::Function&)+0xe7)[0x84826e9]
lli(llvm::JIT::runJITOnFunction(llvm::Function*)+0x4f)[0x8325fcb]
lli(llvm::JIT::getPointerToFunction(llvm::Function*)+0x15f)[0x832617b]
lli(llvm::JIT::runFunction(llvm::Function*, std::vector<llvm::GenericValue,
std::allocator<llvm::GenericValue> > const&)+0x4e)[0x8325254]
lli(llvm::ExecutionEngine::runFunctionAsMain(llvm::Function*,
std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char>
>, std::allocator<std::basic_string<char, std::char_traits<char>,
std::allocator<char> > > > const&, char const* const*)+0x2ee)[0x8377ef6]
lli(main+0x2dd)[0x830abb1]
/lib/tls/libc.so.6(__libc_start_main+0xe4)[0x42015704]
lli(dlopen+0x41)[0x830a731]
Aborted (core dumped)

Compiling the file with llc produces the following x86 assembly:
        .intel_syntax
 
 
        .text
        .align  16
        .globl  main
        .type   main, @function
main:
.LBBmain_0:     #
        mov %EAX, OFFSET _stack_
        mov %EAX, DWORD PTR [%EAX]
        #IMPLICIT_USE
        ret
 
 
        .data
        .comm l1__stack_,8192,4         # [2048 x int]* %_stack_

Which, if you try to link it, produces:
bash-2.05b$ gcc prime.s -o prime
/tmp/cc1blvtd.o(.text+0x1): In function `main':
: undefined reference to `_stack_'
collect2: ld returned 1 exit status





------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.




More information about the llvm-bugs mailing list