summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-objcopy/Object.cpp
diff options
context:
space:
mode:
authorAlexander Shaposhnikov <shal1t712@gmail.com>2018-10-24 22:49:06 +0000
committerAlexander Shaposhnikov <shal1t712@gmail.com>2018-10-24 22:49:06 +0000
commit654d3a9577d9782b03edaff7be369fa13e9ba14b (patch)
tree9e0b9e3c233edfc475172a2dc626f8820ade353e /llvm/tools/llvm-objcopy/Object.cpp
parentad4d018202d7f967c56b6adcfc283f7273b9d356 (diff)
downloadbcm5719-llvm-654d3a9577d9782b03edaff7be369fa13e9ba14b.tar.gz
bcm5719-llvm-654d3a9577d9782b03edaff7be369fa13e9ba14b.zip
[llvm-objcopy] Introduce dispatch mechanism based on the input
In this diff we introduce dispatch mechanism based on the type of the input (archive, object file, raw binary) and the format (coff, elf, macho). We also move the ELF-specific code into the namespace llvm::objcopy::elf. Test plan: make check-all Differential revision: https://reviews.llvm.org/D53311 llvm-svn: 345217
Diffstat (limited to 'llvm/tools/llvm-objcopy/Object.cpp')
-rw-r--r--llvm/tools/llvm-objcopy/Object.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/llvm/tools/llvm-objcopy/Object.cpp b/llvm/tools/llvm-objcopy/Object.cpp
index d677579ea23..5b2138436d5 100644
--- a/llvm/tools/llvm-objcopy/Object.cpp
+++ b/llvm/tools/llvm-objcopy/Object.cpp
@@ -28,8 +28,10 @@
#include <utility>
#include <vector>
-using namespace llvm;
-using namespace llvm::objcopy;
+namespace llvm {
+namespace objcopy {
+namespace elf {
+
using namespace object;
using namespace ELF;
@@ -1165,7 +1167,9 @@ template <class ELFT> void ELFWriter<ELFT>::writeEhdr() {
Ehdr.e_machine = Obj.Machine;
Ehdr.e_version = Obj.Version;
Ehdr.e_entry = Obj.Entry;
- Ehdr.e_phnum = size(Obj.segments());
+ // We have to use the fully-qualified name llvm::size
+ // since some compilers complain on ambiguous resolution.
+ Ehdr.e_phnum = llvm::size(Obj.segments());
Ehdr.e_phoff = (Ehdr.e_phnum != 0) ? Obj.ProgramHdrSegment.Offset : 0;
Ehdr.e_phentsize = (Ehdr.e_phnum != 0) ? sizeof(Elf_Phdr) : 0;
Ehdr.e_flags = Obj.Flags;
@@ -1597,9 +1601,6 @@ void BinaryWriter::finalize() {
SecWriter = llvm::make_unique<BinarySectionWriter>(Buf);
}
-namespace llvm {
-namespace objcopy {
-
template class BinaryELFBuilder<ELF64LE>;
template class BinaryELFBuilder<ELF64BE>;
template class BinaryELFBuilder<ELF32LE>;
@@ -1614,5 +1615,7 @@ template class ELFWriter<ELF64LE>;
template class ELFWriter<ELF64BE>;
template class ELFWriter<ELF32LE>;
template class ELFWriter<ELF32BE>;
+
+} // end namespace elf
} // end namespace objcopy
} // end namespace llvm
OpenPOWER on IntegriCloud