<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">Hi Oleg,<br>
<br>
There may be multiple issues on handling weak symbols, I will try
to fix this.<br>
<br>
Shankar Easwaran<br>
<br>
On 9/12/2014 4:35 AM, Oleg Ranevskyy wrote:<br>
</div>
<blockquote cite="mid:5412BE7F.3030903@gmail.com" type="cite">Hello
LLVM community,
<br>
<br>
I am evaluating profitability of using the LLVM lld for linking
our projects.
<br>
<br>
As a test, I tried to build the latest Boost with clang / lld on
X86_64 Ubuntu and faced a problem at the very first step of doing
this. One of the Boost's auxiliary tools refers to the "environ"
variable to access the environment variables. "environ" is defined
in glibc and is actually a weak alias for the "__environ"
variable. Here is a fragment of posix/environ.c:
<br>
<br>
char **__environ = NULL; // var pointing to env vars array
<br>
weak_alias (__environ, environ) // and two weak aliases to it
<br>
weak_alias (__environ, _environ)
<br>
<br>
When linking a program that accesses "environ" with binutils' ld,
the symbol is correctly marked as a weak object:
<br>
> nm a.out | grep environ
<br>
0000000000601040 B __environ@@GLIBC_2.2.5
<br>
0000000000601040 *V *environ@@GLIBC_2.2.5
<br>
<br>
LLVM lld marks it as uninitialized data from the BSS section:
<br>
0000000000401168 *B* environ
<br>
<br>
Readelf also shows different symbols (readelf -s a.out | grep
environ):
<br>
- ld:
<br>
4: 0000000000601040 8 OBJECT WEAK DEFAULT 25
_environ@GLIBC_2.2.5 (2)
<br>
5: 0000000000601040 8 OBJECT WEAK DEFAULT 25
<a class="moz-txt-link-abbreviated" href="mailto:environ@GLIBC_2.2.5">environ@GLIBC_2.2.5</a> (2) <- environ is a weak object
<br>
6: 0000000000601040 8 OBJECT GLOBAL DEFAULT 25
__environ@GLIBC_2.2.5 (2) <- __environ itself is present as a
global
<br>
54: 0000000000601040 8 OBJECT WEAK DEFAULT 25
<a class="moz-txt-link-abbreviated" href="mailto:environ@@GLIBC_2.2.5">environ@@GLIBC_2.2.5</a>
<br>
63: 0000000000601040 8 OBJECT GLOBAL DEFAULT 25
__environ@@GLIBC_2.2.5
<br>
<br>
- lld
<br>
1: 0000000000401168 8 OBJECT GLOBAL DEFAULT 22
environ <- no __environ reference. Environ is a global, not
weak
<br>
8: 0000000000000000 8 OBJECT GLOBAL DEFAULT UND
environ
<br>
37: 0000000000401168 8 OBJECT GLOBAL DEFAULT 22
environ
<br>
<br>
This leads to "environ" being nil when running the lld-linked
binary.
<br>
<br>
Is it a known problem?
<br>
What is the fullness of ELF/Linux support?
<br>
Where can I find the features list that are expected to work and
what work is still in progress?
<br>
<br>
Thank you!
<br>
<br>
Kind regards,
<br>
Oleg
<br>
<br>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
LLVM Developers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a class="moz-txt-link-freetext" href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a>
<a class="moz-txt-link-freetext" href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a>
</pre>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by the Linux Foundation</pre>
</body>
</html>