Commit 6b83eba3 authored by Mike Hommey's avatar Mike Hommey
Browse files

Bug 1598194 - Make FaultyLib-specific code FaultyLib-specific rather than...

Bug 1598194 - Make FaultyLib-specific code FaultyLib-specific rather than Android-specific. r=gerald

The custom linker used on Android (FaultyLib), can be enabled on
non-Android, and in the near future, may not always be enabled on
Android, so the FaultyLib-specific parts of the profile need to not be
specific to Android, but to the linker being enabled instead.

Differential Revision: https://phabricator.services.mozilla.com/D54073

--HG--
extra : moz-landing-system : lando
parent 168ff04a
Loading
Loading
Loading
Loading
+10 −7
Original line number Diff line number Diff line
@@ -33,16 +33,19 @@
#  include <sys/types.h>
#  include <vector>

#  if defined(GP_OS_linux)
#    include <link.h>  // dl_phdr_info
#  elif defined(GP_OS_android)
#  if defined(MOZ_LINKER)
#    include "AutoObjectMapper.h"
#    include "ElfLoader.h"  // dl_phdr_info
#  elif defined(GP_OS_linux) || defined(GP_OS_android)
#    include <link.h>  // dl_phdr_info
#  else
#    error "Unexpected configuration"
#  endif

#  if defined(GP_OS_android)
extern "C" MOZ_EXPORT __attribute__((weak)) int dl_iterate_phdr(
    int (*callback)(struct dl_phdr_info* info, size_t size, void* data),
    void* data);
#  else
#    error "Unexpected configuration"
#  endif

// ----------------------------------------------------------------------------
@@ -648,7 +651,7 @@ struct LoadedLibraryInfo {
  unsigned long mLastMappingEnd;
};

#  if defined(GP_OS_android)
#  if defined(MOZ_LINKER)
static void outputMapperLog(const char* aBuf) { /* LOG("%s", aBuf); */
}
#  endif
@@ -665,7 +668,7 @@ static std::string getId(const char* bin_name) {
  std::vector<uint8_t> identifier;
  identifier.reserve(kDefaultBuildIdSize);

#  if defined(GP_OS_android)
#  if defined(MOZ_LINKER)
  if (nsDependentCString(bin_name).Find("!/") != kNotFound) {
    AutoObjectMapperFaultyLib mapper(outputMapperLog);
    void* image = nullptr;
+3 −3
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@
#  include "PlatformMacros.h"
#  include "AutoObjectMapper.h"

#  if defined(GP_OS_android)
#  if defined(MOZ_LINKER)
#    include <dlfcn.h>
#    include "mozilla/Types.h"
// FIXME move these out of mozglue/linker/ElfLoader.h into their
@@ -95,7 +95,7 @@ bool AutoObjectMapperPOSIX::Map(/*OUT*/ void** start, /*OUT*/ size_t* length,
  return true;
}

#  if defined(GP_OS_android)
#  if defined(MOZ_LINKER)
AutoObjectMapperFaultyLib::AutoObjectMapperFaultyLib(void (*aLog)(const char*))
    : AutoObjectMapperPOSIX(aLog), mHdl(nullptr) {}

@@ -125,6 +125,6 @@ bool AutoObjectMapperFaultyLib::Map(/*OUT*/ void** start,
  return false;
}

#  endif  // defined(GP_OS_android)
#  endif  // defined(MOZ_LINKER)

#endif  // MOZ_BASE_PROFILER
+2 −2
Original line number Diff line number Diff line
@@ -61,7 +61,7 @@ class MOZ_STACK_CLASS AutoObjectMapperPOSIX {
  void operator delete[](void*);
};

#if defined(GP_OS_android)
#if defined(MOZ_LINKER)
// This is a variant of AutoObjectMapperPOSIX suitable for use in
// conjunction with faulty.lib on Android.  How it behaves depends on
// the name of the file to be mapped.  There are three possible cases:
@@ -109,6 +109,6 @@ class MOZ_STACK_CLASS AutoObjectMapperFaultyLib : public AutoObjectMapperPOSIX {
  void operator delete[](void*);
};

#endif  // defined(GP_OS_android)
#endif  // defined(MOZ_LINKER)

#endif  // AutoObjectMapper_h
+1 −1
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@ void read_procmaps(lul::LUL* aLUL) {

    std::string nativePath = lib.GetDebugPath();

#    if defined(GP_OS_android)
#    if defined(MOZ_LINKER)
    // We're using faulty.lib.  Use a special-case object mapper.
    AutoObjectMapperFaultyLib mapper(aLUL->mLog);
#    else
+10 −7
Original line number Diff line number Diff line
@@ -28,16 +28,19 @@
#include <features.h>
#include <sys/types.h>

#if defined(GP_OS_linux)
#  include <link.h>  // dl_phdr_info
#elif defined(GP_OS_android)
#if defined(MOZ_LINKER)
#  include "AutoObjectMapper.h"
#  include "ElfLoader.h"  // dl_phdr_info
#elif defined(GP_OS_linux) || defined(GP_OS_android)
#  include <link.h>  // dl_phdr_info
#else
#  error "Unexpected configuration"
#endif

#if defined(GP_OS_android)
extern "C" MOZ_EXPORT __attribute__((weak)) int dl_iterate_phdr(
    int (*callback)(struct dl_phdr_info* info, size_t size, void* data),
    void* data);
#else
#  error "Unexpected configuration"
#endif

struct LoadedLibraryInfo {
@@ -55,7 +58,7 @@ struct LoadedLibraryInfo {
  unsigned long mLastMappingEnd;
};

#if defined(GP_OS_android)
#if defined(MOZ_LINKER)
static void outputMapperLog(const char* aBuf) { LOG("%s", aBuf); }
#endif

@@ -78,7 +81,7 @@ static nsCString getId(const char* bin_name) {
  PageAllocator allocator;
  auto_wasteful_vector<uint8_t, kDefaultBuildIdSize> identifier(&allocator);

#if defined(GP_OS_android)
#if defined(MOZ_LINKER)
  if (nsDependentCString(bin_name).Find("!/") != kNotFound) {
    AutoObjectMapperFaultyLib mapper(outputMapperLog);
    void* image = nullptr;
Loading