[PATCH] Add a fallback mechanism for undefined atom.

Rui Ueyama ruiu at google.com
Fri Sep 6 13:32:20 PDT 2013


On Fri, Sep 6, 2013 at 1:19 PM, Shankar Kalpathi Easwaran <
shankarke at gmail.com> wrote:

>
>   It also changes the call to the __wrap_symbol if real symbol is not
> found.
>   If the real symbol is found, the call still is routed to the real
> function and not the wrap function.
>   This is clearly the alias feature. The implementation suggested by Nick
> is very clean in my opinion for this.
>

I'm not saying that that is not an aliasing feature. What I said is it's
not a simple aliasing feature which I think is usually transitive (if B is
an alias of A and C is an alias of B, C is an alias of A). PECOFF's "weak
external" symbols also have as we have seen in this thread slightly
different semantics. I don't think I can address these aspects of all
different flavor of aliasing soon. By aliasing itself, it's going to be
larger and complicated patch than this one. We can discuss and implement
that later.

My point is that this patch is useful and simple enough, so we should
submit this to make LLD to actually link real C++ programs.


>   Below is a snippet that uses calls to wrap :-
>
>   Example :-
>   (1) Using wrap function directly
>   $cat wrap.c
>   #include <stdio.h>
>
>   void __wrap_myfn()
>   {
>     printf("Hello World\n");
>   }
>
>   int main() {
>     myfn();
>     return 0;
>   }
>   $gcc wrap.c -Wl,--wrap,myfn
>   $./a.out
>   Hello World
>   $gcc wrap.c
>   /tmp/ccV7Dm8C.o: In function `main':
>   wrap.c:(.text+0x1a): undefined reference to `myfn'
>   collect2: error: ld returned 1 exit status
>
>   (2) wrap with a definition
>
>   #include <stdio.h>
>
>   void myfn() {
>     printf("not in wrap function\n");
>   }
>
>   void __wrap_myfn()
>   {
>     printf("Hello World\n");
>   }
>
>   int main() {
>     myfn();
>     return 0;
>   }
>
>   $gcc wrapdefn.c -Wl,--wrap,myfn
>   $./a.out
>   not in wrap function
>
> http://llvm-reviews.chandlerc.com/D1550
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130906/3b9e1299/attachment.html>


More information about the llvm-commits mailing list