Bug 1471132 - Avoid ASAN padding between NSModules. r=froydnj

--HG--
extra : rebase_source : 480ea315a847ffb63a8cb1e583669a61f1a7f3eb
This commit is contained in:
Mike Hommey 2018-06-26 14:39:49 +09:00
Родитель 354a9e27a0
Коммит b231504a1b
3 изменённых файлов: 9 добавлений и 13 удалений

Просмотреть файл

@ -40,9 +40,7 @@ TARGET = {
'nm': '{}nm'.format(buildconfig.substs.get('TOOLCHAIN_PREFIX', '')),
}
if buildconfig.substs.get('MOZ_ASAN'):
GUESSED_NSMODULE_SIZE = 64
elif buildconfig.substs.get('HAVE_64BIT_BUILD'):
if buildconfig.substs.get('HAVE_64BIT_BUILD'):
GUESSED_NSMODULE_SIZE = 8
else:
GUESSED_NSMODULE_SIZE = 4

Просмотреть файл

@ -11,6 +11,7 @@
#include "nsID.h"
#include "nsIFactory.h"
#include "nsCOMPtr.h" // for already_AddRefed
#include "mozilla/Attributes.h"
namespace mozilla {
@ -148,7 +149,12 @@ struct Module
# if !defined(NSMODULE_SECTION)
# error Do not know how to define sections.
# endif
# define NSMODULE_DEFN(_name) extern NSMODULE_SECTION mozilla::Module const *const NSMODULE_NAME(_name)
# if defined(MOZ_HAVE_ASAN_BLACKLIST)
# define NSMODULE_ASAN_BLACKLIST __attribute__((no_sanitize_address))
# else
# define NSMODULE_ASAN_BLACKLIST
# endif
# define NSMODULE_DEFN(_name) extern NSMODULE_SECTION NSMODULE_ASAN_BLACKLIST mozilla::Module const *const NSMODULE_NAME(_name)
#else
# define NSMODULE_NAME(_name) NSModule
# define NSMODULE_DEFN(_name) extern "C" NS_EXPORT mozilla::Module const *const NSModule

Просмотреть файл

@ -250,12 +250,6 @@ nsTArray<const mozilla::Module*>* nsComponentManagerImpl::sStaticModules;
NSMODULE_DEFN(start_kPStaticModules);
NSMODULE_DEFN(end_kPStaticModules);
/* The content between start_kPStaticModules and end_kPStaticModules is gathered
* by the linker from various objects containing symbols in a specific section.
* ASAN considers (rightfully) the use of this content as a global buffer
* overflow. But this is a deliberate and well-considered choice, with no proper
* way to make ASAN happy. */
MOZ_ASAN_BLACKLIST
/* static */ void
nsComponentManagerImpl::InitializeStaticModules()
{
@ -267,9 +261,7 @@ nsComponentManagerImpl::InitializeStaticModules()
for (const mozilla::Module * const* staticModules =
&NSMODULE_NAME(start_kPStaticModules) + 1;
staticModules < &NSMODULE_NAME(end_kPStaticModules); ++staticModules)
if (*staticModules) { // ASAN adds padding
sStaticModules->AppendElement(*staticModules);
}
sStaticModules->AppendElement(*staticModules);
}
nsTArray<nsComponentManagerImpl::ComponentLocation>*