summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-objcopy/Object.cpp
diff options
context:
space:
mode:
authorJake Ehrlich <jakehehrlich@google.com>2017-12-19 00:47:30 +0000
committerJake Ehrlich <jakehehrlich@google.com>2017-12-19 00:47:30 +0000
commite8437de727ed208cc4a8b7b36b6165dca89fafcb (patch)
tree49925acbe0c18e22f600ec664772aa06bc11615f /llvm/tools/llvm-objcopy/Object.cpp
parente29c0b88628c0f353d2fa1423525fe4acbd7ad67 (diff)
downloadbcm5719-llvm-e8437de727ed208cc4a8b7b36b6165dca89fafcb.tar.gz
bcm5719-llvm-e8437de727ed208cc4a8b7b36b6165dca89fafcb.zip
[llvm-objcopy] Add option to add a progbits section from a file
This change adds support for adding progbits sections with contents from a file Differential Revision: https://reviews.llvm.org/D41212 llvm-svn: 321047
Diffstat (limited to 'llvm/tools/llvm-objcopy/Object.cpp')
-rw-r--r--llvm/tools/llvm-objcopy/Object.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/tools/llvm-objcopy/Object.cpp b/llvm/tools/llvm-objcopy/Object.cpp
index bd5bcd7fc18..d5dfcac40e4 100644
--- a/llvm/tools/llvm-objcopy/Object.cpp
+++ b/llvm/tools/llvm-objcopy/Object.cpp
@@ -81,6 +81,11 @@ void Section::writeSection(FileOutputBuffer &Out) const {
std::copy(std::begin(Contents), std::end(Contents), Buf);
}
+void OwnedDataSection::writeSection(FileOutputBuffer &Out) const {
+ uint8_t *Buf = Out.getBufferStart() + Offset;
+ std::copy(std::begin(Data), std::end(Data), Buf);
+}
+
void StringTableSection::addString(StringRef Name) {
StrTabBuilder.add(Name);
Size = StrTabBuilder.getSize();
@@ -676,6 +681,13 @@ void Object<ELFT>::removeSections(
Sections.erase(Iter, std::end(Sections));
}
+template <class ELFT>
+void Object<ELFT>::addSection(StringRef SecName, ArrayRef<uint8_t> Data) {
+ auto Sec = llvm::make_unique<OwnedDataSection>(SecName, Data);
+ Sec->OriginalOffset = ~0ULL;
+ Sections.push_back(std::move(Sec));
+}
+
template <class ELFT> void ELFObject<ELFT>::sortSections() {
// Put all sections in offset order. Maintain the ordering as closely as
// possible while meeting that demand however.
OpenPOWER on IntegriCloud