Android: Determine search path by taking the address of a function instead of a variable.

The GetCrazyContext function calls the
crazy_context_add_search_path_for_address function to add the directory
where the crazy linker library was loaded from to the search path.
This function works by reading /proc/self/maps to discover the path
of the file from which the address passed as the second argument is
mapped, which is expected to be the crazy linker library.

However, there is no guarantee that the address of a static variable
such as s_crazy_context will be mapped; the linker may allocate them
into an unmapped region of the r/w segment.  This happens to be what
lld does with this variable. Because the address was not mapped,
we ended up failing to determine the search path, which led to a
failure to load libchrome.so in pre-modern APKs.

We can more reasonably rely on functions being memory mapped, so this
change causes us to take the address of a function instead.

Bug: 779185
Change-Id: I83cd882567c48a2cca443b7f5781c50ebc1b9bb4
Reviewed-on: https://chromium-review.googlesource.com/745201
Reviewed-by: agrieve <agrieve@chromium.org>
Commit-Queue: Peter Collingbourne <pcc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#512698}

CrOS-Libchrome-Original-Commit: eb412d9686ae92bc8cbe2f1c380b8db013130e9b
1 file changed
tree: d3c9e03f0b1120e82762eb5a09a743760b852e20
  1. base/
  2. build/
  3. components/
  4. dbus/
  5. device/
  6. ipc/
  7. mojo/
  8. testing/
  9. third_party/
  10. ui/