[LLVMdev] global symbols converted to local symbols

John Criswell criswell at uiuc.edu
Wed Oct 29 21:36:13 PDT 2008


Ryan M. Lefever wrote:
> I have a bitcode file x.bc.  When I run llmv-nm on x.bc, it shows that a 
> function f(), that I've written, is defined as a global function (text) 
> object, i.e., llvm-nm shows it marked with a 'T'.  I have converted x.bc 
> to an executable with the following command:  llvm-ld -native -o x.exe 
> x.bc  When I run nm on x.exe, it shows that f is now a local function 
> (text) object, i.e., nm shows it marked with a 't'.  Why is llvm-ld 
> converting f() from a global function object to a local function object.
>   
I suspect what is happening is that the internalize pass is being 
executed by llvm-ld because it believes that your program is now 
complete and that it is safe to mark globals as internal (which provides 
greater optimization opportunity).

There are several things you can do:

1) Run llvm-ld with the -disable-opt option to disable optimization.  
Use opt to optimize manually using the -internalize-<x> options to 
control what is internalized and what is not (see opt --help for more 
information).

2) If the native code library is one that you wrote, you can change the 
interface to pass a pointer to the global into the library as opposed to 
having the linker resolve the references.

-- John T.

> I believe that I need f() to be a global function object because I use 
> LD_PRELOAD to load a library that make use of f().
>
> Thanks,
> Ryan
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>   




More information about the llvm-dev mailing list