Граф коммитов

88 Коммитов

Автор SHA1 Сообщение Дата
Mike Hommey 69fef46cab Bug 1651079 - Add necessary LOCAL_INCLUDES for StackWalk.cpp in memory/replace/logalloc/replay. r=rstewart
This requires a workaround for the use of __wrap_dladdr, which can't be
used in logalloc-replay. The workaround involves making __wrap_dladdr
expand to dladdr, but that makes the definition ElfLinker.h conflict
with the one in the Android system headers, so we change it to match,
and adjust ElfLinker.cpp accordingly.

And while here, fix the condition in mozglue/misc to match the condition
around including Linker.h in StackWalk.cpp itself.

Differential Revision: https://phabricator.services.mozilla.com/D82648
2020-07-08 21:37:24 +00:00
Mike Hommey 3a241e8832 Bug 1648340 - Only call GetAndroidSDKVersion() on Android. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D81024
2020-06-25 10:59:19 +00:00
James Willcox 2ef4e466f8 Bug 1291377 - Don't use custom linker on Android 6.0+ r=glandium
We still need it for Android < 6.0 (API 23) because otherwise we don't
have a way to hook up mozalloc.

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

--HG--
extra : moz-landing-system : lando
2020-03-20 15:35:48 +00:00
Bogdan Tara 05377fcd08 Backed out changeset fe0c22951e7c (bug 1291377) for mozglue related Android bustages CLOSED TREE 2020-03-20 16:39:42 +02:00
James Willcox e2c25ee165 Bug 1291377 - Don't use custom linker on Android 6.0+ r=glandium
We still need it for Android < 6.0 (API 23) because otherwise we don't
have a way to hook up mozalloc.

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

--HG--
extra : moz-landing-system : lando
2020-03-20 14:20:48 +00:00
Mike Hommey b1d0510804 Bug 1598196 - Support disabling the linker on Android in the code. r=froydnj
For now, there is no flag to actually allow it, but this is the
code-side changes to allow the linker being disabled.

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

--HG--
extra : moz-landing-system : lando
2019-11-21 14:57:24 +00:00
Sylvestre Ledru e226046cb8 Bug 1547143 - Format the tree: Be prescriptive with the pointer style (left) r=Ehsan
# ignore-this-changeset

Depends on D28954

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

--HG--
extra : moz-landing-system : lando
2019-05-01 08:47:10 +00:00
Mike Hommey 492bd126b6 Bug 1543555 - Stop using our linker to resolve libc/libm symbols when not strictly necessary. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D27019

--HG--
extra : moz-landing-system : lando
2019-04-12 02:12:31 +00:00
Cameron McCormack eedb6aebd4 Bug 1538081 - Part 3: Add operator<<(ostream&) definitions for a few common types. r=froydnj,gerald
Depends on D25023

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

--HG--
extra : moz-landing-system : lando
2019-03-30 04:26:26 +00:00
Ehsan Akhgari e5e885ae31 Bug 1521000 - Part 2: Adjust our clang-format rules to include spaces after the hash for nested preprocessor directives r=sylvestre
# ignore-this-changeset

--HG--
extra : amend_source : 7221c8d15a765df71171099468e7c7faa648f37c
extra : histedit_source : a0cce6015636202bff09e35a13f72e03257a7695
2019-01-18 10:16:18 +01:00
Sylvestre Ledru 265e672179 Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
# ignore-this-changeset

--HG--
extra : amend_source : 4d301d3b0b8711c4692392aa76088ba7fd7d1022
2018-11-30 11:46:48 +01:00
Jim Chen f61f04949b Bug 1451891 - Fix race conditions in __wrap_dlerror; r=glandium
__wrap_dlerror uses a single pointer for all threads, which means one
thread could get the dlerror result from another thread. Normally this
wouldn't cause crashes. However, because dlerror results come from a
per-thread buffer, if a thread exits and our saved dlerror result came
from that thread, the saved pointer could then refer to invalid memory.

The proper way to fix this is to use TLS and have a per-thread pointer
for __wrap_dlerror. However, instead of using up a TLS slot, this patch
keeps the single pointer for custom messages, and fallback to per-thread
dlerror call for system messages. While the race condition still exists,
I think the risk is acceptable. Even when races occur, they should no
longer cause crashes.

