[Mips] Fix the bug -- symbol referred by the R_MIPS_TLS_GD relocation
authorSimon Atanasyan <simon@atanasyan.com>
Wed, 11 Jun 2014 10:08:08 +0000 (10:08 +0000)
committerSimon Atanasyan <simon@atanasyan.com>
Wed, 11 Jun 2014 10:08:08 +0000 (10:08 +0000)
does not get an entry in the dynamic symbol table.

llvm-svn: 210648

lld/lib/ReaderWriter/ELF/Mips/MipsSectionChunks.h
lld/test/elf/Mips/tls-5.test [new file with mode: 0644]

index 05c32b7..8b483b1 100644 (file)
@@ -68,7 +68,7 @@ public:
         return AtomSection<ELFType>::appendAtom(atom);
       case R_MIPS_TLS_DTPMOD32:
         _hasNonLocal = true;
-        return AtomSection<ELFType>::appendAtom(atom);
+        break;
       }
     }
 
diff --git a/lld/test/elf/Mips/tls-5.test b/lld/test/elf/Mips/tls-5.test
new file mode 100644 (file)
index 0000000..378ce32
--- /dev/null
@@ -0,0 +1,69 @@
+# Check that in case of an executable file linking symbol referred
+# by the R_MIPS_TLS_GD relocation gets an entry in the dynamic symbol table.
+
+# RUN: yaml2obj -format=elf -o %t-o.o %s
+# RUN: lld -flavor gnu -target mipsel -e T0 -o %t.exe %t-o.o
+
+# Check dynamic relocations:
+# RUN: llvm-readobj -r %t.exe | FileCheck -check-prefix=REL %s
+# Check dynamic symbol table:
+# RUN: llvm-readobj -dt %t.exe | FileCheck -check-prefix=SYM %s
+
+# REL:      Relocations [
+# REL-NEXT:   Section (5) .rel.dyn {
+# REL-NEXT:     0x402008 R_MIPS_TLS_DTPMOD32 T1 0x0
+# REL-NEXT:     0x40200C R_MIPS_TLS_DTPREL32 T1 0x0
+# REL-NEXT:   }
+# REL-NEXT: ]
+
+# SYM:      Symbol {
+# SYM:        Name: T1@ (1)
+# SYM-NEXT:   Value: 0x0
+# SYM-NEXT:   Size: 4
+# SYM-NEXT:   Binding: Global (0x1)
+# SYM-NEXT:   Type: TLS (0x6)
+# SYM-NEXT:   Other: 0
+# SYM-NEXT:   Section: .tdata (0x7)
+# SYM-NEXT: }
+
+---
+FileHeader:
+  Class:           ELFCLASS32
+  Data:            ELFDATA2LSB
+  Type:            ET_REL
+  Machine:         EM_MIPS
+  Flags:           [ EF_MIPS_NOREORDER, EF_MIPS_PIC, EF_MIPS_CPIC,
+                     EF_MIPS_ABI_O32, EF_MIPS_ARCH_32R2 ]
+Sections:
+  - Name:            .text
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
+    AddressAlign:    0x10
+    Size:            0x04
+  - Name:            .rel.text
+    Type:            SHT_REL
+    Link:            .symtab
+    AddressAlign:    0x04
+    Info:            .text
+    Relocations:
+      - Offset:          0x00
+        Symbol:          T1
+        Type:            R_MIPS_TLS_GD
+  - Name:            .tdata
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_WRITE, SHF_ALLOC, SHF_TLS ]
+    AddressAlign:    0x04
+    Size:            0x04
+
+Symbols:
+  Global:
+    - Name:            T0
+      Type:            STT_FUNC
+      Section:         .text
+      Size:            0x04
+    - Name:            T1
+      Type:            STT_TLS
+      Section:         .tdata
+      Value:           0x00
+      Size:            0x04
+...