[PATCH] [lld] Atoms created from command line options should be available in YAML

Shankar Kalpathi Easwaran shankarke at gmail.com
Fri Aug 30 15:52:40 PDT 2013



================
Comment at: include/lld/ReaderWriter/PECOFFLinkingContext.h:128
@@ +127,3 @@
+  virtual void setEntrySymbolName(StringRef name) {
+    addInitialUndefinedSymbol(name);
+    LinkingContext::setEntrySymbolName(name);
----------------
kledzik at apple.com wrote:
> Why the call to addInitialUndefinedSymbol() here?  What happens if this is called again with a different name?  The old name would still be in the initialUndef list.  
> 
> If the undef is just needed for dead code stripping, the Resolver should always put the entrypoint in the root set of atoms to not dead strip.
Will remove this code. Thanks for noticing this.

================
Comment at: lib/Core/LinkingContext.cpp:55-72
@@ -52,1 +54,20 @@
 
+std::vector<std::unique_ptr<File>> LinkingContext::createInternalFiles() {
+  std::vector<std::unique_ptr<File> > result;
+  std::unique_ptr<SimpleFile> simpleFile(
+      new SimpleFile(*this, "command line option -u"));
+  for (auto ai : _initialUndefinedSymbols)
+    simpleFile->addAtom(
+        *(new (_allocator) SimpleUndefinedAtom(*simpleFile, ai)));
+  result.push_back(std::move(simpleFile));
+  StringRef entrySymbol = entrySymbolName();
+  if (!entrySymbol.empty()) {
+    std::unique_ptr<SimpleFile> entryFile(
+        new SimpleFile(*this, "command line option -entry"));
+    entryFile->addAtom(
+        *(new (_allocator) SimpleUndefinedAtom(*simpleFile, entrySymbol)));
+    result.push_back(std::move(entryFile));
+  }
+  return result;
+}
+
----------------
kledzik at apple.com wrote:
> Can this be broken up into separate methods so that a subclass could re-use parts of it?  For example, one method for making the -u file, and another for making the entry point reference.  
Yes, will do. Will make these methods protected. Makes it cleaner too.

================
Comment at: lib/ReaderWriter/ELF/ELFLinkingContext.cpp:173-190
@@ -159,1 +172,20 @@
 
+std::vector<std::unique_ptr<File> > ELFLinkingContext::createInternalFiles() {
+  std::vector<std::unique_ptr<File> > result;
+  std::unique_ptr<SimpleFile> simpleFile(
+      new SimpleFile(*this, "command line option -u"));
+  for (auto ai : _initialUndefinedSymbols)
+    simpleFile->addAtom(
+        *(new (_allocator) CommandLineUndefinedAtom(*simpleFile, ai)));
+  result.push_back(std::move(simpleFile));
+  StringRef entrySymbol = entrySymbolName();
+  if (!entrySymbol.empty()) {
+    std::unique_ptr<SimpleFile> entryFile(
+        new SimpleFile(*this, "command line option -entry"));
+    entryFile->addAtom(
+        *(new (_allocator) SimpleUndefinedAtom(*entryFile, entrySymbol)));
+    result.push_back(std::move(entryFile));
+  }
+  return result;
+}
+
----------------
kledzik at apple.com wrote:
> Once the base implementation of createInternalFiles() is modularized, parts can be re-used here.
Will do that.


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



More information about the llvm-commits mailing list