[PATCH] D68441: Ignore --export-dynamic if --relocatable is given

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 3 20:58:12 PDT 2019


ruiu created this revision.
ruiu added reviewers: MaskRay, grimar.
Herald added subscribers: arichardson, emaste.
Herald added a reviewer: espindola.
Herald added a project: LLVM.

The combination of the two flags doesn't make sense, and other linkers
seem to just ignore --export-dynamic if --relocatable is given. This
patch makes lld compatible with that behavior.

Fixes https://bugs.llvm.org/show_bug.cgi?id=43552


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68441

Files:
  lld/ELF/Driver.cpp
  lld/test/ELF/relocatable-export-dynamic.s


Index: lld/test/ELF/relocatable-export-dynamic.s
===================================================================
--- /dev/null
+++ lld/test/ELF/relocatable-export-dynamic.s
@@ -0,0 +1,13 @@
+# REQUIRES: x86
+
+## If --relocatable is given, --export-dynamic should be ignored.
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1.o
+# RUN: ld.lld -o %t2.o %t1.o -r --export-dynamic
+# RUN: llvm-objdump --section-headers %t2.o | FileCheck %s
+
+# CHECK-NOT: .dynsym
+
+.global _start
+_start:
+  ret
Index: lld/ELF/Driver.cpp
===================================================================
--- lld/ELF/Driver.cpp
+++ lld/ELF/Driver.cpp
@@ -855,7 +855,8 @@
   config->executeOnly =
       args.hasFlag(OPT_execute_only, OPT_no_execute_only, false);
   config->exportDynamic =
-      args.hasFlag(OPT_export_dynamic, OPT_no_export_dynamic, false);
+      args.hasFlag(OPT_export_dynamic, OPT_no_export_dynamic, false) &&
+      !args.hasArg(OPT_relocatable);
   config->filterList = args::getStrings(args, OPT_filter);
   config->fini = args.getLastArgValue(OPT_fini, "_fini");
   config->fixCortexA53Errata843419 = args.hasArg(OPT_fix_cortex_a53_843419);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68441.223133.patch
Type: text/x-patch
Size: 1179 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191004/188dd407/attachment.bin>


More information about the llvm-commits mailing list