Merge changes I3648c914,I47dec958,Ia20f8198
* changes: Allow strip.sh --keep-mini-debug-info to work on non-elf files Fix strip.sh --keep-mini-debug-info Remove relocation packer
This commit is contained in:
@@ -134,7 +134,6 @@ bootstrap_go_package {
|
|||||||
"cc/pgo.go",
|
"cc/pgo.go",
|
||||||
"cc/prebuilt.go",
|
"cc/prebuilt.go",
|
||||||
"cc/proto.go",
|
"cc/proto.go",
|
||||||
"cc/relocation_packer.go",
|
|
||||||
"cc/rs.go",
|
"cc/rs.go",
|
||||||
"cc/sanitize.go",
|
"cc/sanitize.go",
|
||||||
"cc/sabi.go",
|
"cc/sabi.go",
|
||||||
|
@@ -141,7 +141,6 @@ func (library *libraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.An
|
|||||||
ret.Class = "STATIC_LIBRARIES"
|
ret.Class = "STATIC_LIBRARIES"
|
||||||
} else if library.shared() {
|
} else if library.shared() {
|
||||||
ctx.subAndroidMk(ret, &library.stripper)
|
ctx.subAndroidMk(ret, &library.stripper)
|
||||||
ctx.subAndroidMk(ret, &library.relocationPacker)
|
|
||||||
|
|
||||||
ret.Class = "SHARED_LIBRARIES"
|
ret.Class = "SHARED_LIBRARIES"
|
||||||
} else if library.header() {
|
} else if library.header() {
|
||||||
@@ -310,14 +309,6 @@ func (stripper *stripper) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMk
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (packer *relocationPacker) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
|
|
||||||
ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
|
|
||||||
if packer.Properties.PackingRelocations {
|
|
||||||
fmt.Fprintln(w, "LOCAL_PACK_MODULE_RELOCATIONS := true")
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func (installer *baseInstaller) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
|
func (installer *baseInstaller) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
|
||||||
// Soong installation is only supported for host modules. Have Make
|
// Soong installation is only supported for host modules. Have Make
|
||||||
// installation trigger Soong installation.
|
// installation trigger Soong installation.
|
||||||
|
@@ -210,7 +210,6 @@ type libraryDecorator struct {
|
|||||||
|
|
||||||
flagExporter
|
flagExporter
|
||||||
stripper
|
stripper
|
||||||
relocationPacker
|
|
||||||
|
|
||||||
// If we're used as a whole_static_lib, our missing dependencies need
|
// If we're used as a whole_static_lib, our missing dependencies need
|
||||||
// to be given
|
// to be given
|
||||||
@@ -251,8 +250,7 @@ func (library *libraryDecorator) linkerProps() []interface{} {
|
|||||||
&library.Properties,
|
&library.Properties,
|
||||||
&library.MutatedProperties,
|
&library.MutatedProperties,
|
||||||
&library.flagExporter.Properties,
|
&library.flagExporter.Properties,
|
||||||
&library.stripper.StripProperties,
|
&library.stripper.StripProperties)
|
||||||
&library.relocationPacker.Properties)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (library *libraryDecorator) linkerFlags(ctx ModuleContext, flags Flags) Flags {
|
func (library *libraryDecorator) linkerFlags(ctx ModuleContext, flags Flags) Flags {
|
||||||
@@ -428,8 +426,6 @@ func (library *libraryDecorator) linkerInit(ctx BaseModuleContext) {
|
|||||||
library.baseInstaller.location = location
|
library.baseInstaller.location = location
|
||||||
|
|
||||||
library.baseLinker.linkerInit(ctx)
|
library.baseLinker.linkerInit(ctx)
|
||||||
|
|
||||||
library.relocationPacker.packingInit(ctx)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (library *libraryDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps {
|
func (library *libraryDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps {
|
||||||
@@ -558,12 +554,6 @@ func (library *libraryDecorator) linkShared(ctx ModuleContext,
|
|||||||
TransformSharedObjectToToc(ctx, outputFile, tocFile, builderFlags)
|
TransformSharedObjectToToc(ctx, outputFile, tocFile, builderFlags)
|
||||||
}
|
}
|
||||||
|
|
||||||
if library.relocationPacker.needsPacking(ctx) {
|
|
||||||
packedOutputFile := outputFile
|
|
||||||
outputFile = android.PathForModuleOut(ctx, "unpacked", fileName)
|
|
||||||
library.relocationPacker.pack(ctx, outputFile, packedOutputFile, builderFlags)
|
|
||||||
}
|
|
||||||
|
|
||||||
if library.stripper.needsStrip(ctx) {
|
if library.stripper.needsStrip(ctx) {
|
||||||
// b/80093681, GNU strip/objcopy bug.
|
// b/80093681, GNU strip/objcopy bug.
|
||||||
// Use llvm-{strip,objcopy} when clang lld is used.
|
// Use llvm-{strip,objcopy} when clang lld is used.
|
||||||
|
@@ -1,100 +0,0 @@
|
|||||||
// Copyright 2016 Google Inc. All rights reserved.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
package cc
|
|
||||||
|
|
||||||
import (
|
|
||||||
"runtime"
|
|
||||||
|
|
||||||
"github.com/google/blueprint"
|
|
||||||
|
|
||||||
"android/soong/android"
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
pctx.SourcePathVariable("relocationPackerCmd", "prebuilts/misc/${config.HostPrebuiltTag}/relocation_packer/relocation_packer")
|
|
||||||
}
|
|
||||||
|
|
||||||
var relocationPackerRule = pctx.AndroidStaticRule("packRelocations",
|
|
||||||
blueprint.RuleParams{
|
|
||||||
Command: "rm -f $out && cp $in $out && $relocationPackerCmd $out",
|
|
||||||
CommandDeps: []string{"$relocationPackerCmd"},
|
|
||||||
})
|
|
||||||
|
|
||||||
type RelocationPackerProperties struct {
|
|
||||||
// Generate compact dynamic relocation table, default true.
|
|
||||||
Pack_relocations *bool `android:"arch_variant"`
|
|
||||||
|
|
||||||
// This will be true even if we're embedded in Make, in which case
|
|
||||||
// we'll defer to make to actually do the packing.
|
|
||||||
PackingRelocations bool `blueprint:"mutated"`
|
|
||||||
|
|
||||||
// Use clang lld instead of gnu ld.
|
|
||||||
Use_clang_lld *bool
|
|
||||||
}
|
|
||||||
|
|
||||||
type relocationPacker struct {
|
|
||||||
Properties RelocationPackerProperties
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *relocationPacker) useClangLld(ctx BaseModuleContext) bool {
|
|
||||||
if p.Properties.Use_clang_lld != nil {
|
|
||||||
return Bool(p.Properties.Use_clang_lld)
|
|
||||||
}
|
|
||||||
return ctx.Config().UseClangLld()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *relocationPacker) packingInit(ctx BaseModuleContext) {
|
|
||||||
enabled := true
|
|
||||||
// Relocation packer isn't available on Darwin yet
|
|
||||||
if runtime.GOOS == "darwin" {
|
|
||||||
enabled = false
|
|
||||||
}
|
|
||||||
if ctx.Target().Os != android.Android {
|
|
||||||
enabled = false
|
|
||||||
}
|
|
||||||
if ctx.Config().Getenv("DISABLE_RELOCATION_PACKER") == "true" {
|
|
||||||
enabled = false
|
|
||||||
}
|
|
||||||
// Relocation packer does not work with lld output files.
|
|
||||||
// Packed files won't load.
|
|
||||||
if p.useClangLld(ctx) {
|
|
||||||
enabled = false
|
|
||||||
}
|
|
||||||
if ctx.useSdk() {
|
|
||||||
enabled = false
|
|
||||||
}
|
|
||||||
if p.Properties.Pack_relocations != nil &&
|
|
||||||
*p.Properties.Pack_relocations == false {
|
|
||||||
enabled = false
|
|
||||||
}
|
|
||||||
|
|
||||||
p.Properties.PackingRelocations = enabled
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *relocationPacker) needsPacking(ctx ModuleContext) bool {
|
|
||||||
if ctx.Config().EmbeddedInMake() {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return p.Properties.PackingRelocations
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *relocationPacker) pack(ctx ModuleContext, in, out android.ModuleOutPath, flags builderFlags) {
|
|
||||||
ctx.Build(pctx, android.BuildParams{
|
|
||||||
Rule: relocationPackerRule,
|
|
||||||
Description: "pack relocations",
|
|
||||||
Output: out,
|
|
||||||
Input: in,
|
|
||||||
})
|
|
||||||
}
|
|
@@ -71,19 +71,20 @@ do_strip_keep_symbols() {
|
|||||||
|
|
||||||
do_strip_keep_mini_debug_info() {
|
do_strip_keep_mini_debug_info() {
|
||||||
rm -f "${outfile}.dynsyms" "${outfile}.funcsyms" "${outfile}.keep_symbols" "${outfile}.debug" "${outfile}.mini_debuginfo" "${outfile}.mini_debuginfo.xz"
|
rm -f "${outfile}.dynsyms" "${outfile}.funcsyms" "${outfile}.keep_symbols" "${outfile}.debug" "${outfile}.mini_debuginfo" "${outfile}.mini_debuginfo.xz"
|
||||||
|
local fail=
|
||||||
if [ ! -z "${use_llvm_strip}" ]; then
|
if [ ! -z "${use_llvm_strip}" ]; then
|
||||||
"${CLANG_BIN}/llvm-strip" --strip-all -keep=.ARM.attributes -remove-section=.comment "${infile}" "${outfile}.tmp"
|
"${CLANG_BIN}/llvm-strip" --strip-all -keep=.ARM.attributes -remove-section=.comment "${infile}" "${outfile}.tmp" || fail=true
|
||||||
else
|
else
|
||||||
"${CROSS_COMPILE}strip" --strip-all -R .comment "${infile}" -o "${outfile}.tmp"
|
"${CROSS_COMPILE}strip" --strip-all -R .comment "${infile}" -o "${outfile}.tmp" || fail=true
|
||||||
fi
|
fi
|
||||||
if [ "$?" == "0" ]; then
|
if [ -z $fail ]; then
|
||||||
# Current prebult llvm-objcopy does not support the following flags:
|
# Current prebult llvm-objcopy does not support the following flags:
|
||||||
# --only-keep-debug --rename-section --keep-symbols
|
# --only-keep-debug --rename-section --keep-symbols
|
||||||
# For the following use cases, ${CROSS_COMPILE}objcopy does fine with lld linked files,
|
# For the following use cases, ${CROSS_COMPILE}objcopy does fine with lld linked files,
|
||||||
# except the --add-section flag.
|
# except the --add-section flag.
|
||||||
"${CROSS_COMPILE}objcopy" --only-keep-debug "${infile}" "${outfile}.debug"
|
"${CROSS_COMPILE}objcopy" --only-keep-debug "${infile}" "${outfile}.debug"
|
||||||
"${CROSS_COMPILE}nm" -D "${infile}" --format=posix --defined-only | awk '{ print $$1 }' | sort >"${outfile}.dynsyms"
|
"${CROSS_COMPILE}nm" -D "${infile}" --format=posix --defined-only | awk '{ print $1 }' | sort >"${outfile}.dynsyms"
|
||||||
"${CROSS_COMPILE}nm" "${infile}" --format=posix --defined-only | awk '{ if ($$2 == "T" || $$2 == "t" || $$2 == "D") print $$1 }' | sort > "${outfile}.funcsyms"
|
"${CROSS_COMPILE}nm" "${infile}" --format=posix --defined-only | awk '{ if ($2 == "T" || $2 == "t" || $2 == "D") print $1 }' | sort > "${outfile}.funcsyms"
|
||||||
comm -13 "${outfile}.dynsyms" "${outfile}.funcsyms" > "${outfile}.keep_symbols"
|
comm -13 "${outfile}.dynsyms" "${outfile}.funcsyms" > "${outfile}.keep_symbols"
|
||||||
echo >> "${outfile}.keep_symbols" # Ensure that the keep_symbols file is not empty.
|
echo >> "${outfile}.keep_symbols" # Ensure that the keep_symbols file is not empty.
|
||||||
"${CROSS_COMPILE}objcopy" --rename-section .debug_frame=saved_debug_frame "${outfile}.debug" "${outfile}.mini_debuginfo"
|
"${CROSS_COMPILE}objcopy" --rename-section .debug_frame=saved_debug_frame "${outfile}.debug" "${outfile}.mini_debuginfo"
|
||||||
|
Reference in New Issue
Block a user