[lld] 928a197 - [ELF] Add a GRP_COMDAT test with a local signature symbol

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 8 09:22:36 PDT 2021


Author: Fangrui Song
Date: 2021-06-08T09:22:30-07:00
New Revision: 928a197d26ffd035bc4279ba533f169190a03574

URL: https://github.com/llvm/llvm-project/commit/928a197d26ffd035bc4279ba533f169190a03574
DIFF: https://github.com/llvm/llvm-project/commit/928a197d26ffd035bc4279ba533f169190a03574.diff

LOG: [ELF] Add a GRP_COMDAT test with a local signature symbol

See https://groups.google.com/g/generic-abi/c/2X6mR-s2zoc

Test that a local signature symbol does not suppress COMDAT deduplication.

Added: 
    lld/test/ELF/comdat-local-signature.s

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/lld/test/ELF/comdat-local-signature.s b/lld/test/ELF/comdat-local-signature.s
new file mode 100644
index 0000000000000..eed92ca9d7a65
--- /dev/null
+++ b/lld/test/ELF/comdat-local-signature.s
@@ -0,0 +1,30 @@
+# REQUIRES: x86
+## COMDAT groups are deduplicated by the name of the signature symbol.
+## The local/global status is not part of the equation.
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
+# RUN: ld.lld %t.o %t.o -o %t
+# RUN: llvm-readelf -s -x .zero -x .comdat %t | FileCheck %s
+
+# CHECK:      Type   Bind  Vis     Ndx     Name
+# CHECK-NEXT: NOTYPE LOCAL DEFAULT UND
+# CHECK-NEXT: NOTYPE LOCAL DEFAULT [[#A:]] zero
+# CHECK-NEXT: NOTYPE LOCAL DEFAULT [[#]]   comdat
+# CHECK-NEXT: NOTYPE LOCAL DEFAULT [[#A]]  zero
+# CHECK-NOT:  {{.}}
+
+## Non-GRP_COMDAT groups are never deduplicated.
+# CHECK:      Hex dump of section '.zero':
+# CHECK-NEXT: [[#%x,]] 0202
+
+## GRP_COMDAT groups are deduplicated.
+# CHECK:      Hex dump of section '.comdat':
+# CHECK-NEXT: [[#%x,]] 01 .{{$}}
+
+.section .zero,"aG", at progbits,zero
+zero:
+  .byte 2
+
+.section .comdat,"aG", at progbits,comdat,comdat
+comdat:
+  .byte 1


        


More information about the llvm-commits mailing list