Commit cf14fec1 authored by David 'Digit' Turner's avatar David 'Digit' Turner Committed by Commit Bot

android: build: Enable RELR packed relocations for libchrome.so

NOTE: This is a reland of [1], but this one does not touch
libchromefortest.so which is used on Android N+ during testing,
and could not be loaded by the system linker when using RELR
relocations.

This optimization cannot be applied to libmonochrome.so, unfortunately,
because only Android P and above support these at the system linker
level.

[1] https://chromium-review.googlesource.com/c/1304487

BUG=895194
R=agrieve@chromium.org,torne@chromium.org,pasko@chromium.org,pcc@chromium.org

Change-Id: If50f607d2e9abbff5ae0c140da342af7b8c78858
Reviewed-on: https://chromium-review.googlesource.com/c/1317630Reviewed-by: default avataragrieve <agrieve@chromium.org>
Reviewed-by: default avatarEgor Pasko <pasko@chromium.org>
Commit-Queue: David Turner <digit@chromium.org>
Cr-Commit-Position: refs/heads/master@{#609142}
parent cb3ca0bb
...@@ -197,6 +197,12 @@ config("lld_pack_relocations") { ...@@ -197,6 +197,12 @@ config("lld_pack_relocations") {
ldflags = [ "-Wl,--pack-dyn-relocs=android" ] ldflags = [ "-Wl,--pack-dyn-relocs=android" ]
} }
# Pack relocations with Android-specific relocations and RELR relocations that
# are only supported by the crazy linker and Android P+.
config("lld_pack_relocations_with_relr") {
ldflags = [ "-Wl,--pack-dyn-relocs=android+relr,--use-android-relr-tags" ]
}
# Used for instrumented build to generate the orderfile. # Used for instrumented build to generate the orderfile.
config("default_orderfile_instrumentation") { config("default_orderfile_instrumentation") {
if (use_order_profiling) { if (use_order_profiling) {
......
...@@ -979,12 +979,16 @@ jinja_template_resources("chrome_test_apk_template_resources") { ...@@ -979,12 +979,16 @@ jinja_template_resources("chrome_test_apk_template_resources") {
# ELF relocations to reduce native library size. # ELF relocations to reduce native library size.
# use_gnu_hash_style: If true, the final library will include only GNU hash # use_gnu_hash_style: If true, the final library will include only GNU hash
# tables, rather than both SysV and GNU types (the default). # tables, rather than both SysV and GNU types (the default).
# enable_relr_relocations: Optional flag. If true, and if |enable_compressed_relocations|
# is true, then reduce the size of the native library by enabling RELR relocations.
# Note that these are only supported by the Chromium linker, and Android P+.
template("chrome_common_shared_library") { template("chrome_common_shared_library") {
shared_library(target_name) { shared_library(target_name) {
forward_variables_from(invoker, forward_variables_from(invoker,
"*", "*",
[ [
"enable_compressed_relocations", "enable_compressed_relocations",
"enable_relr_relocations",
"export_java_symbols", "export_java_symbols",
"use_gnu_hash_style", "use_gnu_hash_style",
]) ])
...@@ -1018,7 +1022,12 @@ template("chrome_common_shared_library") { ...@@ -1018,7 +1022,12 @@ template("chrome_common_shared_library") {
# Compress relocations if needed. # Compress relocations if needed.
if (defined(invoker.enable_compressed_relocations) && if (defined(invoker.enable_compressed_relocations) &&
invoker.enable_compressed_relocations) { invoker.enable_compressed_relocations) {
configs += [ "//build/config/android:lld_pack_relocations" ] if (defined(invoker.enable_relr_relocations) &&
invoker.enable_relr_relocations) {
configs += [ "//build/config/android:lld_pack_relocations_with_relr" ]
} else {
configs += [ "//build/config/android:lld_pack_relocations" ]
}
} }
if (invoker.use_gnu_hash_style && target_cpu != "mipsel" && if (invoker.use_gnu_hash_style && target_cpu != "mipsel" &&
...@@ -1051,6 +1060,7 @@ template("chrome_shared_library") { ...@@ -1051,6 +1060,7 @@ template("chrome_shared_library") {
} }
enable_compressed_relocations = chromium_linker_supported && use_lld enable_compressed_relocations = chromium_linker_supported && use_lld
enable_relr_relocations = enable_compressed_relocations
use_gnu_hash_style = chromium_linker_supported use_gnu_hash_style = chromium_linker_supported
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment