[lld] r255085 - Don't bypass the GOT for delta32toGOT references.

Pete Cooper via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 8 16:46:02 PST 2015


Author: pete
Date: Tue Dec  8 18:46:02 2015
New Revision: 255085

URL: http://llvm.org/viewvc/llvm-project?rev=255085&view=rev
Log:
Don't bypass the GOT for delta32toGOT references.

The gcc_except_tab was generating these references to point to the typeinfo in the data section.

gcc_except_tab also had the DW_EH_PE_indirect flag set which means that at runtime we are going
to dereference this entry as if it is in the GOT.

Reviewed by Nick Kledzik in http://reviews.llvm.org/D15360.

Added:
    lld/trunk/test/mach-o/gcc_except_tab-got-arm64.yaml
Modified:
    lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp
    lld/trunk/test/mach-o/unwind-info-simple-arm64.yaml

Modified: lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp?rev=255085&r1=255084&r2=255085&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp Tue Dec  8 18:46:02 2015
@@ -50,6 +50,9 @@ public:
     case gotOffset12:
       canBypassGOT = true;
       return true;
+    case delta32ToGOT:
+      canBypassGOT = false;
+      return true;
     case imageOffsetGot:
       canBypassGOT = false;
       return true;
@@ -74,6 +77,9 @@ public:
       const_cast<Reference *>(ref)->setKindValue(targetNowGOT ?
                                                  offset12scale8 : addOffset12);
       break;
+    case delta32ToGOT:
+      const_cast<Reference *>(ref)->setKindValue(delta32);
+      break;
     case imageOffsetGot:
       const_cast<Reference *>(ref)->setKindValue(imageOffset);
       break;

Added: lld/trunk/test/mach-o/gcc_except_tab-got-arm64.yaml
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/mach-o/gcc_except_tab-got-arm64.yaml?rev=255085&view=auto
==============================================================================
--- lld/trunk/test/mach-o/gcc_except_tab-got-arm64.yaml (added)
+++ lld/trunk/test/mach-o/gcc_except_tab-got-arm64.yaml Tue Dec  8 18:46:02 2015
@@ -0,0 +1,53 @@
+# RUN: lld -flavor darwin -arch arm64 %s \
+# RUN: -dylib %p/Inputs/libSystem.yaml -o %t
+# RUN: llvm-objdump -section-headers %t | FileCheck %s
+
+# Make sure that the GOT relocation from gcc_except_tab to the data
+# is not removed.
+
+--- !native
+defined-atoms:   
+  - name:            _main
+    scope:           global
+    content:         [ FD, 7B, BF, A9, FD, 03, 00, 91, FF, 43, 00, D1, 
+                       BF, C3, 1F, B8, 00, 00, 00, 94, BF, 03, 00, 91, 
+                       FD, 7B, C1, A8, C0, 03, 5F, D6 ]
+    alignment:       4
+  - name:            __ZTSP1A
+    scope:           hidden
+    type:            constant
+    content:         [ 50, 31, 41, 00 ]
+    merge:           as-weak
+  - name:            GCC_except_table0
+    type:            unwind-lsda
+    content:         [ FF, 9B, E7, 80, 00, 03, 5B, 00, 00, 00, 00, 1C, 
+                       00, 00, 00, 00, 00, 00, 00, 00, 1C, 00, 00, 00, 
+                       18, 00, 00, 00, 84, 00, 00, 00, 03, 40, 00, 00, 
+                       00, 10, 00, 00, 00, 94, 00, 00, 00, 03, 60, 00, 
+                       00, 00, 20, 00, 00, 00, B4, 00, 00, 00, 05, 80, 
+                       00, 00, 00, 68, 00, 00, 00, 00, 00, 00, 00, 00, 
+                       E8, 00, 00, 00, 08, 00, 00, 00, 28, 01, 00, 00, 
+                       00, F0, 00, 00, 00, 74, 00, 00, 00, 00, 00, 00, 
+                       00, 00, 00, 00, 01, 7D, 01, 00, A8, FF, FF, FF ]
+    alignment:       4
+    references:      
+      - kind:            delta32ToGOT
+        offset:          104
+        target:          __ZTIP1A
+  - name:            __ZTIP1A
+    scope:           hidden
+    type:            data
+    content:         [ 10, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 
+                       00, 00, 00, 80, 00, 00, 00, 00, 00, 00, 00, 00, 
+                       00, 00, 00, 00, 00, 00, 00, 00 ]
+    merge:           as-weak
+    alignment:       16
+shared-library-atoms:
+  - name:            dyld_stub_binder
+    load-name:       /usr/lib/libSystem.B.dylib
+    type:            unknown
+...
+
+# Make sure we have a GOT relocation.
+# This could only have come from __gcc_except_tab to __ZTIP1A
+# CHECK: __got
\ No newline at end of file

Modified: lld/trunk/test/mach-o/unwind-info-simple-arm64.yaml
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/mach-o/unwind-info-simple-arm64.yaml?rev=255085&r1=255084&r2=255085&view=diff
==============================================================================
--- lld/trunk/test/mach-o/unwind-info-simple-arm64.yaml (original)
+++ lld/trunk/test/mach-o/unwind-info-simple-arm64.yaml Tue Dec  8 18:46:02 2015
@@ -250,7 +250,7 @@ undefined-symbols:
 # CHECK:   Number of indices in array:                0x2
 # CHECK:   Common encodings: (count = 0)
 # CHECK:   Personality functions: (count = 1)
-# CHECK:     personality[1]: 0x00004018
+# CHECK:     personality[1]: 0x00004020
 # CHECK:   Top level indices: (count = 2)
 # CHECK:     [0]: function offset=0x00003e68, 2nd level page offset=0x00000040, LSDA offset=0x00000038
 # CHECK:     [1]: function offset=0x00003edc, 2nd level page offset=0x00000000, LSDA offset=0x00000040




More information about the llvm-commits mailing list