MozReview-Commit-ID: 4hGksidjiVz

--HG--
extra : rebase_source : 373000686c426b81ffd7cee88264e89b7a733957
2018-07-25 13:59:30 -04:00
Jim Chen 9d10605784 Bug 1460989 - Hold system linker lock while modifying debug map. r=glandium, a=RyanVM
When we modify the debug map, we could be racing with the system linker,
either when we modify the entries or when we change page protection
flags. To fix the race, we need to take the system linker's internal
lock when we perform any kind of modification on the debug map.

One way to hold the system linker lock is to call dl_iterate_phdr, and
perform our actions inside the callback, which is invoked with the
lock being held. However, dl_iterate_phdr is only present on Android
5.0+, and even then, dl_iterate_phdr is only protected by the linker
lock on Android 6.0+.

This means that with this patch, we can only safely modify the debug map
on Android 6.0+, which I think is acceptable for an operation that only
benefits a debugger.

MozReview-Commit-ID: BowBEO8tu8Z

--HG--
extra : amend_source : 837631dfc2ef17b24ffe5778bcb70dc29b7dfc66
2018-06-15 04:24:10 -04:00
Ryan VanderMeulen 4aef6ab351 Backed out changeset a4465713555b (bug 1460989) for causing the Galaxy S8 crash rate to spike. 2018-06-06 21:07:48 -04:00
Jim Chen 32c922179c Bug 1460989 - Check page protection flags again after mprotect(); r=glandium
We are apparently still crashing even after mprotect() with write flag
returns successfully. This patch reads the flags again after mprotect()
returns, and hopefully the flags will tell the truth of whether the page
is truly writable or not after calling mprotect().

MozReview-Commit-ID: Jsg8vHKFEvJ

--HG--
extra : rebase_source : b028aa0d5cefd50302bfc2502292d9129d202e09
2018-05-30 11:47:07 -04:00
James Willcox 624417af1d Bug 1455662 - Guard against mprotect() failure when manipulating link map r=jchen
MozReview-Commit-ID: 7orhBmf4j5j
2018-04-25 15:06:55 -05:00
James Willcox cf502cd7d7 Bug 1450793 - Don't assume 4k page size r=glandium
MozReview-Commit-ID: DWSIUOFfKW5
2018-04-13 08:46:35 -05:00
James Willcox 0e79fd0b72 Bug 1447607 - Correctly init and update ElfLoader::Singleton::lastError r=glandium
MozReview-Commit-ID: r1bclXdt4V

--HG--
extra : rebase_source : c9f612def794a6edc5fa8dd99fc08d2df4ed1cf1
2018-03-30 09:57:43 -05:00
Nathan Froyd 1dba87fe96 Bug 1448029 - make constructors in the linker explicit; r=glandium
Attempting to stand up the static analysis for Android builds revealed
that we weren't being explicit enough.
2018-03-27 10:51:32 -04:00
Mike Hommey 5e48214af2 Bug 1414506 - Use system dl_iterate_phdr for system loaded libraries when we can. r=froydnj
When looping through the debugger helper links during our
dl_iterate_phdr implementation, we effectively race with other threads
dlclose()ing libraries while we're working.

We do have a (rather involved) check in place to ensure that elf headers
are readable. But it turns out in practice, some dlclose() do happen
between the check and the actual read of the elf headers.

Unfortunately, we can't lock the system linker while we're looping, so a
better approach is to only loop through the libraries we loaded, and
rely on the system dl_iterate_phdr to iterate over the (remaining)
system libraries.

Unfortunately (again), Android versions < 5.0 don't have a system
dl_iterate_phdr, so we have to rely on the old iterator when it's not
present.

--HG--
extra : rebase_source : 3fd07589ed1939411ef72f481b7c72f761d53701
2018-01-23 15:59:18 +09:00
Mike Hommey 76f5fcdbab Bug 1414506 - Move dl_phdr_info filling and callback invocation to a separate class. r=froydnj
We're going to introduce two code paths that need to fill dl_phdr_info
from different iterators, so first move the code to a separate class,
that both code paths will be able to call.

