forked from OSchip/llvm-project
[ELF] Remove OwningPtr from the Chunk::write interface.
llvm-svn: 173741
This commit is contained in:
parent
bdf8bc8315
commit
adfb7eb211
|
@ -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;
|
||||
|
||||
|
|
|
@ -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(Segment<ELFT> *segment) {
|
|||
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));
|
||||
|
@ -230,7 +227,7 @@ public:
|
|||
_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(Section<ELFT> *section) {
|
|||
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));
|
||||
|
|
|
@ -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 StringRef symname) {
|
|||
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));
|
||||
|
|
|
@ -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(uint64_t &addr) {
|
|||
}
|
||||
|
||||
// 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);
|
||||
|
|
|
@ -274,11 +274,11 @@ ELFExecutableWriter<ELFT>::writeFile(const lld::File &file, StringRef path) {
|
|||
// 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();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue