[lld] r335351 - [ELF] - ICF: Add 2 more test cases.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 22 07:29:22 PDT 2018


Author: grimar
Date: Fri Jun 22 07:29:22 2018
New Revision: 335351

URL: http://llvm.org/viewvc/llvm-project?rev=335351&view=rev
Log:
[ELF] - ICF: Add 2 more test cases.

These test cases covers the following condition:
https://github.com/llvm-mirror/lld/blob/master/ELF/ICF.cpp#L243

It was uncovered by our tests. I was able to delete the whole `if`
and no test failed.

Added:
    lld/trunk/test/ELF/icf10.test
    lld/trunk/test/ELF/icf11.test

Added: lld/trunk/test/ELF/icf10.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/icf10.test?rev=335351&view=auto
==============================================================================
--- lld/trunk/test/ELF/icf10.test (added)
+++ lld/trunk/test/ELF/icf10.test Fri Jun 22 07:29:22 2018
@@ -0,0 +1,40 @@
+# RUN: yaml2obj %s -o %t.o
+# RUN: ld.lld --icf=all %t.o -o %t --print-icf-sections 2>&1 | FileCheck %s
+
+# Checks that ICF does not merge 2 sections the offset of
+# the relocations of which differ.
+
+# CHECK-NOT: selected
+
+!ELF
+FileHeader:
+  Class:           ELFCLASS64
+  Data:            ELFDATA2LSB
+  OSABI:           ELFOSABI_FREEBSD
+  Type:            ET_REL
+  Machine:         EM_X86_64
+Sections:
+  - Name:            .text.foo
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_ALLOC, SHF_EXECINSTR]
+    Content:         "FFFFFFFFFFFFFFFF"
+  - Name:            .text.bar
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_ALLOC, SHF_EXECINSTR]
+    Content:         "FFFFFFFFFFFFFFFF"
+  - Name:            .rela.text.foo
+    Type:            SHT_RELA
+    Link:            .symtab
+    Info:            .text.foo
+    Relocations:
+      - Offset:          0x0000000000000000
+        Symbol:          ''
+        Type:            R_X86_64_NONE
+  - Name:            .rela.text.bar
+    Type:            SHT_RELA
+    Link:            .symtab
+    Info:            .text.bar
+    Relocations:
+      - Offset:          0x0000000000000001
+        Symbol:          ''
+        Type:            R_X86_64_NONE

Added: lld/trunk/test/ELF/icf11.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/icf11.test?rev=335351&view=auto
==============================================================================
--- lld/trunk/test/ELF/icf11.test (added)
+++ lld/trunk/test/ELF/icf11.test Fri Jun 22 07:29:22 2018
@@ -0,0 +1,52 @@
+# RUN: yaml2obj %s -o %t.o
+# RUN: ld.lld --icf=all %t.o -o %t --print-icf-sections 2>&1 | FileCheck %s
+
+# Checks that ICF does not merge 2 sections the type of
+# the relocations of which differ.
+
+# CHECK-NOT: selected
+
+!ELF
+FileHeader:
+  Class:           ELFCLASS64
+  Data:            ELFDATA2LSB
+  OSABI:           ELFOSABI_FREEBSD
+  Type:            ET_REL
+  Machine:         EM_X86_64
+Sections:
+  - Type:            SHT_PROGBITS
+    Name:            .text
+    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
+    AddressAlign:    0x04
+    Content:         "0000000000000000"
+  - Name:            .text.foo
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_ALLOC, SHF_EXECINSTR]
+    Content:         "FFFFFFFFFFFFFFFF"
+  - Name:            .text.bar
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_ALLOC, SHF_EXECINSTR]
+    Content:         "FFFFFFFFFFFFFFFF"
+  - Name:            .rela.text.foo
+    Type:            SHT_RELA
+    Link:            .symtab
+    Info:            .text.foo
+    Relocations:
+      - Offset:          0x0000000000000000
+        Symbol:          ''
+        Type:            R_X86_64_NONE
+  - Name:            .rela.text.bar
+    Type:            SHT_RELA
+    Link:            .symtab
+    Info:            .text.bar
+    Relocations:
+      - Offset:          0
+        Symbol:          zed
+        Type:            R_X86_64_64
+Symbols:
+  Global:
+    - Name:     zed
+      Type:     STT_FUNC
+      Section:  .text
+      Value:    0x0
+      Size:     8




More information about the llvm-commits mailing list