New issue
Advanced search Search tips

Issue 779185 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Oct 2017
Cc:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 3
Type: Bug

Blocking:
issue 742655



Sign in to add a comment

libchrome.so linked with lld not loadable by crazylinker

Project Member Reported by agrieve@chromium.org, Oct 27 2017

Issue description

GN Args:
target_os = "android"
is_debug = false
symbol_level = 1
is_official_build = true
use_lld = true
is_chrome_branded = true

1. Obtain a build of ld.lld that can link libchrome.so
2. Build chrome_public_apk
3. Run on a kitkat device via out/Release/bin/chrome_public_apk run

Logcat doesn't have much of use in it:

10-27 15:41:23.711  7912  7965 I cr_LibraryLoader: Loading chrome
10-27 15:41:23.711  7912  7965 E cr_ChromiumAndroidLinker: Open: Could not open libchrome.so: Can't find library file libchrome.so
10-27 15:41:23.711  7912  7965 E cr_LibraryLoader: Unable to load library: libchrome.so
10-27 15:41:23.711  7912  7965 E cr_LibraryLoader: Unable to load library: chrome


Chrome opens fine on my O device, so that's why I think it's a crazylinker issue.
 

Comment 1 by p...@chromium.org, Oct 27 2017

I can repro on my L device with chrome_public_apk but not with chrome_modern_public_apk.

Comment 2 by p...@chromium.org, Oct 30 2017

Cc: -p...@chromium.org agrieve@chromium.org
Owner: p...@chromium.org
Status: Started (was: Available)
Project Member

Comment 3 by bugdroid1@chromium.org, Oct 31 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/eb412d9686ae92bc8cbe2f1c380b8db013130e9b

commit eb412d9686ae92bc8cbe2f1c380b8db013130e9b
Author: Peter Collingbourne <pcc@chromium.org>
Date: Tue Oct 31 01:45:47 2017

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}
[modify] https://crrev.com/eb412d9686ae92bc8cbe2f1c380b8db013130e9b/base/android/linker/legacy_linker_jni.cc

Comment 4 by p...@chromium.org, Oct 31 2017

Status: Fixed (was: Started)

Sign in to add a comment