[PATCH] D73230: [X86][ELF] Prefer to lower MC_GlobalAddress operands to .Lfoo$local

ben via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 10 04:02:48 PDT 2020


bd1976llvm added a comment.

@MaskRay - this change causes a behaviour difference for --wrap.

Here is the --wrap behaviour before this change:

  ben at ben-VirtualBox:~/tests/wrap$ more main.c
  void __wrap_foo () {
  	puts ("__wrap_foo");
  	__real_foo();
  }
  
  void foo () { puts("foo()"); }
  
  int main() {
  	__real_foo();
  	puts("---");
  	__wrap_foo();
  	puts("---");
  	foo();
  	return 0;
  }
  ben at ben-VirtualBox:~/tests/wrap$ gcc main.c -Wl,--wrap=foo -ffunction-sections -fuse-ld=lld -o lld.elf -Wno-implicit-function-declaration
  ben at ben-VirtualBox:~/tests/wrap$ ./lld.elf 
  foo()
  ---
  __wrap_foo
  foo()
  ---
  __wrap_foo
  foo()

… and here is the behaviour after this change:

  ben at ben-VirtualBox:~/tests/wrap$ ./lld.elf 
  foo()
  ---
  __wrap_foo
  foo()
  ---
  foo()

There is no behaviour change for -flto builds so the behaviour for --wrap is now effectively different for LTO vs normal builds.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73230/new/

https://reviews.llvm.org/D73230



More information about the llvm-commits mailing list