#include "ArchiveInternals.h"
#include "llvm/Bitcode/ReaderWriter.h"
#include "llvm/Support/MemoryBuffer.h"
-#include "llvm/System/MappedFile.h"
#include "llvm/Module.h"
#include <memory>
using namespace llvm;
/// Read a variable-bit-rate encoded unsigned integer
-inline unsigned readInteger(const char*&At, const char*End){
+static inline unsigned readInteger(const char*&At, const char*End) {
unsigned Shift = 0;
unsigned Result = 0;
bool
Archive::checkSignature(std::string* error) {
// Check the magic string at file's header
- if (mapfile->size() < 8 || memcmp(base, ARFILE_MAGIC, 8)) {
+ if (mapfile->getBufferSize() < 8 || memcmp(base, ARFILE_MAGIC, 8)) {
if (error)
*error = "invalid signature for an archive file";
return false;
members.clear();
symTab.clear();
const char *At = base;
- const char *End = base + mapfile->size();
+ const char *End = mapfile->getBufferEnd();
if (!checkSignature(error))
return false;
members.clear();
symTab.clear();
const char *At = base;
- const char *End = base + mapfile->size();
+ const char *End = mapfile->getBufferEnd();
// Make sure we're dealing with an archive
if (!checkSignature(ErrorMsg))
// Module hasn't been loaded yet, we need to load it
const char* modptr = base + fileOffset;
- ArchiveMember* mbr = parseMemberHeader(modptr, base + mapfile->size(),ErrMsg);
+ ArchiveMember* mbr = parseMemberHeader(modptr, mapfile->getBufferEnd(),
+ ErrMsg);
if (!mbr)
return 0;
// below.
// Get a pointer to the first file
- const char* At = ((const char*)base) + firstFileOffset;
- const char* End = ((const char*)base) + mapfile->size();
+ const char* At = base + firstFileOffset;
+ const char* End = mapfile->getBufferEnd();
while ( At < End) {
// Compute the offset to be put in the symbol table