[PATCH] D86642: [lld-macho] Support GOT relocations to __dso_handle

Jez Ng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 26 10:05:35 PDT 2020


int3 created this revision.
int3 added a reviewer: lld-macho.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
int3 requested review of this revision.

Found such a relocation while testing some real world programs.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86642

Files:
  lld/MachO/Symbols.h
  lld/test/MachO/dso-handle.s


Index: lld/test/MachO/dso-handle.s
===================================================================
--- lld/test/MachO/dso-handle.s
+++ lld/test/MachO/dso-handle.s
@@ -3,14 +3,17 @@
 
 # RUN: lld -flavor darwinnew %t.o -o %t
 # RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s
-# CHECK: leaq {{.*}} # 100000000
+# CHECK:      leaq {{.*}} # 100000000
+# CHECK-NEXT: leaq {{.*}} # 100000000
 
 # RUN: lld -flavor darwinnew -dylib %t.o -o %t.dylib
 # RUN: llvm-objdump -d --no-show-raw-insn %t.dylib | FileCheck %s --check-prefix=DYLIB-CHECK
-# DYLIB-CHECK: leaq {{.*}} # 0
+# DYLIB-CHECK:      leaq {{.*}} # 0
+# DYLIB-CHECK-NEXT: leaq {{.*}} # 0
 
 .globl _main
 .text
 _main:
   leaq ___dso_handle(%rip), %rdx
+  movq ___dso_handle at GOTPCREL(%rip), %rdx
   ret
Index: lld/MachO/Symbols.h
===================================================================
--- lld/MachO/Symbols.h
+++ lld/MachO/Symbols.h
@@ -167,9 +167,13 @@
 
   uint64_t getFileOffset() const override;
 
+  bool isWeakDef() const override { return false; }
+
+  bool isTlv() const override { return false; }
+
   static constexpr StringRef name = "___dso_handle";
 
-  static bool classof(const Symbol *s) { return s->kind() == DefinedKind; }
+  static bool classof(const Symbol *s) { return s->kind() == DSOHandleKind; }
 };
 
 union SymbolUnion {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86642.288022.patch
Type: text/x-patch
Size: 1329 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200826/4db0b232/attachment.bin>


More information about the llvm-commits mailing list