llvm.org GIT mirror llvm / 8f15c88
Revert "[LTO/gold] Support --wrap" This reverts commit r327459. The new gold plugin interface is not available with older gold installations, leading to compile failures: http://lab.llvm.org:8011/builders/clang-with-thin-lto-ubuntu/builds/9109/steps/build-stage2-LLVMgold.so/logs/stdio git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327465 91177308-0d34-0410-b5e6-96231b3b80d8 Teresa Johnson 2 years ago
5 changed file(s) with 0 addition(s) and 174 deletion(s). Raw diff Collapse all Expand all
+0
-14
test/tools/gold/X86/v1.16/Inputs/wrap-bar.ll less more
None target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
1 target triple = "x86_64-unknown-linux-gnu"
2
3 define hidden void @bar() {
4 ret void
5 }
6
7 define hidden void @__real_bar() {
8 ret void
9 }
10
11 define hidden void @__wrap_bar() {
12 ret void
13 }
+0
-28
test/tools/gold/X86/v1.16/lit.local.cfg less more
None import re
1 import subprocess
2
3 def is_gold_v1_16_linker_available():
4
5 if not config.gold_executable:
6 return False
7 try:
8 ld_cmd = subprocess.Popen([config.gold_executable, '-v'],
9 stdout = subprocess.PIPE,
10 stderr = subprocess.PIPE)
11 ld_out, _ = ld_cmd.communicate()
12 ld_out = ld_out.decode()
13 except:
14 return False
15
16 match = re.search(r'GNU gold \(.*\) (\d+)\.(\d+)', ld_out)
17 if not match:
18 return False
19 major = int(match.group(1))
20 minor = int(match.group(2))
21 if major < 1 or (major == 1 and minor < 16):
22 return False
23
24 return True
25
26 if not is_gold_v1_16_linker_available():
27 config.unsupported = True
+0
-42
test/tools/gold/X86/v1.16/wrap-1.ll less more
None ; LTO
1 ; RUN: llvm-as %s -o %t.o
2 ; RUN: %gold -plugin %llvmshlibdir/LLVMgold%shlibext %t.o -o %t.out -wrap=bar -plugin-opt=save-temps
3 ; RUN: llvm-readobj -t %t.out | FileCheck %s
4 ; RUN: cat %t.out.resolution.txt | FileCheck -check-prefix=RESOLS %s
5
6 ; ThinLTO
7 ; RUN: opt -module-summary %s -o %t.o
8 ; RUN: %gold -plugin %llvmshlibdir/LLVMgold%shlibext %t.o -o %t.out -wrap=bar -plugin-opt=save-temps
9 ; RUN: llvm-readobj -t %t.out | FileCheck %s
10 ; RUN: cat %t.out.resolution.txt | FileCheck -check-prefix=RESOLS %s
11
12 ; CHECK: Name: __wrap_bar
13 ; CHECK-NEXT: Value:
14 ; CHECK-NEXT: Size:
15 ; CHECK-NEXT: Binding: Global
16 ; CHECK-NEXT: Type: Function
17
18 ; Make sure that the 'r' (linker redefined) bit is set for bar and __real_bar
19 ; in the resolutions file, and that the 'x' (visible to regular obj) bit is set
20 ; for bar and __wrap_bar.
21 ; RESOLS: ,bar,lxr
22 ; RESOLS: ,__wrap_bar,plx
23 ; RESOLS: ,__real_bar,plr
24
25 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
26 target triple = "x86_64-unknown-linux-gnu"
27
28 declare void @bar()
29
30 define void @_start() {
31 call void @bar()
32 ret void
33 }
34
35 define void @__wrap_bar() {
36 ret void
37 }
38
39 define void @__real_bar() {
40 ret void
41 }
+0
-55
test/tools/gold/X86/v1.16/wrap-2.ll less more
None ; LTO
1 ; This doesn't currently work with gold, because it does not apply defsym
2 ; renaming to symbols in the same module (apparently by design for consistency
3 ; with GNU ld). Because regular LTO hands back a single object file to gold,
4 ; it doesn't perform the desired defsym renaming. This isn't an issue with
5 ; ThinLTO which hands back multiple native objects to gold. For regular
6 ; LTO defsym handling, gold will need a fix (not the gold plugin).
7 ; RUN-TODO: llvm-as %s -o %t.o
8 ; RUN-TODO: llvm-as %S/Inputs/wrap-bar.ll -o %t1.o
9 ; RUN-TODO: %gold -plugin %llvmshlibdir/LLVMgold%shlibext %t.o %t1.o -shared -o %t.so -wrap=bar
10 ; RUN-TODO: llvm-objdump -d %t.so | FileCheck %s
11 ; RUN-TODO: llvm-readobj -t %t.so | FileCheck -check-prefix=BIND %s
12
13 ; ThinLTO
14 ; RUN: opt -module-summary %s -o %t.o
15 ; RUN: opt -module-summary %S/Inputs/wrap-bar.ll -o %t1.o
16 ; RUN: %gold -plugin %llvmshlibdir/LLVMgold%shlibext %t.o %t1.o -shared -o %t.so -wrap=bar
17 ; RUN: llvm-objdump -d %t.so | FileCheck %s -check-prefix=THIN
18 ; RUN: llvm-readobj -t %t.so | FileCheck -check-prefix=BIND %s
19
20 ; Make sure that calls in foo() are not eliminated and that bar is
21 ; routed to __wrap_bar and __real_bar is routed to bar.
22
23 ; CHECK: foo:
24 ; CHECK-NEXT: pushq %rax
25 ; CHECK-NEXT: callq{{.*}}<__wrap_bar>
26 ; CHECK-NEXT: callq{{.*}}
27
28 ; THIN: foo:
29 ; THIN-NEXT: pushq %rax
30 ; THIN-NEXT: callq{{.*}}<__wrap_bar>
31 ; THIN-NEXT: popq %rax
32 ; THIN-NEXT: jmp{{.*}}
33
34 ; Check that bar and __wrap_bar retain their original binding.
35 ; BIND: Name: bar
36 ; BIND-NEXT: Value:
37 ; BIND-NEXT: Size:
38 ; BIND-NEXT: Binding: Local
39 ; BIND: Name: __wrap_bar
40 ; BIND-NEXT: Value:
41 ; BIND-NEXT: Size:
42 ; BIND-NEXT: Binding: Local
43
44 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
45 target triple = "x86_64-unknown-linux-gnu"
46
47 declare void @bar()
48 declare void @__real_bar()
49
50 define void @foo() {
51 call void @bar()
52 call void @__real_bar()
53 ret void
54 }
5555 static ld_plugin_release_input_file release_input_file = nullptr;
5656 static ld_plugin_get_input_file get_input_file = nullptr;
5757 static ld_plugin_message message = discard_message;
58 static ld_plugin_get_wrap_symbols get_wrap_symbols = nullptr;
5958
6059 namespace {
6160 struct claimed_file {
9392 struct ResolutionInfo {
9493 bool CanOmitFromDynSym = true;
9594 bool DefaultVisibility = true;
96 bool CanInline = true;
97 bool IsUsedInRegularObj = false;
9895 };
9996
10097 }
369366 case LDPT_MESSAGE:
370367 message = tv->tv_u.tv_message;
371368 break;
372 case LDPT_GET_WRAP_SYMBOLS:
373 get_wrap_symbols = tv->tv_u.tv_get_wrap_symbols;
374 break;
375369 default:
376370 break;
377371 }
568562 }
569563 }
570564
571 // Handle any --wrap options passed to gold, which are than passed
572 // along to the plugin.
573 if (get_wrap_symbols) {
574 const char **wrap_symbols;
575 uint64_t count = 0;
576 if (get_wrap_symbols(&count, &wrap_symbols) != LDPS_OK) {
577 message(LDPL_ERROR, "Unable to get wrap symbols!");
578 return LDPS_ERR;
579 }
580 for (uint64_t i = 0; i < count; i++) {
581 StringRef Name = wrap_symbols[i];
582 ResolutionInfo &Res = ResInfo[Name];
583 ResolutionInfo &WrapRes = ResInfo["__wrap_" + Name.str()];
584 ResolutionInfo &RealRes = ResInfo["__real_" + Name.str()];
585 // Tell LTO not to inline symbols that will be overwritten.
586 Res.CanInline = false;
587 RealRes.CanInline = false;
588 // Tell LTO not to eliminate symbols that will be used after renaming.
589 Res.IsUsedInRegularObj = true;
590 WrapRes.IsUsedInRegularObj = true;
591 }
592 }
593
594565 return LDPS_OK;
595566 }
596567
713684 if (Resolution != LDPR_RESOLVED_DYN && Resolution != LDPR_UNDEF &&
714685 (IsExecutable || !Res.DefaultVisibility))
715686 R.FinalDefinitionInLinkageUnit = true;
716
717 if (!Res.CanInline)
718 R.LinkerRedefined = true;
719
720 if (Res.IsUsedInRegularObj)
721 R.VisibleToRegularObj = true;
722687
723688 freeSymName(Sym);
724689 }