[lld] r210648 - [Mips] Fix the bug -- symbol referred by the R_MIPS_TLS_GD relocation

Simon Atanasyan simon at atanasyan.com
Wed Jun 11 03:08:09 PDT 2014


Author: atanasyan
Date: Wed Jun 11 05:08:08 2014
New Revision: 210648

URL: http://llvm.org/viewvc/llvm-project?rev=210648&view=rev
Log:
[Mips] Fix the bug -- symbol referred by the R_MIPS_TLS_GD relocation
does not get an entry in the dynamic symbol table.

Added:
    lld/trunk/test/elf/Mips/tls-5.test
Modified:
    lld/trunk/lib/ReaderWriter/ELF/Mips/MipsSectionChunks.h

Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsSectionChunks.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsSectionChunks.h?rev=210648&r1=210647&r2=210648&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsSectionChunks.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsSectionChunks.h Wed Jun 11 05:08:08 2014
@@ -68,7 +68,7 @@ public:
         return AtomSection<ELFType>::appendAtom(atom);
       case R_MIPS_TLS_DTPMOD32:
         _hasNonLocal = true;
-        return AtomSection<ELFType>::appendAtom(atom);
+        break;
       }
     }
 

Added: lld/trunk/test/elf/Mips/tls-5.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/Mips/tls-5.test?rev=210648&view=auto
==============================================================================
--- lld/trunk/test/elf/Mips/tls-5.test (added)
+++ lld/trunk/test/elf/Mips/tls-5.test Wed Jun 11 05:08:08 2014
@@ -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
+...





More information about the llvm-commits mailing list