[PATCH] D16009: [lld]Non-MachO references shouldn't assert when checking for TLV.

Jim Grosbach via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 8 12:43:06 PST 2016


grosbach created this revision.
grosbach added reviewers: lhames, pete.
grosbach added a subscriber: llvm-commits.
grosbach set the repository for this revision to rL LLVM.
grosbach added a project: lld.

    Early exit identified as not being a TLV access is correct. In particular
    the 'all' namespace is completely valid here for things like layout-after
    references.

Repository:
  rL LLVM

http://reviews.llvm.org/D16009

Files:
  lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp
  test/mach-o/tlv-refkind.yaml

Index: test/mach-o/tlv-refkind.yaml
===================================================================
--- /dev/null
+++ test/mach-o/tlv-refkind.yaml
@@ -0,0 +1,56 @@
+# RUN: lld -flavor darwin -arch x86_64  %s %p/Inputs/libSystem.yaml \
+# RUN: -o %t
+# RUN: llvm-nm -m -n %t | FileCheck %s
+#
+#
+# Test that x86_64 checking for TLV on local symbols properly accounts for
+# references not in the mach_o:: namespace. Specifically in this case,
+# all::layout_after references.
+#
+--- !mach-o
+arch:            x86_64
+file-type:       MH_OBJECT
+flags:           [  ]
+compat-version:  0.0
+current-version: 0.0
+has-UUID:        false
+OS:              unknown
+sections:
+  - segment:         __TEXT
+    section:         __text
+    type:            S_REGULAR
+    attributes:      [ S_ATTR_PURE_INSTRUCTIONS, S_ATTR_SOME_INSTRUCTIONS ]
+    address:         0x0000000000000000
+    content:         [ 0xC3 ]
+  - segment:         __DATA
+    section:         __data
+    type:            S_REGULAR
+    attributes:      [  ]
+    address:         0x0000000000000001
+    content:         [ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00 ]
+local-symbols:
+  - name:            l.blah
+    type:            N_SECT
+    sect:            2
+    value:           0x0000000000000001
+  - name:            l.blaz
+    type:            N_SECT
+    sect:            2
+    value:           0x0000000000000005
+global-symbols:
+  - name:            _foo
+    type:            N_SECT
+    scope:           [ N_EXT ]
+    sect:            2
+    value:           0x0000000000000001
+  - name:            _main
+    type:            N_SECT
+    scope:           [ N_EXT ]
+    sect:            1
+    value:           0x0000000000000000
+page-size:       0x00000000
+...
+
+
+# CHECK: (undefined) external dyld_stub_binder (from libSystem)
+# CHECK-NEXT: external _main
Index: lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp
===================================================================
--- lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp
+++ lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp
@@ -60,7 +60,8 @@
   }
 
   bool isTLVAccess(const Reference &ref) const override {
-    assert(ref.kindNamespace() == Reference::KindNamespace::mach_o);
+    if (ref.kindNamespace() != Reference::KindNamespace::mach_o)
+      return false;
     assert(ref.kindArch() == Reference::KindArch::x86_64);
     return ref.kindValue() == ripRel32Tlv;
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16009.44365.patch
Type: text/x-patch
Size: 2437 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160108/caeb2a0e/attachment.bin>


More information about the llvm-commits mailing list