[test] Add test for section groups and deadstrip
authorShankar Easwaran <shankare@codeaurora.org>
Sun, 1 Feb 2015 05:47:02 +0000 (05:47 +0000)
committerShankar Easwaran <shankare@codeaurora.org>
Sun, 1 Feb 2015 05:47:02 +0000 (05:47 +0000)
This adds a test that deadstrip should preserve the section group even if there
is only one reference to a function in the group.

llvm-svn: 227711

lld/test/core/sectiongroup-deadstrip.objtxt [new file with mode: 0644]

diff --git a/lld/test/core/sectiongroup-deadstrip.objtxt b/lld/test/core/sectiongroup-deadstrip.objtxt
new file mode 100644 (file)
index 0000000..f6536c4
--- /dev/null
@@ -0,0 +1,92 @@
+# Test for section group members be preserved even if there is a
+# reference to only one functions in the group.
+# RUN: lld -core --dead-strip %s | FileCheck %s
+
+#
+# Test that section groups are parsed properly when there is a reference to a
+# group atom from outside a group.
+#
+
+---
+defined-atoms:
+  - name:         entry
+    dead-strip:   never
+    references:
+    - offset:          1
+      kind:            pcrel32
+      target:          d1
+  - name:            f1
+    scope:           global
+    type:            code
+  - name:            f2
+    scope:           global
+    type:            code
+  - name:            g1
+    scope:           global
+    type:            code
+  - name:            d1
+    scope:           global
+    type:            data
+  - name:            g1
+    scope:           global
+    type:            group-comdat
+    references:
+      - kind:            group-child
+        target:          f1
+      - kind:            group-child
+        target:          f2
+      - kind:            group-child
+        target:          d1
+      - kind:            group-child
+        target:          g1
+  - name:            anotherfunction
+    scope:           global
+    type:            data
+    references:
+      - kind:            layout-before
+        target:          f1
+---
+undefined-atoms:
+    - name:              f1
+      can-be-null:       never
+...
+
+#CHECK: defined-atoms:
+#CHECK:   - name:            g1
+#CHECK:     ref-name:        [[PARENT:[a-zA-Z\.0-9_]+]]
+#CHECK:     scope:           global
+#CHECK:     type:            group-comdat
+#CHECK:     references:
+#CHECK:       - kind:            group-child
+#CHECK:         offset:          0
+#CHECK:         target:          [[GCHILDONE:[a-zA-Z\.0-9_]+]]
+#CHECK:       - kind:            group-child
+#CHECK:         offset:          0
+#CHECK:         target:          [[GCHILDTWO:[a-zA-Z\.0-9_]+]]
+#CHECK:       - kind:            group-child
+#CHECK:         offset:          0
+#CHECK:         target:          [[GCHILDTHREE:[a-zA-Z\.0-9_]+]]
+#CHECK:       - kind:            group-child
+#CHECK:         offset:          0
+#CHECK:         target:          [[GCHILDFOUR:[a-zA-Z\.0-9_]+]]
+#CHECK:   - name:            f1
+#CHECK:     ref-name:        [[GCHILDONE]]
+#CHECK:     scope:           global
+#CHECK:   - name:            f2
+#CHECK:     ref-name:        [[GCHILDTWO]]
+#CHECK:     scope:           global
+#CHECK:   - name:            d1
+#CHECK:     ref-name:        [[GCHILDTHREE]]
+#CHECK:     scope:           global
+#CHECK:     type:            data
+#CHECK:   - name:            g1
+#CHECK:     ref-name:        [[GCHILDFOUR]]
+#CHECK:     scope:           global
+#CHECK:   - name:            anotherfunction
+#CHECK:     scope:           global
+#CHECK:     type:            data
+#CHECK:     references:
+#CHECK:       - kind:            layout-before
+#CHECK:         offset:          0
+#CHECK:         target:          [[GCHILDONE]]
+#CHECK: ...