diff options
| -rw-r--r-- | lld/lib/ReaderWriter/ELF/WriterELF.cpp | 4 | ||||
| -rw-r--r-- | lld/test/elf/Inputs/constdata.x86-64 | bin | 0 -> 1688 bytes | |||
| -rw-r--r-- | lld/test/elf/rodata.test | 4 |
3 files changed, 8 insertions, 0 deletions
diff --git a/lld/lib/ReaderWriter/ELF/WriterELF.cpp b/lld/lib/ReaderWriter/ELF/WriterELF.cpp index b6e847ef4db..2973f0243e1 100644 --- a/lld/lib/ReaderWriter/ELF/WriterELF.cpp +++ b/lld/lib/ReaderWriter/ELF/WriterELF.cpp @@ -273,6 +273,7 @@ public: 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 @@ public: 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 @@ public: type = ELF::STT_FUNC; break; case DefinedAtom::typeData: + case DefinedAtom::typeConstant: symbol->st_value = addr; type = ELF::STT_OBJECT; break; diff --git a/lld/test/elf/Inputs/constdata.x86-64 b/lld/test/elf/Inputs/constdata.x86-64 Binary files differnew file mode 100644 index 00000000000..d877a553535 --- /dev/null +++ b/lld/test/elf/Inputs/constdata.x86-64 diff --git a/lld/test/elf/rodata.test b/lld/test/elf/rodata.test new file mode 100644 index 00000000000..afe9e1b4bf8 --- /dev/null +++ b/lld/test/elf/rodata.test @@ -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 |

