forked from OSchip/llvm-project
Use MemoryBufferRef instead of MemoryBuffer&. NFC.
This just reduces the noise from another patch. llvm-svn: 235933
This commit is contained in:
parent
a73aed0c9b
commit
ed48e53d60
|
@ -271,8 +271,7 @@ public:
|
|||
|
||||
/// 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;
|
||||
|
|
|
@ -24,7 +24,7 @@ DynamicFile<ELFT>::DynamicFile(std::unique_ptr<MemoryBuffer> mb,
|
|||
_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);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ template <class ELFT> class DynamicFile : public SharedLibraryFile {
|
|||
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,
|
||||
|
|
|
@ -28,7 +28,7 @@ ELFFile<ELFT>::ELFFile(std::unique_ptr<MemoryBuffer> mb, ELFLinkingContext &ctx)
|
|||
_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);
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ public:
|
|||
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) {
|
||||
|
|
|
@ -31,7 +31,7 @@ public:
|
|||
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);
|
||||
|
|
|
@ -21,7 +21,7 @@ template <class ELFT>
|
|||
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)
|
||||
|
|
|
@ -133,8 +133,7 @@ bool MachOLinkingContext::isThinObjectFile(StringRef path, Arch &arch) {
|
|||
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);
|
||||
}
|
||||
|
@ -613,7 +612,7 @@ MachOLinkingContext::getMemoryBuffer(StringRef path) {
|
|||
// 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);
|
||||
}
|
||||
|
|
|
@ -264,8 +264,8 @@ bool isThinObjectFile(StringRef path, MachOLinkingContext::Arch &arch);
|
|||
/// 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>>
|
||||
|
|
|
@ -170,9 +170,8 @@ bool isThinObjectFile(StringRef path, MachOLinkingContext::Arch &arch) {
|
|||
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);
|
||||
|
@ -212,7 +211,7 @@ readBinary(std::unique_ptr<MemoryBuffer> &mb,
|
|||
|
||||
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);
|
||||
|
|
Loading…
Reference in New Issue