[PATCH] D43193: [ELF] - Added testcase for testing visibility of weak_odr symbols.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 12 07:47:01 PST 2018
grimar created this revision.
grimar added reviewers: ruiu, espindola.
Herald added subscribers: arichardson, emaste.
This is relative to "Bug 36166 - tools/gold/X86/comdat.ll is failing only on Debian Unstable" (PR36166).
Something changed in newer versions of gold and now together with gold-plugin
there is an issue shown in PR, symbol may get wrong visibility.
LLD works fine, but we have no testcase for the same use case, and I
suggest to add it just in case to explicitly document the behavior.
https://reviews.llvm.org/D43193
Files:
test/ELF/lto/Inputs/weakodr-visibility.ll
test/ELF/lto/weakodr-visibility.ll
Index: test/ELF/lto/weakodr-visibility.ll
===================================================================
--- test/ELF/lto/weakodr-visibility.ll
+++ test/ELF/lto/weakodr-visibility.ll
@@ -0,0 +1,40 @@
+; REQUIRES: x86
+; RUN: llvm-as %s -o %t1.o
+; RUN: llvm-as %p/Inputs/weakodr-visibility.ll -o %t2.o
+
+; Testcase checks we keep desired visibility of weak
+; symbol in a library even if select different definition.
+; We change the order of input files in command line and
+; check that linker selects different symbol definitions,
+; but keeps `protected` visibility.
+
+; RUN: ld.lld %t1.o %t2.o -o %t.so -shared
+; RUN: llvm-readobj -t %t.so | FileCheck %s
+; RUN: llvm-objdump -d %t.so | FileCheck %s --check-prefix=FIRST
+; CHECK: Symbol {
+; CHECK: Name: foo
+; CHECK-NEXT: Value:
+; CHECK-NEXT: Size:
+; CHECK-NEXT: Binding: Weak
+; CHECK-NEXT: Type: Function
+; CHECK-NEXT: Other [
+; CHECK-NEXT: STV_PROTECTED
+; CHECK-NEXT: ]
+; CHECK-NEXT: Section:
+; CHECK-NEXT: }
+; FIRST: foo:
+; FIRST-NEXT: movl $41, %eax
+
+; Now swap the files order.
+; RUN: ld.lld %t2.o %t1.o -o %t.so -shared
+; RUN: llvm-readobj -t %t.so | FileCheck %s
+; RUN: llvm-objdump -d %t.so | FileCheck %s --check-prefix=SECOND
+; SECOND: foo:
+; SECOND-NEXT: movl $42, %eax
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define weak_odr i32 @foo(i8* %this) {
+ ret i32 41
+}
Index: test/ELF/lto/Inputs/weakodr-visibility.ll
===================================================================
--- test/ELF/lto/Inputs/weakodr-visibility.ll
+++ test/ELF/lto/Inputs/weakodr-visibility.ll
@@ -0,0 +1,6 @@
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define weak_odr protected i32 @foo(i8* %this) {
+ ret i32 42
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43193.133862.patch
Type: text/x-patch
Size: 1879 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180212/158e422a/attachment.bin>
More information about the llvm-commits
mailing list