[PATCH] [lld][ELF] Add undefined symbol option to lld

Rui Ueyama ruiu at google.com
Mon Jun 17 22:14:13 PDT 2013



================
Comment at: include/lld/ReaderWriter/ELFTargetInfo.h:200
@@ -182,2 +199,3 @@
   StringRef                          _dynamicLinkerPath;
+  StringRefVector _undefinedSymbols;
 };
----------------
Align horizontally. That's probably not LLVM coding style but local consistency is more important than that, I think (unless we fix all the above style).

================
Comment at: lib/Driver/LDOptions.td:77
@@ +76,3 @@
+    HelpText<"Force symbol to be entered in the output file as an undefined symbol">;
+def u_alias : Joined<["--"], "undefined=">, Alias<u>;
+
----------------
Looks like GNU accepts all the following flags:

 1. -u foo
 2. -u=foo
 3. --undefined foo
 4. --undefined=foo

I think with this patch lld will accept only case 1 and 4. Does the LLVM command option handler the capability to handle all these cases?

================
Comment at: lib/ReaderWriter/ELF/ExecutableWriter.h:66
@@ -65,2 +65,3 @@
 template <class ELFT>
 void ExecutableWriter<ELFT>::addFiles(InputFiles &inputFiles) {
+  // Add the default atoms as defined by executables
----------------
Make this a virtual method?

================
Comment at: lib/ReaderWriter/ELF/OutputELFWriter.h:237
@@ -225,3 +236,3 @@
 
-template<class ELFT>
-void OutputELFWriter<ELFT>::createDefaultSections() {
+template <class ELFT>
+void OutputELFWriter<ELFT>::addFiles(InputFiles &inputFiles) {
----------------
virtual?

================
Comment at: test/elf/X86_64/undef.test:4
@@ +3,3 @@
+# which is usually the usecase for it
+RUN: lld -flavor gnu -target x86_64 -u fn %p/Inputs/libfn.a -o %t --noinhibit-exec
+RUN: llvm-readobj -symbols %t | FileCheck -check-prefix=SYMFROMARCHIVE %s
----------------
Could you write a test using the same command line options except "-u fn", to verify that "fn" will not be emit in that case?


http://llvm-reviews.chandlerc.com/D997



More information about the llvm-commits mailing list