[lld] r173741 - [ELF] Remove OwningPtr from the Chunk::write interface.
Michael J. Spencer
bigcheesegs at gmail.com
Mon Jan 28 17:00:22 PST 2013
Author: mspencer
Date: Mon Jan 28 19:00:21 2013
New Revision: 173741
URL: http://llvm.org/viewvc/llvm-project?rev=173741&view=rev
Log:
[ELF] Remove OwningPtr from the Chunk::write interface.
Modified:
lld/trunk/lib/ReaderWriter/ELF/ELFChunk.h
lld/trunk/lib/ReaderWriter/ELF/ELFHeaderChunks.h
lld/trunk/lib/ReaderWriter/ELF/ELFSectionChunks.h
lld/trunk/lib/ReaderWriter/ELF/ELFSegmentChunks.h
lld/trunk/lib/ReaderWriter/ELF/WriterELF.cpp
Modified: lld/trunk/lib/ReaderWriter/ELF/ELFChunk.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ELFChunk.h?rev=173741&r1=173740&r2=173741&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ELFChunk.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ELFChunk.h Mon Jan 28 19:00:21 2013
@@ -76,8 +76,7 @@ public:
uint64_t memSize() const { return _msize; }
void setMemSize(uint64_t msize) { _msize = msize; }
// Writer the chunk
- virtual void write(ELFWriter *writer,
- llvm::OwningPtr<llvm::FileOutputBuffer> &buffer) = 0;
+ virtual void write(ELFWriter *writer, llvm::FileOutputBuffer &buffer) = 0;
// Finalize the chunk before writing
virtual void finalize() = 0;
Modified: lld/trunk/lib/ReaderWriter/ELF/ELFHeaderChunks.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ELFHeaderChunks.h?rev=173741&r1=173740&r2=173741&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ELFHeaderChunks.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ELFHeaderChunks.h Mon Jan 28 19:00:21 2013
@@ -52,7 +52,7 @@ public:
return c->Kind() == Chunk<ELFT>::K_ELFHeader;
}
- void write(ELFWriter *writer, llvm::OwningPtr<llvm::FileOutputBuffer> &buffer);
+ void write(ELFWriter *writer, llvm::FileOutputBuffer &buffer);
void finalize() { }
@@ -75,11 +75,9 @@ ELFHeader<ELFT>::ELFHeader()
e_flags(2);
}
-template<class ELFT>
-void
-ELFHeader<ELFT>::write(ELFWriter *writer,
- llvm::OwningPtr<llvm::FileOutputBuffer> &buffer) {
- uint8_t *chunkBuffer = buffer->getBufferStart();
+template <class ELFT>
+void ELFHeader<ELFT>::write(ELFWriter *writer, llvm::FileOutputBuffer &buffer) {
+ uint8_t *chunkBuffer = buffer.getBufferStart();
uint8_t *atomContent = chunkBuffer + this->fileOffset();
memcpy(atomContent, &_eh, fileSize());
}
@@ -133,7 +131,7 @@ public:
return c->Kind() == Chunk<ELFT>::K_ELFProgramHeader;
}
- void write(ELFWriter *writer, llvm::OwningPtr<llvm::FileOutputBuffer> &buffer);
+ void write(ELFWriter *writer, llvm::FileOutputBuffer &buffer);
/// \brief find a program header entry in the list of program headers
PhIterT findProgramHeader(uint64_t type, uint64_t flags, uint64_t flagClear) {
@@ -197,11 +195,10 @@ ELFProgramHeader<ELFT>::addSegment(Segme
return ret;
}
-template<class ELFT>
-void
-ELFProgramHeader<ELFT>::write(ELFWriter *writer,
- llvm::OwningPtr<llvm::FileOutputBuffer> &buffer) {
- uint8_t *chunkBuffer = buffer->getBufferStart();
+template <class ELFT>
+void ELFProgramHeader<ELFT>::write(ELFWriter *writer,
+ llvm::FileOutputBuffer &buffer) {
+ uint8_t *chunkBuffer = buffer.getBufferStart();
uint8_t *dest = chunkBuffer + this->fileOffset();
for (auto phi : _ph) {
memcpy(dest, phi, sizeof(Elf_Phdr));
@@ -229,8 +226,8 @@ public:
void setStringSection(ELFStringTable<ELFT> *s) {
_stringSection = s;
}
-
- void write(ELFWriter *writer, llvm::OwningPtr<llvm::FileOutputBuffer> &buffer);
+
+ void write(ELFWriter *writer, llvm::FileOutputBuffer &buffer);
void finalize() { }
@@ -297,11 +294,10 @@ ELFSectionHeader<ELFT>::updateSection(Se
shdr->sh_entsize = section->entsize();
}
-template<class ELFT>
-void
-ELFSectionHeader<ELFT>::write(ELFWriter *writer,
- llvm::OwningPtr<llvm::FileOutputBuffer> &buffer) {
- uint8_t *chunkBuffer = buffer->getBufferStart();
+template <class ELFT>
+void ELFSectionHeader<ELFT>::write(ELFWriter *writer,
+ llvm::FileOutputBuffer &buffer) {
+ uint8_t *chunkBuffer = buffer.getBufferStart();
uint8_t *dest = chunkBuffer + this->fileOffset();
for (auto shi : _sectionInfo) {
memcpy(dest, shi, sizeof(Elf_Shdr));
Modified: lld/trunk/lib/ReaderWriter/ELF/ELFSectionChunks.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ELFSectionChunks.h?rev=173741&r1=173740&r2=173741&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ELFSectionChunks.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ELFSectionChunks.h Mon Jan 28 19:00:21 2013
@@ -159,8 +159,7 @@ public:
inline void finalize() { }
/// \brief Write the section and the atom contents to the buffer
- void write(ELFWriter *writer,
- llvm::OwningPtr<llvm::FileOutputBuffer> &buffer);
+ void write(ELFWriter *writer, llvm::FileOutputBuffer &buffer);
/// Atom Iterators
typedef typename std::vector<AtomLayout>::iterator atom_iter;
@@ -336,11 +335,9 @@ Section<ELFT>::segmentKindToStr() const
}
/// \brief Write the section and the atom contents to the buffer
-template<class ELFT>
-void
-Section<ELFT>::write(ELFWriter *writer,
- llvm::OwningPtr<llvm::FileOutputBuffer> &buffer) {
- uint8_t *chunkBuffer = buffer->getBufferStart();
+template <class ELFT>
+void Section<ELFT>::write(ELFWriter *writer, llvm::FileOutputBuffer &buffer) {
+ uint8_t *chunkBuffer = buffer.getBufferStart();
for (auto &ai : _atoms) {
const DefinedAtom *definedAtom = cast<DefinedAtom>(ai._atom);
if (definedAtom->contentType() == DefinedAtom::typeZeroFill)
@@ -509,8 +506,7 @@ public:
uint64_t addString(const llvm::StringRef symname);
- void write(ELFWriter *writer,
- llvm::OwningPtr<llvm::FileOutputBuffer> &buffer);
+ void write(ELFWriter *writer, llvm::FileOutputBuffer &buffer);
inline void finalize() { }
@@ -544,11 +540,10 @@ ELFStringTable<ELFT>::addString(const St
return offset;
}
-template<class ELFT>
-void
-ELFStringTable<ELFT>::write(ELFWriter *writer,
- llvm::OwningPtr<llvm::FileOutputBuffer> &buffer) {
- uint8_t *chunkBuffer = buffer->getBufferStart();
+template <class ELFT>
+void ELFStringTable<ELFT>::write(ELFWriter *writer,
+ llvm::FileOutputBuffer &buffer) {
+ uint8_t *chunkBuffer = buffer.getBufferStart();
uint8_t *dest = chunkBuffer + this->fileOffset();
for (auto si : _strings) {
memcpy(dest, si.data(), si.size());
@@ -570,8 +565,7 @@ public:
void finalize();
- void write(ELFWriter *writer,
- llvm::OwningPtr<llvm::FileOutputBuffer> &buffer);
+ void write(ELFWriter *writer, llvm::FileOutputBuffer &buffer);
static inline bool classof(const Chunk<ELFT> *c) {
return c->kind() == Section<ELFT>::K_SymbolTable;
@@ -688,11 +682,10 @@ ELFSymbolTable<ELFT>::finalize() {
this->setLink(_stringSection->ordinal());
}
-template<class ELFT>
-void
-ELFSymbolTable<ELFT>::write(ELFWriter *writer,
- llvm::OwningPtr<llvm::FileOutputBuffer> &buffer) {
- uint8_t *chunkBuffer = buffer->getBufferStart();
+template <class ELFT>
+void ELFSymbolTable<ELFT>::write(ELFWriter *writer,
+ llvm::FileOutputBuffer &buffer) {
+ uint8_t *chunkBuffer = buffer.getBufferStart();
uint8_t *dest = chunkBuffer + this->fileOffset();
for (auto sti : _symbolTable) {
memcpy(dest, sti, sizeof(Elf_Sym));
Modified: lld/trunk/lib/ReaderWriter/ELF/ELFSegmentChunks.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ELFSegmentChunks.h?rev=173741&r1=173740&r2=173741&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ELFSegmentChunks.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ELFSegmentChunks.h Mon Jan 28 19:00:21 2013
@@ -144,7 +144,7 @@ public:
void assignVirtualAddress(uint64_t &addr);
// Write the Segment
- void write(ELFWriter *writer, OwningPtr<llvm::FileOutputBuffer> &buffer);
+ void write(ELFWriter *writer, llvm::FileOutputBuffer &buffer);
int64_t flags() const;
@@ -356,9 +356,8 @@ Segment<ELFT>::assignVirtualAddress(uint
}
// Write the Segment
-template<class ELFT>
-void
-Segment<ELFT>::write(ELFWriter *writer, OwningPtr<llvm::FileOutputBuffer> &buffer) {
+template <class ELFT>
+void Segment<ELFT>::write(ELFWriter *writer, llvm::FileOutputBuffer &buffer) {
for (auto slice : slices())
for (auto section : slice->sections())
section->write(writer, buffer);
Modified: lld/trunk/lib/ReaderWriter/ELF/WriterELF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/WriterELF.cpp?rev=173741&r1=173740&r2=173741&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/WriterELF.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/WriterELF.cpp Mon Jan 28 19:00:21 2013
@@ -274,11 +274,11 @@ ELFExecutableWriter<ELFT>::writeFile(con
// HACK: We have to write out the header and program header here even though
// they are a member of a segment because only sections are written in the
// following loop.
- _elfHeader->write(this, buffer);
- _programHeader->write(this, buffer);
+ _elfHeader->write(this, *buffer);
+ _programHeader->write(this, *buffer);
for (auto section : _layout->sections())
- section->write(this, buffer);
+ section->write(this, *buffer);
return buffer->commit();
}
More information about the llvm-commits
mailing list