platform_system_core/libunwindstack/Android.bp
Christopher Ferris b7de5f5429 Demand read load bias for a map.
Add a static GetLoadBias method to the Elf object that only reads just
enough to get the load bias.

Add a method to MapInfo that gets the load bias. First attempt to get
it if the elf object already exists. If no elf object was created, use
the new static method to get the load bias.

In BacktraceMap, add a custom iterator so that when code dereferences
a map element, that's when the load bias will be retrieved if it hasn't
already been set.

Bug: 69871050

Test: New unit tests, verify tombstones have non-zero load bias values for
Test: libraries with a non-zero load bias.
Change-Id: I125f4abc827589957fce2f0df24b0f25d037d732
2017-12-05 13:12:47 -08:00

213 lines
4.9 KiB
Text

//
// Copyright (C) 2017 The Android Open Source Project
//
// 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.
//
cc_defaults {
name: "libunwindstack_flags",
host_supported: true,
cflags: [
"-Wall",
"-Werror",
"-Wextra",
],
target: {
darwin: {
enabled: false,
},
linux_bionic: {
enabled: true,
},
},
}
cc_library {
name: "libunwindstack",
vendor_available: true,
vndk: {
enabled: true,
support_system_process: true,
},
defaults: ["libunwindstack_flags"],
export_include_dirs: ["include"],
srcs: [
"ArmExidx.cpp",
"DwarfCfa.cpp",
"DwarfEhFrameWithHdr.cpp",
"DwarfMemory.cpp",
"DwarfOp.cpp",
"DwarfSection.cpp",
"Elf.cpp",
"ElfInterface.cpp",
"ElfInterfaceArm.cpp",
"Log.cpp",
"MapInfo.cpp",
"Maps.cpp",
"Memory.cpp",
"Regs.cpp",
"Unwinder.cpp",
"Symbols.cpp",
],
cflags: [
"-Wexit-time-destructors",
],
target: {
// Always disable optimizations for host to make it easier to debug.
host: {
cflags: ["-O0", "-g"],
},
},
arch: {
x86: {
srcs: ["AsmGetRegsX86.S"],
},
x86_64: {
srcs: ["AsmGetRegsX86_64.S"],
},
},
shared_libs: [
"libbase",
"liblog",
"liblzma",
],
}
//-------------------------------------------------------------------------
// Unit Tests
//-------------------------------------------------------------------------
cc_test {
name: "libunwindstack_test",
defaults: ["libunwindstack_flags"],
srcs: [
"tests/ArmExidxDecodeTest.cpp",
"tests/ArmExidxExtractTest.cpp",
"tests/DwarfCfaLogTest.cpp",
"tests/DwarfCfaTest.cpp",
"tests/DwarfDebugFrameTest.cpp",
"tests/DwarfEhFrameTest.cpp",
"tests/DwarfEhFrameWithHdrTest.cpp",
"tests/DwarfMemoryTest.cpp",
"tests/DwarfOpLogTest.cpp",
"tests/DwarfOpTest.cpp",
"tests/DwarfSectionTest.cpp",
"tests/DwarfSectionImplTest.cpp",
"tests/ElfFake.cpp",
"tests/ElfInterfaceArmTest.cpp",
"tests/ElfInterfaceTest.cpp",
"tests/ElfTest.cpp",
"tests/ElfTestUtils.cpp",
"tests/LogFake.cpp",
"tests/MapInfoGetElfTest.cpp",
"tests/MapInfoGetLoadBiasTest.cpp",
"tests/MapsTest.cpp",
"tests/MemoryBufferTest.cpp",
"tests/MemoryFake.cpp",
"tests/MemoryFileTest.cpp",
"tests/MemoryLocalTest.cpp",
"tests/MemoryRangeTest.cpp",
"tests/MemoryRemoteTest.cpp",
"tests/MemoryTest.cpp",
"tests/RegsIterateTest.cpp",
"tests/RegsStepIfSignalHandlerTest.cpp",
"tests/RegsTest.cpp",
"tests/SymbolsTest.cpp",
"tests/UnwindOfflineTest.cpp",
"tests/UnwindTest.cpp",
"tests/UnwinderTest.cpp",
],
cflags: [
"-O0",
"-g",
],
shared_libs: [
"libbase",
"liblog",
"liblzma",
"libunwindstack",
],
static_libs: [
"libgmock",
],
data: [
"tests/files/elf32.xz",
"tests/files/elf64.xz",
"tests/files/offline/straddle_arm32/*",
"tests/files/offline/straddle_arm64/*",
],
}
//-------------------------------------------------------------------------
// Tools
//-------------------------------------------------------------------------
cc_defaults {
name: "libunwindstack_tools",
defaults: ["libunwindstack_flags"],
shared_libs: [
"libunwindstack",
"libbase",
"liblzma",
],
}
cc_binary {
name: "unwind",
defaults: ["libunwindstack_tools"],
srcs: [
"tools/unwind.cpp",
],
}
cc_binary {
name: "unwind_info",
defaults: ["libunwindstack_tools"],
srcs: [
"tools/unwind_info.cpp",
],
}
cc_binary {
name: "unwind_symbols",
defaults: ["libunwindstack_tools"],
srcs: [
"tools/unwind_symbols.cpp",
],
}
// Generates the elf data for use in the tests for .gnu_debugdata frames.
// Once these files are generated, use the xz command to compress the data.
cc_binary_host {
name: "gen_gnudebugdata",
defaults: ["libunwindstack_flags"],
srcs: [
"tests/GenGnuDebugdata.cpp",
],
}