--HG--
extra : rebase_source : a50663ad8d15d4f7a28d7138824003df5edd7f1c
2018-01-23 15:50:38 +09:00
Nathan Froyd c04d322a0a Bug 1412405 - fix isnanf symbol lookup by using a LoadedElf for libm; r=glandium
We already dealt with issues around dlsym not resolving weak symbols
with libc in bug 1081034.  This fix applies the same workaround to libm,
which solves the isnanf issue.

The previous fix for looking up __isnanf is no longer needed.
2017-10-28 08:51:23 -04:00
Nathan Froyd 936aff29b5 Bug 1412405 - try harder to find a definition for isnanf in the custom linker; r=nalexander
The comment with the accompanying change explains things, but the short
version is that clang generates full calls to isnanf, which our
dlsym-based symbol lookup in the custom linker cannot handle correctly.
We therefore need to do extra work for isnanf to find the correct symbol.
2017-10-27 17:08:20 -04:00
Mike Hommey 8022e9e91e Bug 1376704 - Remove szip support in the linker. r=snorp
Since bug 1307886, we don't actually use szip anymore, and don't even
have the option to package Fennec using it. We can thus remove the
support for loading them, as well as on demand linkage.

The latter might mean we can remove the segfault handler, but it's
unclear whether this is currently working around other issues with
registering signal handlers, so we'll leave that to a followup.

--HG--
extra : rebase_source : ec23cd4e78f259a70f6690adc8dfabb557e8f304
2017-06-28 15:47:31 +09:00
Jim Chen 8057a25813 Bug 1360321 - 4c. Add Divert case for AArch64; r=froydnj r=glandium
Fill in AArch64 trampoline for Divert(). Even though we're not using
on-demand decompression anymore, I added the AArch64 cases for
completeness.

MozReview-Commit-ID: D91KhHiDo7S
2017-05-17 13:06:22 -04:00
Jim Chen f5f1f202b1 Bug 1360321 - 4a. Fix printf macro mismatches in mozglue; r=froydnj r=glandium
Fix printf macro mismatches where, for example, `PRIxPTR` is defined for
`long` but the ELF `Addr` type is defined as `long long`.

MozReview-Commit-ID: 8hXY1MpHPjS
2017-05-17 13:06:22 -04:00
Eugen Sawin c281414151 Bug 1358241 - [2.1] Add mutex locking around the library handles cache. r=jchen 2017-04-25 18:05:06 +02:00
Eugen Sawin 84b446b09c Bug 1358241 - [1.2] Make direct library reference counter atomic to avoid mutex locking issues. r=jchen 2017-04-25 18:05:06 +02:00
Eugen Sawin 4b956de40e Bug 1346042 - [1.0] Mutex-lock LibHandle direct reference management. r=glandium 2017-04-18 16:08:40 +02:00
Eugen Sawin 18f563fd04 Bug 1305745 - [1.1] Free the zip path intermediate variable. r=glandium 2016-10-04 15:21:22 +02:00
Mike Hommey c6f04b053b Bug 1291768 - Avoid SIGSEGV trying to read ELF headers of libraries with a non-null base virtual address. r=froydnj
--HG--
extra : rebase_source : ff8b269f2e0a69253ff5277f71a5b3f48cc7d55e
2016-08-18 07:16:40 +09:00
Nathan Froyd 01583602a9 Bug 1207245 - part 6 - rename nsRefPtr<T> to RefPtr<T>; r=ehsan; a=Tomcat
The bulk of this commit was generated with a script, executed at the top
level of a typical source code checkout.  The only non-machine-generated
part was modifying MFBT's moz.build to reflect the new naming.

CLOSED TREE makes big refactorings like this a piece of cake.

 # The main substitution.
find . -name '*.cpp' -o -name '*.cc' -o -name '*.h' -o -name '*.mm' -o -name '*.idl'| \
    xargs perl -p -i -e '
 s/nsRefPtr\.h/RefPtr\.h/g; # handle includes
 s/nsRefPtr ?</RefPtr</g;   # handle declarations and variables
'

 # Handle a special friend declaration in gfx/layers/AtomicRefCountedWithFinalize.h.
perl -p -i -e 's/::nsRefPtr;/::RefPtr;/' gfx/layers/AtomicRefCountedWithFinalize.h

 # Handle nsRefPtr.h itself, a couple places that define constructors
 # from nsRefPtr, and code generators specially.  We do this here, rather
 # than indiscriminantly s/nsRefPtr/RefPtr/, because that would rename
 # things like nsRefPtrHashtable.
