summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGiuliano Procida <gprocida@google.com>2022-01-11 16:34:12 +0000
committerDodji Seketeli <dodji@redhat.com>2022-01-17 17:06:47 +0100
commit4ab1e456c0740b944643d6d830c8ebc2c2151e08 (patch)
tree3abaf380fbfef6b4bd94cdaf3a34ecd7c5bd0729
parentInclude <libgen.h> in tools/abisym.cc for basename(3) (diff)
downloadlibabigail-4ab1e456c0740b944643d6d830c8ebc2c2151e08.tar.gz
libabigail-4ab1e456c0740b944643d6d830c8ebc2c2151e08.tar.bz2
libabigail-4ab1e456c0740b944643d6d830c8ebc2c2151e08.tar.xz
symtab reader: fix up alternative addresses
CFI symbols need special interpretation and this work is performed by the add_alternative_address_lookups method. Some symbol addresses need to be "tweaked" to be correctly interpreted and this must also happen in add_alternative_address_lookups. In particular, this commit fixes ARM32 CFI symbol interpretation. * src/abg-symtab-reader.cc (symtab::add_alternative_address_lookups): Tweak function addresses in the same manner as done in symtab::load_. Signed-off-by: Giuliano Procida <gprocida@google.com>
-rw-r--r--src/abg-symtab-reader.cc17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/abg-symtab-reader.cc b/src/abg-symtab-reader.cc
index 0f4d0b65..04e8b23c 100644
--- a/src/abg-symtab-reader.cc
+++ b/src/abg-symtab-reader.cc
@@ -351,6 +351,7 @@ symtab::load_(Elf* elf_handle,
351 elf_helpers::maybe_adjust_et_rel_sym_addr_to_abs_addr(elf_handle, 351 elf_helpers::maybe_adjust_et_rel_sym_addr_to_abs_addr(elf_handle,
352 sym); 352 sym);
353 353
354 // See also symtab::add_alternative_address_lookups.
354 if (symbol_sptr->is_function()) 355 if (symbol_sptr->is_function())
355 { 356 {
356 if (is_arm32) 357 if (is_arm32)
@@ -581,6 +582,9 @@ symtab::update_function_entry_address_symbol_map(
581void 582void
582symtab::add_alternative_address_lookups(Elf* elf_handle) 583symtab::add_alternative_address_lookups(Elf* elf_handle)
583{ 584{
585 const bool is_arm32 = elf_helpers::architecture_is_arm32(elf_handle);
586 const bool is_ppc64 = elf_helpers::architecture_is_ppc64(elf_handle);
587
584 Elf_Scn* symtab_section = elf_helpers::find_symtab_section(elf_handle); 588 Elf_Scn* symtab_section = elf_helpers::find_symtab_section(elf_handle);
585 if (!symtab_section) 589 if (!symtab_section)
586 return; 590 return;
@@ -634,6 +638,19 @@ symtab::add_alternative_address_lookups(Elf* elf_handle)
634 elf_helpers::maybe_adjust_et_rel_sym_addr_to_abs_addr( 638 elf_helpers::maybe_adjust_et_rel_sym_addr_to_abs_addr(
635 elf_handle, sym); 639 elf_handle, sym);
636 640
641 // See also symtab::load_.
642 if (symbol_sptr->is_function())
643 {
644 if (is_arm32)
645 // Clear bit zero of ARM32 addresses as per "ELF for the Arm
646 // Architecture" section 5.5.3.
647 // https://static.docs.arm.com/ihi0044/g/aaelf32.pdf
648 symbol_value &= ~1;
649 else if (is_ppc64)
650 update_function_entry_address_symbol_map(elf_handle, sym,
651 symbol_sptr);
652 }
653
637 const auto result = 654 const auto result =
638 addr_symbol_map_.emplace(symbol_value, symbol_sptr); 655 addr_symbol_map_.emplace(symbol_value, symbol_sptr);
639 ABG_ASSERT(result.second); 656 ABG_ASSERT(result.second);