<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div>I believe in iterative development, and that test cases are more important than the implementation.  That means that as long as the test cases for this feature have good coverage, we can later change the implementation have confidence that if the test suite passes, the new implementation is correct.</div><div><br></div><div>So, I’m ok with committing this undef-fallback implementation as long as there are test cases for it.</div><div><br></div><div>-Nick</div><br><div><div>On Sep 6, 2013, at 1:09 PM, Rui Ueyama <<a href="mailto:ruiu@google.com">ruiu@google.com</a>> wrote:</div><blockquote type="cite"><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div dir="ltr">That's again slightly different from simple symbol aliasing, because with --wrap,<span class="Apple-converted-space"> </span><i>symbol</i> will be resolved to __wrap_<i>symbol</i>, while __real_<i>symbol</i><span class="Apple-converted-space"> </span>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 class="Apple-converted-space"> </span><span dir="ltr"><<a href="mailto:shankare@codeaurora.org" target="_blank">shankare@codeaurora.org</a>></span><span class="Apple-converted-space"> </span>wrote:<br><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: 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: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: 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: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;">On 9/3/2013 2:59 PM, Nick Kledzik wrote:<br><br><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: 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> <span class="Apple-converted-space"> </span>On 9/3/2013 2:36 PM, Nick Kledzik wrote:<br><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: 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: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: 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> <span class="Apple-converted-space"> </span>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>   <span class="Apple-converted-space"> </span>Num:    Value  Size Type    Bind   Vis      Ndx Name<br>     <span class="Apple-converted-space"> </span>0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND<br>     <span class="Apple-converted-space"> </span>1: 00000000     0 FILE    LOCAL  DEFAULT  ABS x.c<br>     <span class="Apple-converted-space"> </span>2: 00000000     0 SECTION LOCAL  DEFAULT    1<br>     <span class="Apple-converted-space"> </span>3: 00000000     0 SECTION LOCAL  DEFAULT    2<br>     <span class="Apple-converted-space"> </span>4: 00000000     0 SECTION LOCAL  DEFAULT    3<br>     <span class="Apple-converted-space"> </span>5: 00000000     0 SECTION LOCAL  DEFAULT    5<br>     <span class="Apple-converted-space"> </span>6: 00000000     0 SECTION LOCAL  DEFAULT    6<br>     <span class="Apple-converted-space"> </span>7: 00000000     0 SECTION LOCAL  DEFAULT    4<br>     <span class="Apple-converted-space"> </span>8: 00000000     5 FUNC    GLOBAL DEFAULT    1 __f<br>     <span class="Apple-converted-space"> </span>9: 00000000     5 FUNC    WEAK   DEFAULT    1 f<br><br><br><br><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"> <span class="Apple-converted-space"> </span>Does Darwin keep the alias information when the<br><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: 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>--<span class="Apple-converted-space"> </span><br>Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by the Linux Foundation</div></div></blockquote></div></div></div></blockquote></div><br></body></html>