Export of internal Abseil changes
-- 167cd2647144583746311129b0cc98a89a9897e1 by Andy Soffer <asoffer@google.com>: Internal Changes PiperOrigin-RevId: 268000987 -- ab44fea7dfdaf763c69609a08ddfac22480ce520 by Derek Mauro <dmauro@google.com>: Fix flags Cmake tests on Windows PiperOrigin-RevId: 267859442 -- d7ec9f7611370b01bc9a5aed7e18460df2a15429 by Abseil Team <absl-team@google.com>: Fix undefined behavior in symbolize_elf.inc PiperOrigin-RevId: 267684904 -- e7c5f8e472a91ed99bdf4876942f2bda5751aa6c by Abseil Team <absl-team@google.com>: Turn off ABSL_HAS_ALARM on Fuchsia. PiperOrigin-RevId: 267666090 -- b7d25d5c71a49e697a8bf6440ed30f2e3f036420 by Chris Kennelly <ckennelly@google.com>: Mark once initialization function as no inline. We expect this code to run infrequently. PiperOrigin-RevId: 267649713 -- dc2a5e5f1e39a03fff837d34a319033fde55d9ba by Derek Mauro <dmauro@google.com>: Fix the MSVC CMake random build PiperOrigin-RevId: 267624074 -- ba2751b67fa17d1b6c53e5ba79f81a5371e4a03a by Abseil Team <absl-team@google.com>: Move "internal/flag.*" files to the "internal" build target. PiperOrigin-RevId: 267588996 -- 05b985a33eec4f8acff1809ad9218a1e22220f34 by Abseil Team <absl-team@google.com>: Move "internal/flag.*" files to the "internal" build target. PiperOrigin-RevId: 267580412 GitOrigin-RevId: 167cd2647144583746311129b0cc98a89a9897e1 Change-Id: Ibd334f46a5671c7c1d3fcf5354029e2fbb7ba91f
This commit is contained in:
parent
325fd7b042
commit
97c1664b4b
14 changed files with 154 additions and 62 deletions
|
@ -624,6 +624,13 @@ static bool InSection(const void *address, const ElfW(Shdr) * section) {
|
|||
return start <= address && address < (start + size);
|
||||
}
|
||||
|
||||
static const char *ComputeOffset(const char *base, ptrdiff_t offset) {
|
||||
// Note: cast to uintptr_t to avoid undefined behavior when base evaluates to
|
||||
// zero and offset is non-zero.
|
||||
return reinterpret_cast<const char *>(
|
||||
reinterpret_cast<uintptr_t>(base) + offset);
|
||||
}
|
||||
|
||||
// Read a symbol table and look for the symbol containing the
|
||||
// pc. Iterate over symbols in a symbol table and look for the symbol
|
||||
// containing "pc". If the symbol is found, and its name fits in
|
||||
|
@ -676,7 +683,8 @@ static ABSL_ATTRIBUTE_NOINLINE FindSymbolResult FindSymbol(
|
|||
// We keep the original address for opd redirection below.
|
||||
const char *const original_start_address =
|
||||
reinterpret_cast<const char *>(symbol.st_value);
|
||||
const char *start_address = original_start_address + relocation;
|
||||
const char *start_address =
|
||||
ComputeOffset(original_start_address, relocation);
|
||||
|
||||
if (deref_function_descriptor_pointer &&
|
||||
InSection(original_start_address, opd)) {
|
||||
|
@ -688,8 +696,7 @@ static ABSL_ATTRIBUTE_NOINLINE FindSymbolResult FindSymbol(
|
|||
|
||||
// If pc is inside the .opd section, it points to a function descriptor.
|
||||
const size_t size = pc_in_opd ? kFunctionDescriptorSize : symbol.st_size;
|
||||
const void *const end_address =
|
||||
reinterpret_cast<const char *>(start_address) + size;
|
||||
const void *const end_address = ComputeOffset(start_address, size);
|
||||
if (symbol.st_value != 0 && // Skip null value symbols.
|
||||
symbol.st_shndx != 0 && // Skip undefined symbols.
|
||||
#ifdef STT_TLS
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue