[llvm-commits] [lld] r171711 - in /lld/trunk: lib/ReaderWriter/ELF/WriterELF.cpp test/elf/Inputs/constdata.x86-64 test/elf/rodata.test

Michael J. Spencer bigcheesegs at gmail.com
Mon Jan 7 00:00:43 PST 2013


Author: mspencer
Date: Mon Jan  7 02:00:42 2013
New Revision: 171711

URL: http://llvm.org/viewvc/llvm-project?rev=171711&view=rev
Log:
[ELF] Properly handle constant data.

With this hello world works with dietlibc on x86-64 Linux.

Added:
    lld/trunk/test/elf/Inputs/constdata.x86-64
    lld/trunk/test/elf/rodata.test
Modified:
    lld/trunk/lib/ReaderWriter/ELF/WriterELF.cpp

Modified: lld/trunk/lib/ReaderWriter/ELF/WriterELF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/WriterELF.cpp?rev=171711&r1=171710&r2=171711&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/WriterELF.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/WriterELF.cpp Mon Jan  7 02:00:42 2013
@@ -273,6 +273,7 @@
       switch(definedAtom->contentType()) {
       case  DefinedAtom::typeCode:
       case  DefinedAtom::typeData:
+      case  DefinedAtom::typeConstant:
         _atoms.push_back(std::make_pair(atom, std::make_pair(fOffset, 0)));
         this->_fsize = fOffset + definedAtom->size();
         this->_msize = mOffset + definedAtom->size();
@@ -456,6 +457,8 @@
     uint8_t *chunkBuffer = buffer->getBufferStart();
     for (auto &ai : _atoms) {
       const DefinedAtom *definedAtom = llvm::dyn_cast<DefinedAtom>(ai.first);
+      if (definedAtom->contentType() == DefinedAtom::typeZeroFill)
+        continue;
       // Copy raw content of atom to file buffer.
       ArrayRef<uint8_t> content = definedAtom->rawContent();
       uint64_t contentSize = content.size();
@@ -1067,6 +1070,7 @@
         type = ELF::STT_FUNC;
         break;
       case  DefinedAtom::typeData:
+      case  DefinedAtom::typeConstant:
         symbol->st_value = addr;
         type = ELF::STT_OBJECT;
         break;

Added: lld/trunk/test/elf/Inputs/constdata.x86-64
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/Inputs/constdata.x86-64?rev=171711&view=auto
==============================================================================
Binary files lld/trunk/test/elf/Inputs/constdata.x86-64 (added) and lld/trunk/test/elf/Inputs/constdata.x86-64 Mon Jan  7 02:00:42 2013 differ

Added: lld/trunk/test/elf/rodata.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/rodata.test?rev=171711&view=auto
==============================================================================
--- lld/trunk/test/elf/rodata.test (added)
+++ lld/trunk/test/elf/rodata.test Mon Jan  7 02:00:42 2013
@@ -0,0 +1,4 @@
+RUN: lld -flavor ld -target x86_64-linux -o %t %p/Inputs/constdata.x86-64
+RUN: llvm-objdump -s %t | FileCheck %s
+
+CHECK: Hellooooooooo





More information about the llvm-commits mailing list