perl -p -i -e 's/nsRefPtr/RefPtr/g' \
     mfbt/nsRefPtr.h \
     xpcom/glue/nsCOMPtr.h \
     xpcom/base/OwningNonNull.h \
     ipc/ipdl/ipdl/lower.py \
     ipc/ipdl/ipdl/builtin.py \
     dom/bindings/Codegen.py \
     python/lldbutils/lldbutils/utils.py

 # In our indiscriminate substitution above, we renamed
 # nsRefPtrGetterAddRefs, the class behind getter_AddRefs.  Fix that up.
find . -name '*.cpp' -o -name '*.h' -o -name '*.idl' | \
    xargs perl -p -i -e 's/nsRefPtrGetterAddRefs/RefPtrGetterAddRefs/g'

if [ -d .git ]; then
    git mv mfbt/nsRefPtr.h mfbt/RefPtr.h
else
    hg mv mfbt/nsRefPtr.h mfbt/RefPtr.h
fi

--HG--
rename : mfbt/nsRefPtr.h => mfbt/RefPtr.h
2015-10-18 01:24:48 -04:00
Nathan Froyd 583afa0965 Bug 1207245 - part 3 - switch all uses of mozilla::RefPtr<T> to nsRefPtr<T>; r=ehsan
This commit was generated using the following script, executed at the
top level of a typical source code checkout.

 # Don't modify select files in mfbt/ because it's not worth trying to
 # tease out the dependencies currently.
 #
 # Don't modify anything in media/gmp-clearkey/0.1/ because those files
 # use their own RefPtr, defined in their own RefCounted.h.
find . -name '*.cpp' -o -name '*.h' -o -name '*.mm' -o -name '*.idl'| \
    grep -v 'mfbt/RefPtr.h' | \
    grep -v 'mfbt/nsRefPtr.h' | \
    grep -v 'mfbt/RefCounted.h' | \
    grep -v 'media/gmp-clearkey/0.1/' | \
    xargs perl -p -i -e '
 s/mozilla::RefPtr/nsRefPtr/g; # handle declarations in headers
 s/\bRefPtr</nsRefPtr</g; # handle local variables in functions
 s#mozilla/RefPtr.h#mozilla/nsRefPtr.h#; # handle #includes
 s#mfbt/RefPtr.h#mfbt/nsRefPtr.h#;       # handle strange #includes
'

 # |using mozilla::RefPtr;| is OK; |using nsRefPtr;| is invalid syntax.
find . -name '*.cpp' -o -name '*.mm' | xargs sed -i -e '/using nsRefPtr/d'

 # RefPtr.h used |byRef| for dealing with COM-style outparams.
 # nsRefPtr.h uses |getter_AddRefs|.
 # Fixup that mismatch.
find . -name '*.cpp' -o -name '*.h'| \
    xargs perl -p -i -e 's/byRef/getter_AddRefs/g'
2015-10-18 00:40:10 -04:00
Nathan Froyd 974d8120f2 Bug 1161627 - part 2 - machine-convert TemporaryRef<T> to already_AddRefed<T>; r=ehsan
This conversion was done with the script:

  find . -name '*.cpp' -o -name '*.h' -o -name '*.mm' -o -name '*.idl' | \
    egrep -v 'cairo-win32-refptr.h|RefPtr.h|TestRefPtr.cpp' | \
    xargs sed -i -e 's/mozilla::TemporaryRef</already_AddRefed</g' \
                 -e 's/TemporaryRef</already_AddRefed</g'

Manual fixups were performed in the following instances:

- We handled mfbt/RefPtr.h manually so as to not convert TemporaryRef itself
  into already_AddRefed.

- The following files had explicit Move() calls added to make up for the lack
  of a copy constructor on already_AddRefed:

  dom/base/ImageEncoder.cpp
  dom/media/MediaTaskQueue.{h,cpp}
  dom/media/webaudio/PannerNode.cpp

- A redundant overload for MediaTaskQueue::Dispatch was deleted.

- A few manual fixups were required in mfbt/tests/TestRefPtr.cpp.

