[lld] r321149 - [COFF] Don't set the thumb bit in address table entries for data symbols

Martin Storsjo via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 19 22:50:45 PST 2017


Author: mstorsjo
Date: Tue Dec 19 22:50:45 2017
New Revision: 321149

URL: http://llvm.org/viewvc/llvm-project?rev=321149&view=rev
Log:
[COFF] Don't set the thumb bit in address table entries for data symbols

The thumb bit should only be set for executable code.

Differential Revision: https://reviews.llvm.org/D41379

Modified:
    lld/trunk/COFF/DLL.cpp
    lld/trunk/test/COFF/export-armnt.yaml

Modified: lld/trunk/COFF/DLL.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/DLL.cpp?rev=321149&r1=321148&r2=321149&view=diff
==============================================================================
--- lld/trunk/COFF/DLL.cpp (original)
+++ lld/trunk/COFF/DLL.cpp Tue Dec 19 22:50:45 2017
@@ -362,12 +362,12 @@ public:
   size_t getSize() const override { return Size * 4; }
 
   void writeTo(uint8_t *Buf) const override {
-    uint32_t Bit = 0;
-    // Pointer to thumb code must have the LSB set, so adjust it.
-    if (Config->Machine == ARMNT)
-      Bit = 1;
-    for (Export &E : Config->Exports) {
+    for (const Export &E : Config->Exports) {
       uint8_t *P = Buf + OutputSectionOff + E.Ordinal * 4;
+      uint32_t Bit = 0;
+      // Pointer to thumb code must have the LSB set, so adjust it.
+      if (Config->Machine == ARMNT && !E.Data)
+        Bit = 1;
       if (E.ForwardChunk) {
         write32le(P, E.ForwardChunk->getRVA() | Bit);
       } else {

Modified: lld/trunk/test/COFF/export-armnt.yaml
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/export-armnt.yaml?rev=321149&r1=321148&r2=321149&view=diff
==============================================================================
--- lld/trunk/test/COFF/export-armnt.yaml (original)
+++ lld/trunk/test/COFF/export-armnt.yaml Tue Dec 19 22:50:45 2017
@@ -2,16 +2,17 @@
 
 # RUN: yaml2obj < %s > %t.obj
 #
-# RUN: lld-link /out:%t.dll /dll %t.obj /export:exportfn1 /export:exportfn2
+# RUN: lld-link /out:%t.dll /dll %t.obj /export:exportfn1 /export:exportfn2 /export:exportdata,data
 # RUN: llvm-objdump -p %t.dll | FileCheck %s
 
 # CHECK:      Export Table:
 # CHECK:      DLL name: export-armnt.yaml.tmp.dll
 # CHECK:      Ordinal      RVA  Name
 # CHECK-NEXT:       0        0
-# CHECK-NEXT:       1   0x1005  exportfn1
-# CHECK-NEXT:       2   0x1009  exportfn2
-# CHECK-NEXT:       3   0x1009  exportfn3
+# CHECK-NEXT:       1   0x1000  exportdata
+# CHECK-NEXT:       2   0x2005  exportfn1
+# CHECK-NEXT:       3   0x2009  exportfn2
+# CHECK-NEXT:       4   0x2009  exportfn3
 
 --- !COFF
 header:
@@ -22,6 +23,10 @@ sections:
     Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
     Alignment:       4
     SectionData:     704700bf704700bf704700bf
+  - Name:            .data
+    Characteristics: [ IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ]
+    Alignment:       4
+    SectionData:     00000000
   - Name:            .drectve
     Characteristics: [ IMAGE_SCN_LNK_INFO, IMAGE_SCN_LNK_REMOVE ]
     Alignment:       1
@@ -39,6 +44,18 @@ symbols:
       NumberOfLinenumbers: 0
       CheckSum:        0
       Number:          0
+  - Name:            .data
+    Value:           0
+    SectionNumber:   2
+    SimpleType:      IMAGE_SYM_TYPE_NULL
+    ComplexType:     IMAGE_SYM_DTYPE_NULL
+    StorageClass:    IMAGE_SYM_CLASS_STATIC
+    SectionDefinition:
+      Length:          4
+      NumberOfRelocations: 0
+      NumberOfLinenumbers: 0
+      CheckSum:        0
+      Number:          0
   - Name:            _DllMainCRTStartup
     Value:           0
     SectionNumber:   1
@@ -63,6 +80,12 @@ symbols:
     SimpleType:      IMAGE_SYM_TYPE_NULL
     ComplexType:     IMAGE_SYM_DTYPE_NULL
     StorageClass:    IMAGE_SYM_CLASS_EXTERNAL
+  - Name:            exportdata
+    Value:           0
+    SectionNumber:   2
+    SimpleType:      IMAGE_SYM_TYPE_NULL
+    ComplexType:     IMAGE_SYM_DTYPE_NULL
+    StorageClass:    IMAGE_SYM_CLASS_EXTERNAL
   - Name:            '?mangled@@YAHXZ'
     Value:           8
     SectionNumber:   1




More information about the llvm-commits mailing list