This just reduces the noise from another patch.
llvm-svn: 235933
/// If the memoryBuffer is a fat file with a slice for the current arch,
/// this method will return the offset and size of that slice.
- bool sliceFromFatFile(const MemoryBuffer &mb, uint32_t &offset,
- uint32_t &size);
+ bool sliceFromFatFile(MemoryBufferRef mb, uint32_t &offset, uint32_t &size);
/// Returns if a command line option specified dylib is an upward link.
bool isUpwardDylib(StringRef installName) const;
_ctx(ctx), _useShlibUndefines(ctx.useShlibUndefines()) {}
template <typename ELFT>
-std::error_code DynamicFile<ELFT>::isCompatible(const MemoryBuffer &mb,
+std::error_code DynamicFile<ELFT>::isCompatible(MemoryBufferRef mb,
ELFLinkingContext &ctx) {
return elf::isCompatible<ELFT>(mb, ctx);
}
public:
DynamicFile(std::unique_ptr<MemoryBuffer> mb, ELFLinkingContext &ctx);
- static std::error_code isCompatible(const MemoryBuffer &mb,
+ static std::error_code isCompatible(MemoryBufferRef mb,
ELFLinkingContext &ctx);
const SharedLibraryAtom *exports(StringRef name,
_useWrap(ctx.wrapCalls().size()), _ctx(ctx) {}
template <typename ELFT>
-std::error_code ELFFile<ELFT>::isCompatible(const MemoryBuffer &mb,
+std::error_code ELFFile<ELFT>::isCompatible(MemoryBufferRef mb,
ELFLinkingContext &ctx) {
return elf::isCompatible<ELFT>(mb, ctx);
}
ELFFile(StringRef name, ELFLinkingContext &ctx);
ELFFile(std::unique_ptr<MemoryBuffer> mb, ELFLinkingContext &ctx);
- static std::error_code isCompatible(const MemoryBuffer &mb,
+ static std::error_code isCompatible(MemoryBufferRef mb,
ELFLinkingContext &ctx);
static bool canParse(file_magic magic) {
ErrorOr<std::unique_ptr<File>>
loadFile(std::unique_ptr<MemoryBuffer> mb,
const class Registry &) const override {
- if (std::error_code ec = FileT::isCompatible(*mb, _ctx))
+ if (std::error_code ec = FileT::isCompatible(mb->getMemBufferRef(), _ctx))
return ec;
std::unique_ptr<File> ret = llvm::make_unique<FileT>(std::move(mb), _ctx);
return std::move(ret);
std::error_code checkCompatibility(unsigned char size, unsigned char endian);
template <typename ELFT>
-std::error_code isCompatible(const MemoryBuffer &mb, ELFLinkingContext &ctx) {
+std::error_code isCompatible(MemoryBufferRef mb, ELFLinkingContext &ctx) {
typedef llvm::object::Elf_Ehdr_Impl<ELFT> Elf_Ehdr;
if (uintptr_t(mb.getBufferStart()) & 1)
return mach_o::normalized::isThinObjectFile(path, arch);
}
-bool MachOLinkingContext::sliceFromFatFile(const MemoryBuffer &mb,
- uint32_t &offset,
+bool MachOLinkingContext::sliceFromFatFile(MemoryBufferRef mb, uint32_t &offset,
uint32_t &size) {
return mach_o::normalized::sliceFromFatFile(mb, _arch, offset, size);
}
// and switch buffer to point to just that required slice.
uint32_t offset;
uint32_t size;
- if (sliceFromFatFile(*mb, offset, size))
+ if (sliceFromFatFile(mb->getMemBufferRef(), offset, size))
return MemoryBuffer::getFileSlice(path, size, offset);
return std::move(mb);
}
/// If the buffer is a fat file with the request arch, then this function
/// returns true with 'offset' and 'size' set to location of the arch slice
/// within the buffer. Otherwise returns false;
-bool sliceFromFatFile(const MemoryBuffer &mb, MachOLinkingContext::Arch arch,
- uint32_t &offset, uint32_t &size);
+bool sliceFromFatFile(MemoryBufferRef mb, MachOLinkingContext::Arch arch,
+ uint32_t &offset, uint32_t &size);
/// Reads a mach-o file and produces an in-memory normalized view.
ErrorOr<std::unique_ptr<NormalizedFile>>
return true;
}
-
-bool sliceFromFatFile(const MemoryBuffer &mb, MachOLinkingContext::Arch arch,
- uint32_t &offset, uint32_t &size) {
+bool sliceFromFatFile(MemoryBufferRef mb, MachOLinkingContext::Arch arch,
+ uint32_t &offset, uint32_t &size) {
const char *start = mb.getBufferStart();
const llvm::MachO::fat_header *fh =
reinterpret_cast<const llvm::MachO::fat_header *>(start);
uint32_t sliceOffset;
uint32_t sliceSize;
- if (sliceFromFatFile(*mb, arch, sliceOffset, sliceSize)) {
+ if (sliceFromFatFile(mb->getMemBufferRef(), arch, sliceOffset, sliceSize)) {
start = &start[sliceOffset];
objSize = sliceSize;
mh = reinterpret_cast<const mach_header *>(start);