[PATCH] D39348: Implement --just-symbols.

Roland McGrath via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 26 17:23:12 PDT 2017


mcgrathr added a comment.

This doesn't implement the -R switch name, which is the traditional interface from time immemorial.  I can use --just-symbols, but you really should handle -R too.

Just copying symbol values will suffice for my case, but it's not really the right semantics.  The rest of the ElfNN_Sym fields matter too.

This crashes on my case.  I don't know what a trivial test case that would make it crash might look like, but I'll send you my actual case separately.



================
Comment at: lld/ELF/Driver.cpp:1065
 
+  // Handle a rarely-used, -just-symbols option.
+  //
----------------
--just-symbols (double dash), better known in traditional Unix as -R.


================
Comment at: lld/ELF/Driver.cpp:1068
+  // This option allows you to link your output against other existing
+  // programs, so that if you load both other program and your output
+  // to memory, your output can call other program's symbols.
----------------
s/programs/program/


================
Comment at: lld/ELF/InputFiles.cpp:1053
+// Reads defined symbols from a given ELF file, and returns their
+// names and values. This is used for -just-symbols.
+template <class ELFT>
----------------
--just-symbols (double dash)


================
Comment at: lld/ELF/InputFiles.cpp:1055
+template <class ELFT>
+std::vector<std::pair<StringRef, uint64_t>>
+elf::readSymbols(MemoryBufferRef MB) {
----------------
The canonical semantics are to copy all the other fields as well, not just st_value.
Only st_shndx is replaced with SHN_ABS.  The others are preserved (size, visibility, type, etc.).



================
Comment at: lld/ELF/InputFiles.h:62
 
+// For --just-symbol.
+template <class ELFT>
----------------
--just-symbols


================
Comment at: lld/ELF/Options.td:150
 
+defm just_symbols: Eq<"just-symbols">, HelpText<"Just link symbols">;
+
----------------
--just-symbols is the GNU long option for this, but -R is the original switch.
Since -R has been overloaded for --rpath, the GNU implementations examine the argument file for -R and treat it as --rpath if it's a directory and as --just-symbols if not.


https://reviews.llvm.org/D39348





More information about the llvm-commits mailing list