- Comments, using declarations, and forward declarations relating to
  TemporaryRef in dom/canvas/ and gfx/layers/ were changed to refer to
  already_AddRefed.
2015-06-17 10:00:52 -04:00
Nathan Froyd db188ea282 Bug 1160485 - remove implicit conversion from RefPtr<T> to TemporaryRef<T>; r=ehsan
Having this implicit conversion means that we can silently do extra
refcounting when it's completely unnecessary.  It's also an obstacle to
making RefPtr more nsRefPtr-like, so let's get rid of it.
2015-05-01 09:14:16 -04:00
Nathan Froyd 3e13ec018f Bug 1116905 - part 1 - remove dependence on implicit conversion from T* to TemporaryRef<T>, non-gfx changes; r=ehsan 2015-04-30 15:17:08 -04:00
travis e56b9791d1 Bug 1154803 - Put our sigaction diversion in __sigaction if it exists r=glandium 2015-04-21 09:32:45 -05:00
James Willcox 47ca1c6198 Bug 1127464 - Assert when we unexpectedly unload libraries on Android r=glandium 2015-03-09 08:33:22 -05:00
Mike Hommey c9456870c0 Bug 1082524 - Do not deref null pointers in link_map. r=nfroyd 2014-10-18 09:27:55 +09:00
Mike Hommey 984856dd8c Fixup for bug 1081034 - Add missing #ifdef to avoid build failure on desktop linux. r=me,npotb,DONTBUILD 2014-10-17 14:09:17 +09:00
Mike Hommey eb75074fdb Bug 1081034 part 3 - Resolve libc symbols with our linker. r=nfroyd
This allows to resolve weak symbols from some Android device's libc that
dlsym() won't. This is effectively an alternative fix to bug 791419, without
requiring wrapping symbols.
2014-10-16 09:20:14 +09:00
Mike Hommey 9c53800a82 Bug 1081034 part 2 - Move initialization of self_elf to its own separate class. r=nfroyd
The new class is kind of like SystemElf, but using our linker's own symbol
resolution. This also adds some initialization from ELF program headers that
weren't done previously for self_elf, as well as registration as for CustomElf
instances.
2014-10-16 09:20:06 +09:00
Mike Hommey 84f2c13cef Bug 1078837 part 2 - Replace IsSystemElf/reinterpret_cast dance with better API. r=nfroyd 2014-10-16 09:19:45 +09:00
Mike Hommey eb89afceec Bug 1083020 - Add a (dummy) stats method to all LibHandles. r=nfroyd
While here, avoid doing anything if debug logging is disabled.
2014-10-16 09:19:40 +09:00
Mike Hommey 464da0f9c2 Bug 1077384 - Make libmozglue a pseudo-LD_PRELOAD on android. r=nfroyd
In order to avoid adding more dlsym overhead than there already is, resolve
symbols directly in the library containing the linker. (GetSymbolPtr is
essentially free ; dlsym makes the system linker compule a ElfHash itself,
and that's quite expensive to do on all symbols)

This also paves the way for direct symbol resolution in all system libraries.
2014-10-07 07:42:18 +09:00
Mike Hommey 2466a02679 Bug 1077135 - Ensure logging initialization for early log messages in the linker. r=nfroyd 2014-10-04 10:31:49 +09:00
Mike Hommey 5331094bbb Bug 1077135 - Initialize ElfLoader::DebuggerHelper::firstAdded. r=nfroyd 2014-10-04 10:31:38 +09:00
Jim Chen f3c570c80b Bug 1066760 - Add base address and fall back to system dladdr in __wrap_dladdr; r=froydnj 2014-09-24 14:12:54 -04:00
Mike Hommey 1cf20f37fd Bug 1036286 - Ensure faulty.lib diverts libc's sigaction instead of a LD_PRELOADed one. r=nfroyd
and force-send calls to sigaction from faulty.lib-loaded libraries to the libc.
2014-08-07 02:51:20 +09:00
Mike Hommey 15851645b4 Bug 1036286 - Delay registration of the faulty.lib signal handler until when it's necessary. r=nfroyd
It's necessary to delay it because for the second part, we need to call dlopen,
and until recently bionic's linker dead-locked when using dlopen from a static
initializer.
2014-08-07 02:51:03 +09:00