From fa00dfda13aaf8132bb6e3ae65e0e2adce9939a0 Mon Sep 17 00:00:00 2001 From: Rahul Chaudhry Date: Wed, 21 Mar 2018 11:50:36 -0700 Subject: [PATCH] Disable relocation_packer and migrate to SHT_RELR sections. Proposal for adding SHT_RELR sections in the generic-abi is at https://groups.google.com/forum/#!topic/generic-abi/bX460iggiKg Comparison with relocation_packer for aosp_marlin-userdebug: $ du -B1 -s */out/target/product/marlin/system 996958208 base/out/target/product/marlin/system 1008340992 no_pack/out/target/product/marlin/system 997801984 sht_relr/out/target/product/marlin/system base contains a build with current settings. no_pack contains a build with relocation_packer disabled. sht_relr contains a build with SHT_RELR sections enabled. relocation_packer was saving 11,382,784 bytes (no_pack - base). SHT_RELR sections are saving 10,539,008 bytes (no_pack - sht_relr). Bug: None Test: Built aosp_marlin-userdebug image, boots on device. Test: Built aosp_x86_64-userdebug image, boots in emulator. Change-Id: I448dc95baa4976b68ce2659b80498539426775f9 --- cc/config/arm64_device.go | 1 + cc/config/arm_device.go | 1 + cc/config/x86_64_device.go | 1 + cc/relocation_packer.go | 9 ++++++++- 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/cc/config/arm64_device.go b/cc/config/arm64_device.go index 5bb7749a8..146d00556 100644 --- a/cc/config/arm64_device.go +++ b/cc/config/arm64_device.go @@ -33,6 +33,7 @@ var ( "-Wl,--fix-cortex-a53-843419", "-fuse-ld=gold", "-Wl,--icf=safe", + "-Wl,--experimental-use-relr", } arm64Cppflags = []string{} diff --git a/cc/config/arm_device.go b/cc/config/arm_device.go index 66b3b3829..7e6d203d2 100644 --- a/cc/config/arm_device.go +++ b/cc/config/arm_device.go @@ -37,6 +37,7 @@ var ( "-Wl,--icf=safe", "-Wl,--hash-style=gnu", "-Wl,-m,armelf", + "-Wl,--experimental-use-relr", } armArmCflags = []string{ diff --git a/cc/config/x86_64_device.go b/cc/config/x86_64_device.go index 12f3e6fa2..dea13fbad 100644 --- a/cc/config/x86_64_device.go +++ b/cc/config/x86_64_device.go @@ -30,6 +30,7 @@ var ( x86_64Ldflags = []string{ "-Wl,--hash-style=gnu", + "-Wl,--experimental-use-relr", } x86_64ArchVariantCflags = map[string][]string{ diff --git a/cc/relocation_packer.go b/cc/relocation_packer.go index 500662365..824b538a8 100644 --- a/cc/relocation_packer.go +++ b/cc/relocation_packer.go @@ -45,7 +45,14 @@ type relocationPacker struct { } func (p *relocationPacker) packingInit(ctx BaseModuleContext) { - enabled := true + // Disable relocation_packer and migrate to SHT_RELR sections. + // + // Proposal for adding SHT_RELR sections in generic-abi is at + // https://groups.google.com/forum/#!topic/generic-abi/bX460iggiKg + // + // TODO: Remove relocation_packer and associated build logic. + enabled := false + // Relocation packer isn't available on Darwin yet if runtime.GOOS == "darwin" { enabled = false