[PATCH] D48502: Fix direct calls to __wrap_sym when it is relocated

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 27 00:44:17 PDT 2018


ruiu added a comment.

I thought about this patch for a bit today. Could you give a program that crashes without this patch? I don't think I understand if we really need this.

My understanding of this patch is this:

1. When you add --wrap=foo, `foo` is renamed `real_foo`, and `wrap_foo` renamed `foo`. After the renaming operation, `wrap_foo` and `foo` points to the same function. We do that by overwriting `foo` with `wrap_foo`'s symbol contents.
2. In some cases, only one of `foo` or `wrap_foo` got a PLT entry.
3. If you call a function that didn't get a PLT entry, that call will be a direct call (i.e. without going through the PLT entry).

I don't know how (3) can lead to a crash. Could you explain it for me?


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D48502





More information about the llvm-commits mailing list