<div dir="ltr">Guys,<div><br></div><div>I want to submit this patch. This patch is one of the last few patches that I need to link against the standard C++ library on Windows. Symbol aliasing does not seems to be needed for ELF. For Mach-O we need the feature, but how to implement can be discussed later. This patch is short and not intrusive, so it won't hurt anyone.</div>

</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Sep 3, 2013 at 1:07 PM, Shankar Easwaran <span dir="ltr"><<a href="mailto:shankare@codeaurora.org" target="_blank">shankare@codeaurora.org</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On 9/3/2013 2:59 PM, Nick Kledzik wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Sep 3, 2013, at 12:51 PM, Shankar Easwaran <<a href="mailto:shankare@codeaurora.org" target="_blank">shankare@codeaurora.org</a>> wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 9/3/2013 2:36 PM, Nick Kledzik wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Sep 3, 2013, at 11:06 AM, Rui Ueyama <<a href="mailto:ruiu@google.com" target="_blank">ruiu@google.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Nick, does Mach-O need symbol aliasing to be handled in the linker?<br>
</blockquote>
Yes.  The darwin linker has command line options for adding aliases.<br>
<br>
Back when I first started working on the darwin linker, a big complaint from the compiler team was that mach-o did not support aliases like ELF did, so the compiler team kept having to special case lots of test cases and functionality that used __attribute__((alias(“xx”))) on darwin.<br>


<br>
<br>
</blockquote>
looks like ELF also needs the same functionality for implementing __wrap.<br>
<br>
But in the case of the linker dealing with compiled .o's, the alias information is lost.<br>
</blockquote>
Really?  I thought ELF had a way to encode this.   I’ve received bug reports saying that mach-o should support it too.<br>
</blockquote>
<br></div>
Example :-<br>
<br>
$cat x.c<br>
void __f () { /* Do something. */; }<br>
          void f () __attribute__ ((weak, alias ("__f")));<br>
$gcc -c x.c<br>
$readelf -s x.o<br>
<br>
Symbol table '.symtab' contains 10 entries:<br>
   Num:    Value  Size Type    Bind   Vis      Ndx Name<br>
     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND<br>
     1: 00000000     0 FILE    LOCAL  DEFAULT  ABS x.c<br>
     2: 00000000     0 SECTION LOCAL  DEFAULT    1<br>
     3: 00000000     0 SECTION LOCAL  DEFAULT    2<br>
     4: 00000000     0 SECTION LOCAL  DEFAULT    3<br>
     5: 00000000     0 SECTION LOCAL  DEFAULT    5<br>
     6: 00000000     0 SECTION LOCAL  DEFAULT    6<br>
     7: 00000000     0 SECTION LOCAL  DEFAULT    4<br>
     8: 00000000     5 FUNC    GLOBAL DEFAULT    1 __f<br>
     9: 00000000     5 FUNC    WEAK   DEFAULT    1 f<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Does Darwin keep the alias information when the __attribute__((alias(“xx”)) is used.<br>
</blockquote>
What the current darwin linker does is if parses a .o file and there are two symbols at the same address (and same section), it picks one to be the atom name (call it “foo”) and the other (call it “bar”) is turned into an alias atom (zero size and atom foo must layout after atom bar)<br>


</blockquote></div>
We do something very similiar in lld in the ELF reader, except that we dont alias it(as we need the content of the original atom, for the linker to abide the section property).<br>
<br>
Thanks<span class="HOEnZb"><font color="#888888"><br>
<br>
Shankar Easwaran<br>
<br>
-- <br>
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by the Linux Foundation<br>
<br>
</font></span></blockquote></div><br></div>