[lld] r190302 - Handle _DYNAMIC correctly in the x86_64 backend.

Joerg Sonnenberger joerg at bec.de
Mon Sep 9 05:19:28 PDT 2013


Author: joerg
Date: Mon Sep  9 07:19:28 2013
New Revision: 190302

URL: http://llvm.org/viewvc/llvm-project?rev=190302&view=rev
Log:
Handle _DYNAMIC correctly in the x86_64 backend.

Modified:
    lld/trunk/lib/ReaderWriter/ELF/Atoms.h
    lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.cpp
    lld/trunk/test/elf/entry.objtxt

Modified: lld/trunk/lib/ReaderWriter/ELF/Atoms.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Atoms.h?rev=190302&r1=190301&r2=190302&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Atoms.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Atoms.h Mon Sep  9 07:19:28 2013
@@ -891,6 +891,31 @@ public:
   virtual ArrayRef<uint8_t> rawContent() const { return ArrayRef<uint8_t>(); }
 };
 
+class DYNAMICAtom : public SimpleDefinedAtom {
+public:
+  DYNAMICAtom(const File &f) : SimpleDefinedAtom(f) {}
+
+  virtual StringRef name() const { return "_DYNAMIC"; }
+
+  virtual Scope scope() const { return scopeLinkageUnit; }
+
+  virtual Merge merge() const { return mergeNo; }
+
+  virtual SectionChoice sectionChoice() const { return sectionCustomRequired; }
+
+  virtual StringRef customSectionName() const { return ".dynamic"; }
+
+  virtual ContentType contentType() const { return typeData; }
+
+  virtual uint64_t size() const { return 0; }
+
+  virtual ContentPermissions permissions() const { return permRW_; }
+
+  virtual Alignment alignment() const { return Alignment(0); }
+
+  virtual ArrayRef<uint8_t> rawContent() const { return ArrayRef<uint8_t>(); }
+};
+
 class InitFiniAtom : public SimpleDefinedAtom {
   StringRef _section;
 

Modified: lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.cpp?rev=190302&r1=190301&r2=190302&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.cpp Mon Sep  9 07:19:28 2013
@@ -21,5 +21,7 @@ X86_64TargetHandler::X86_64TargetHandler
 void X86_64TargetHandler::addFiles(InputFiles &f) {
   _gotFile.addAtom(*new (_gotFile._alloc) GLOBAL_OFFSET_TABLEAtom(_gotFile));
   _gotFile.addAtom(*new (_gotFile._alloc) TLSGETADDRAtom(_gotFile));
+  if (_context.isDynamic())
+    _gotFile.addAtom(*new (_gotFile._alloc) DYNAMICAtom(_gotFile));
   f.appendFile(_gotFile);
 }

Modified: lld/trunk/test/elf/entry.objtxt
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/entry.objtxt?rev=190302&r1=190301&r2=190302&view=diff
==============================================================================
--- lld/trunk/test/elf/entry.objtxt (original)
+++ lld/trunk/test/elf/entry.objtxt Mon Sep  9 07:19:28 2013
@@ -12,8 +12,9 @@
 # RUN: llvm-nm -n %t1 | FileCheck %s
 # 
 # CHECK:  004001b0 T main
-# CHECK:  00401000 A _end
-# CHECK:  00401000 A end
+# CHECK:  00401060 D _DYNAMIC
+# CHECK:  00401060 A _end
+# CHECK:  00401060 A end
 # CHECK:           U _entrypoint
 
 defined-atoms:   





More information about the llvm-commits mailing list