[PATCH] D34993: Refine our --wrap implementation

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 6 11:01:19 PDT 2017


Rui Ueyama via Phabricator <reviews at reviews.llvm.org> writes:

> ruiu added inline comments.
>
>
> ================
> Comment at: ELF/SymbolTable.cpp:191-193
> +  // __real_foo becomes foo
> +  // foo        becomes __wrap_foo
> +  // __wrap_foo becomes __real_foo
> ----------------
> I think I figured out why you want to rotate three symbols instead of just overwriting two symbols foo and wrap_foo. So, you want to keep these three symbols somehow in the symbol table so that they'll be emitted to the output symbol table, and you are reusing the symbol table slot for wrap_foo to keep real_foo, right?

Correct. If we just overwrite __real_foo and __foo we get two copies of
__wrap_foo and no __real_foo.

> What confused me was, after rotating three symbols, find("wrap_foo") returns real_foo. That is counter-intuitive because I didn't expect "--wrap foo" changes not only foo and real_foo but wrap_foo. Can you fix this?

It will require adding a new slot to the symbol table. It will be an odd
one in that nothing in the map will point to it, but it should work. I
will give it a try.

Cheers,
Rafael


More information about the llvm-commits mailing list