mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 885336 - Fix various issues with the dl_mmap interface. r=nfroyd
This commit is contained in:
parent
21f4113886
commit
a682d7fe75
@ -95,7 +95,7 @@ private:
|
|||||||
mappable->munmap(buf, length);
|
mappable->munmap(buf, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
Mappable *mappable;
|
mozilla::RefPtr<Mappable> mappable;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -233,7 +233,6 @@ CustomElf::~CustomElf()
|
|||||||
* Android NDK before r6b doesn't do that. Our wrapped cxa_finalize only
|
* Android NDK before r6b doesn't do that. Our wrapped cxa_finalize only
|
||||||
* calls destructors once, so call it in all cases. */
|
* calls destructors once, so call it in all cases. */
|
||||||
ElfLoader::__wrap_cxa_finalize(this);
|
ElfLoader::__wrap_cxa_finalize(this);
|
||||||
delete mappable;
|
|
||||||
ElfLoader::Singleton.Forget(this);
|
ElfLoader::Singleton.Forget(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,8 +9,6 @@
|
|||||||
#include "Logging.h"
|
#include "Logging.h"
|
||||||
#include "Elfxx.h"
|
#include "Elfxx.h"
|
||||||
|
|
||||||
class Mappable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Library Handle class for ELF libraries we don't let the system linker
|
* Library Handle class for ELF libraries we don't let the system linker
|
||||||
* handle.
|
* handle.
|
||||||
@ -157,7 +155,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Appropriated Mappable */
|
/* Appropriated Mappable */
|
||||||
Mappable *mappable;
|
mozilla::RefPtr<Mappable> mappable;
|
||||||
|
|
||||||
/* Base address where the library is loaded */
|
/* Base address where the library is loaded */
|
||||||
MappedPtr base;
|
MappedPtr base;
|
||||||
|
@ -182,8 +182,6 @@ LeafName(const char *path)
|
|||||||
LibHandle::~LibHandle()
|
LibHandle::~LibHandle()
|
||||||
{
|
{
|
||||||
free(path);
|
free(path);
|
||||||
if (mappable && mappable->GetKind() != Mappable::MAPPABLE_EXTRACT_FILE)
|
|
||||||
delete mappable;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
@ -195,8 +193,7 @@ LibHandle::GetName() const
|
|||||||
size_t
|
size_t
|
||||||
LibHandle::GetMappableLength() const
|
LibHandle::GetMappableLength() const
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(mappable != NULL, "GetMappableLength needs to be called first,"
|
if (!mappable)
|
||||||
" and only once");
|
|
||||||
mappable = GetMappable();
|
mappable = GetMappable();
|
||||||
if (!mappable)
|
if (!mappable)
|
||||||
return 0;
|
return 0;
|
||||||
@ -206,8 +203,10 @@ LibHandle::GetMappableLength() const
|
|||||||
void *
|
void *
|
||||||
LibHandle::MappableMMap(void *addr, size_t length, off_t offset) const
|
LibHandle::MappableMMap(void *addr, size_t length, off_t offset) const
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(mappable == NULL, "MappableMMap must be called after"
|
if (!mappable)
|
||||||
" GetMappableLength");
|
mappable = GetMappable();
|
||||||
|
if (!mappable)
|
||||||
|
return MAP_FAILED;
|
||||||
void* mapped = mappable->mmap(addr, length, PROT_READ, MAP_PRIVATE, offset);
|
void* mapped = mappable->mmap(addr, length, PROT_READ, MAP_PRIVATE, offset);
|
||||||
if (mapped != MAP_FAILED) {
|
if (mapped != MAP_FAILED) {
|
||||||
/* Ensure the availability of all pages within the mapping */
|
/* Ensure the availability of all pages within the mapping */
|
||||||
@ -221,8 +220,7 @@ LibHandle::MappableMMap(void *addr, size_t length, off_t offset) const
|
|||||||
void
|
void
|
||||||
LibHandle::MappableMUnmap(void *addr, size_t length) const
|
LibHandle::MappableMUnmap(void *addr, size_t length) const
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(mappable == NULL, "MappableMUnmap must be called after"
|
if (mappable)
|
||||||
" MappableMMap and GetMappableLength");
|
|
||||||
mappable->munmap(addr, length);
|
mappable->munmap(addr, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include "mozilla/RefPtr.h"
|
#include "mozilla/RefPtr.h"
|
||||||
#include "Zip.h"
|
#include "Zip.h"
|
||||||
#include "Elfxx.h"
|
#include "Elfxx.h"
|
||||||
|
#include "Mappable.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dlfcn.h replacement functions
|
* dlfcn.h replacement functions
|
||||||
@ -76,9 +77,6 @@ template <> inline RefCounted<LibHandle, AtomicRefCount>::~RefCounted()
|
|||||||
} /* namespace detail */
|
} /* namespace detail */
|
||||||
} /* namespace mozilla */
|
} /* namespace mozilla */
|
||||||
|
|
||||||
/* Forward declaration */
|
|
||||||
class Mappable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract class for loaded libraries. Libraries may be loaded through the
|
* Abstract class for loaded libraries. Libraries may be loaded through the
|
||||||
* system linker or this linker, both cases will be derived from this class.
|
* system linker or this linker, both cases will be derived from this class.
|
||||||
@ -200,7 +198,7 @@ private:
|
|||||||
char *path;
|
char *path;
|
||||||
|
|
||||||
/* Mappable object keeping the result of GetMappable() */
|
/* Mappable object keeping the result of GetMappable() */
|
||||||
mutable Mappable *mappable;
|
mutable mozilla::RefPtr<Mappable> mappable;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
* - memory after length and up to the end of the corresponding page is nulled
|
* - memory after length and up to the end of the corresponding page is nulled
|
||||||
* out.
|
* out.
|
||||||
*/
|
*/
|
||||||
class Mappable
|
class Mappable: public mozilla::RefCounted<Mappable>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~Mappable() { }
|
virtual ~Mappable() { }
|
||||||
@ -120,6 +120,9 @@ public:
|
|||||||
*/
|
*/
|
||||||
static Mappable *Create(const char *name, Zip *zip, Zip::Stream *stream);
|
static Mappable *Create(const char *name, Zip *zip, Zip::Stream *stream);
|
||||||
|
|
||||||
|
/* Override finalize from MappableFile */
|
||||||
|
virtual void finalize() {}
|
||||||
|
|
||||||
virtual Kind GetKind() const { return MAPPABLE_EXTRACT_FILE; };
|
virtual Kind GetKind() const { return MAPPABLE_EXTRACT_FILE; };
|
||||||
private:
|
private:
|
||||||
MappableExtractFile(int fd, char *path)
|
MappableExtractFile(int fd, char *path)
|
||||||
|
Loading…
Reference in New Issue
Block a user