<div dir="ltr">That's again slightly different from simple symbol aliasing, because with --wrap, <i>symbol</i> will be resolved to __wrap_<i>symbol</i>, while __real_<i>symbol</i> is resolved to <i>symbol</i>. In this case aliasing is not transitive. Anyways, I don't think that should block this patch.</div>

<div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Sep 6, 2013 at 1:03 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">Hi Ruiu,<br>
<br>
We need the functionality for ELF too to implement the --wrap functionality.<br>
<br>
Thanks<span class="HOEnZb"><font color="#888888"><br>
<br>
Shankar Easwaran</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
On 9/6/2013 2:58 PM, Rui Ueyama wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Guys,<br>
<br>
I want to submit this patch. This patch is one of the last few patches that<br>
I need to link against the standard C++ library on Windows. Symbol aliasing<br>
does not seems to be needed for ELF. For Mach-O we need the feature, but<br>
how to implement can be discussed later. This patch is short and not<br>
intrusive, so it won't hurt anyone.<br>
<br>
<br>
On Tue, Sep 3, 2013 at 1:07 PM, Shankar Easwaran <<a href="mailto:shankare@codeaurora.org" target="_blank">shankare@codeaurora.org</a>><u></u>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:59 PM, Nick Kledzik wrote:<br>
<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>><br>
wrote:<br>
<br>
  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"><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>
<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>
<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<br>
from the compiler team was that mach-o did not support aliases like ELF<br>
did, so the compiler team kept having to special case lots of test cases<br>
and functionality that used __attribute__((alias(“xx”))) on darwin.<br>
<br>
<br>
  looks like ELF also needs the same functionality for implementing<br>
</blockquote>
__wrap.<br>
<br>
But in the case of the linker dealing with compiled .o's, the alias<br>
information is lost.<br>
<br>
</blockquote>
Really?  I thought ELF had a way to encode this.   I’ve received bug<br>
reports saying that mach-o should support it too.<br>
<br>
</blockquote>
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<br>
<br>
<br>
<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<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
__attribute__((alias(“xx”)) is used.<br>
<br>
</blockquote>
What the current darwin linker does is if parses a .o file and there are<br>
two symbols at the same address (and same section), it picks one to be the<br>
atom name (call it “foo”) and the other (call it “bar”) is turned into an<br>
alias atom (zero size and atom foo must layout after atom bar)<br>
<br>
</blockquote>
We do something very similiar in lld in the ELF reader, except that we<br>
dont alias it(as we need the content of the original atom, for the linker<br>
to abide the section property).<br>
<br>
Thanks<br>
<br>
Shankar Easwaran<br>
<br>
--<br>
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted<br>
by the Linux Foundation<br>
<br>
<br>
</blockquote></blockquote>
<br>
<br>
-- <br>
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by the Linux Foundation<br>
<br>
</div></div></blockquote></div><br></div>