From: Giuliano Procida <gprocida@google.com>
To: libabigail@sourceware.org
Cc: dodji@seketeli.org, kernel-team@android.com, gprocida@google.com,
maennich@google.com, mark@klomp.org
Subject: [PATCH 1/1] symtab reader: fix up alternative addresses
Date: Tue, 11 Jan 2022 16:34:12 +0000 [thread overview]
Message-ID: <20220111163412.3012602-2-gprocida@google.com> (raw)
In-Reply-To: <20220111163412.3012602-1-gprocida@google.com>
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>
---
src/abg-symtab-reader.cc | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
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,
elf_helpers::maybe_adjust_et_rel_sym_addr_to_abs_addr(elf_handle,
sym);
+ // See also symtab::add_alternative_address_lookups.
if (symbol_sptr->is_function())
{
if (is_arm32)
@@ -581,6 +582,9 @@ symtab::update_function_entry_address_symbol_map(
void
symtab::add_alternative_address_lookups(Elf* elf_handle)
{
+ const bool is_arm32 = elf_helpers::architecture_is_arm32(elf_handle);
+ const bool is_ppc64 = elf_helpers::architecture_is_ppc64(elf_handle);
+
Elf_Scn* symtab_section = elf_helpers::find_symtab_section(elf_handle);
if (!symtab_section)
return;
@@ -634,6 +638,19 @@ symtab::add_alternative_address_lookups(Elf* elf_handle)
elf_helpers::maybe_adjust_et_rel_sym_addr_to_abs_addr(
elf_handle, sym);
+ // See also symtab::load_.
+ if (symbol_sptr->is_function())
+ {
+ if (is_arm32)
+ // Clear bit zero of ARM32 addresses as per "ELF for the Arm
+ // Architecture" section 5.5.3.
+ // https://static.docs.arm.com/ihi0044/g/aaelf32.pdf
+ symbol_value &= ~1;
+ else if (is_ppc64)
+ update_function_entry_address_symbol_map(elf_handle, sym,
+ symbol_sptr);
+ }
+
const auto result =
addr_symbol_map_.emplace(symbol_value, symbol_sptr);
ABG_ASSERT(result.second);
--
2.34.1.575.g55b058a8bb-goog
next prev parent reply other threads:[~2022-01-11 16:34 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-11 16:34 [PATCH 0/1] Fix interpretation of ARM32 CFI Giuliano Procida
2022-01-11 16:34 ` Giuliano Procida [this message]
2022-01-11 17:46 ` Mark Wielaard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220111163412.3012602-2-gprocida@google.com \
--to=gprocida@google.com \
--cc=dodji@seketeli.org \
--cc=kernel-team@android.com \
--cc=libabigail@sourceware.org \
--cc=maennich@google.com \
--cc=mark@klomp.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).