[lld] f736689 - [lld/mac] Support -data_in_code_info, -function_starts flags
Nico Weber via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 18 10:06:23 PDT 2021
Author: Nico Weber
Date: 2021-06-18T13:01:42-04:00
New Revision: f7366890c23f5be142a434879a3d42f46c4e4d92
URL: https://github.com/llvm/llvm-project/commit/f7366890c23f5be142a434879a3d42f46c4e4d92
DIFF: https://github.com/llvm/llvm-project/commit/f7366890c23f5be142a434879a3d42f46c4e4d92.diff
LOG: [lld/mac] Support -data_in_code_info, -function_starts flags
These are on by default, but there's also an explicit flag for them.
Differential Revision: https://reviews.llvm.org/D104543
Added:
Modified:
lld/MachO/Driver.cpp
lld/MachO/Options.td
lld/test/MachO/data-in-code.s
lld/test/MachO/function-starts.s
Removed:
################################################################################
diff --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp
index 81c9c7484ca4..aa8049ebeb6b 100644
--- a/lld/MachO/Driver.cpp
+++ b/lld/MachO/Driver.cpp
@@ -1073,9 +1073,11 @@ bool macho::link(ArrayRef<const char *> argsArr, bool canExitEarly,
config->deadStripDylibs = args.hasArg(OPT_dead_strip_dylibs);
config->demangle = args.hasArg(OPT_demangle);
config->implicitDylibs = !args.hasArg(OPT_no_implicit_dylibs);
- config->emitFunctionStarts = !args.hasArg(OPT_no_function_starts);
+ config->emitFunctionStarts =
+ args.hasFlag(OPT_function_starts, OPT_no_function_starts, true);
config->emitBitcodeBundle = args.hasArg(OPT_bitcode_bundle);
- config->emitDataInCodeInfo = !args.hasArg(OPT_no_data_in_code_info);
+ config->emitDataInCodeInfo =
+ args.hasFlag(OPT_data_in_code_info, OPT_no_data_in_code_info, true);
config->dedupLiterals = args.hasArg(OPT_deduplicate_literals);
// FIXME: Add a commandline flag for this too.
diff --git a/lld/MachO/Options.td b/lld/MachO/Options.td
index 60d9addc0360..b115f43594f3 100644
--- a/lld/MachO/Options.td
+++ b/lld/MachO/Options.td
@@ -904,7 +904,7 @@ def interposable_list : Separate<["-"], "interposable_list">,
Flags<[HelpHidden]>,
Group<grp_rare>;
def no_function_starts : Flag<["-"], "no_function_starts">,
- HelpText<"Do not create a table of function start addresses">,
+ HelpText<"Do not create table of function start addresses">,
Group<grp_rare>;
def no_objc_category_merging : Flag<["-"], "no_objc_category_merging">,
HelpText<"Do not merge Objective-C categories into their classes">,
@@ -1169,8 +1169,7 @@ def classic_linker : Flag<["-"], "classic_linker">,
Flags<[HelpHidden]>,
Group<grp_undocumented>;
def data_in_code_info : Flag<["-"], "data_in_code_info">,
- HelpText<"This option is undocumented in ld64">,
- Flags<[HelpHidden]>,
+ HelpText<"Emit data-in-code information (default)">,
Group<grp_undocumented>;
def no_data_in_code_info : Flag<["-"], "no_data_in_code_info">,
HelpText<"Do not emit data-in-code information">,
@@ -1228,8 +1227,7 @@ def force_symbol_weak : Flag<["-"], "force_symbol_weak">,
Flags<[HelpHidden]>,
Group<grp_undocumented>;
def function_starts : Flag<["-"], "function_starts">,
- HelpText<"This option is undocumented in ld64">,
- Flags<[HelpHidden]>,
+ HelpText<"Create table of function start addresses (default)">,
Group<grp_undocumented>;
def i : Flag<["-"], "i">,
HelpText<"This option is undocumented in ld64">,
diff --git a/lld/test/MachO/data-in-code.s b/lld/test/MachO/data-in-code.s
index fb4e24d809c5..49aa7655a84b 100644
--- a/lld/test/MachO/data-in-code.s
+++ b/lld/test/MachO/data-in-code.s
@@ -4,7 +4,7 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/foo.s -o %t/foo.o
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/bar.s -o %t/bar.o
-# RUN: %lld %t/foo.o %t/bar.o -o %t/main.exe
+# RUN: %lld -lSystem %t/foo.o %t/bar.o -o %t/main.exe
# RUN: llvm-otool -l %t/main.exe > %t/objdump
# RUN: llvm-objdump --macho --data-in-code %t/main.exe >> %t/objdump
# RUN: FileCheck %s < %t/objdump
@@ -25,11 +25,16 @@
# CHECK-NEXT: [[#%x,TEXT + 28]] 24 JUMP_TABLE32
# CHECK-NEXT: [[#%x,TEXT + 68]] 12 JUMP_TABLE32
-# RUN: %lld %t/foo.o %t/bar.o -no_data_in_code_info -o %t/main.exe
+# RUN: %lld -lSystem %t/foo.o %t/bar.o -no_data_in_code_info -o %t/main.exe
# RUN: llvm-otool -l %t/main.exe | FileCheck --check-prefix=OMIT %s
# OMIT-NOT: LC_DATA_IN_CODE
+# RUN: %lld -lSystem %t/foo.o %t/bar.o -no_data_in_code_info -data_in_code_info -o %t/main.exe
+# RUN: llvm-otool -l %t/main.exe > %t/objdump
+# RUN: llvm-objdump --macho --data-in-code %t/main.exe >> %t/objdump
+# RUN: FileCheck %s < %t/objdump
+
#--- foo.s
.text
.globl _main
diff --git a/lld/test/MachO/function-starts.s b/lld/test/MachO/function-starts.s
index 7026ca457dd4..d3e3f7cf9597 100644
--- a/lld/test/MachO/function-starts.s
+++ b/lld/test/MachO/function-starts.s
@@ -3,7 +3,7 @@
# RUN: rm -rf %t; split-file %s %t
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/basic.s -o %t/basic.o
-# RUN: %lld %t/basic.o -o %t/basic
+# RUN: %lld -lSystem %t/basic.o -o %t/basic
# RUN: llvm-objdump --syms %t/basic > %t/objdump
# RUN: llvm-objdump --macho --function-starts %t/basic >> %t/objdump
# RUN: FileCheck %s --check-prefix=BASIC < %t/objdump
@@ -18,7 +18,7 @@
# BASIC: [[#MAIN]]
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/alias.s -o %t/alias.o
-# RUN: %lld %t/alias.o -o %t/alias
+# RUN: %lld -lSystem %t/alias.o -o %t/alias
# RUN: llvm-objdump --syms %t/alias > %t/objdump
# RUN: llvm-objdump --macho --function-starts %t/alias >> %t/objdump
# RUN: FileCheck %s --check-prefix=ALIAS < %t/objdump
@@ -36,6 +36,11 @@
# NO-FUNCTION-STARTS: basic-no-function-starts:
# NO-FUNCTION-STARTS-EMPTY:
+# RUN: %lld -lSystem %t/basic.o -no_function_starts -function_starts -o %t/basic-explicit
+# RUN: llvm-objdump --syms %t/basic > %t/objdump
+# RUN: llvm-objdump --macho --function-starts %t/basic >> %t/objdump
+# RUN: FileCheck %s --check-prefix=BASIC < %t/objdump
+
#--- basic.s
.section __TEXT,__text,regular,pure_instructions
.globl _f1
More information about the llvm-commits
mailing list