[PATCH] D112589: [lld-macho] If export_size is zero, export_off must be zero

Jez Ng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 26 18:34:35 PDT 2021


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

Otherwise tools like codesign_allocate will choke. We were already
handling this correctly for the other DYLD_INFO sections.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112589

Files:
  lld/MachO/SyntheticSections.h
  lld/test/MachO/no-unneeded-dyld-info.s


Index: lld/test/MachO/no-unneeded-dyld-info.s
===================================================================
--- lld/test/MachO/no-unneeded-dyld-info.s
+++ lld/test/MachO/no-unneeded-dyld-info.s
@@ -1,6 +1,6 @@
 # REQUIRES: x86
 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t.o
-# RUN: %lld -o %t %t.o
+# RUN: %lld -dylib -o %t %t.o
 # RUN: llvm-objdump --macho --all-headers %t | FileCheck %s
 
 # CHECK:                 cmd LC_DYLD_INFO_ONLY
@@ -13,7 +13,8 @@
 # CHECK-NEXT: weak_bind_size 0
 # CHECK-NEXT:  lazy_bind_off 0
 # CHECK-NEXT: lazy_bind_size 0
+# CHECK-NEXT: export_off     0
+# CHECK-NEXT: export_size    0
 
-.globl _main
-_main:
-  ret
+_not_exported:
+  .space 1
Index: lld/MachO/SyntheticSections.h
===================================================================
--- lld/MachO/SyntheticSections.h
+++ lld/MachO/SyntheticSections.h
@@ -345,6 +345,7 @@
   ExportSection();
   void finalizeContents() override;
   uint64_t getRawSize() const override { return size; }
+  bool isNeeded() const override { return size; }
   void writeTo(uint8_t *buf) const override;
 
   bool hasWeakSymbol = false;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112589.382501.patch
Type: text/x-patch
Size: 1142 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211027/ce6e42dd/attachment.bin>


More information about the llvm-commits mailing list