From: vvvvvv@google.com
To: libabigail@sourceware.org
Cc: kernel-team@android.com, maennich@google.com, vvvvvv@google.com
Subject: [PATCH] symtab: fix getting CRC in relocatable modules
Date: Sat, 28 Jan 2023 00:08:18 +0000 [thread overview]
Message-ID: <20230128000818.1605970-1-vvvvvv@google.com> (raw)
From: Aleksei Vetrov <vvvvvv@google.com>
In ELF with ET_REL type symbol value holds not absolute but relative to
section value. This patch applies adjustment to the address, used in CRC
value extraction.
* src/abg-elf-helpers.cc (get_crc_for_symbol): Rename
crc_symbol_value to crc_symbol_address and adjust it for
relocatable ELF types.
Signed-off-by: Aleksei Vetrov <vvvvvv@google.com>
---
src/abg-elf-helpers.cc | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/abg-elf-helpers.cc b/src/abg-elf-helpers.cc
index 5d8e3188..d61114bf 100644
--- a/src/abg-elf-helpers.cc
+++ b/src/abg-elf-helpers.cc
@@ -920,10 +920,11 @@ bool
get_crc_for_symbol(Elf* elf_handle, GElf_Sym* crc_symbol, uint32_t& crc_value)
{
size_t crc_section_index = crc_symbol->st_shndx;
- uint64_t crc_symbol_value = crc_symbol->st_value;
+ GElf_Addr crc_symbol_address =
+ maybe_adjust_et_rel_sym_addr_to_abs_addr(elf_handle, crc_symbol);
if (crc_section_index == SHN_ABS)
{
- crc_value = crc_symbol_value;
+ crc_value = crc_symbol_address;
return true;
}
@@ -940,10 +941,10 @@ get_crc_for_symbol(Elf* elf_handle, GElf_Sym* crc_symbol, uint32_t& crc_value)
if (kcrctab_data == NULL)
return false;
- if (crc_symbol_value < sheader->sh_addr)
+ if (crc_symbol_address < sheader->sh_addr)
return false;
- size_t offset = crc_symbol_value - sheader->sh_addr;
+ size_t offset = crc_symbol_address - sheader->sh_addr;
if (offset + sizeof(uint32_t) > kcrctab_data->d_size
|| offset + sizeof(uint32_t) > sheader->sh_size)
return false;
--
2.39.1.456.gfc5497dd1b-goog
next reply other threads:[~2023-01-28 0:08 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-28 0:08 vvvvvv [this message]
2023-01-31 10:09 ` Dodji Seketeli
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=20230128000818.1605970-1-vvvvvv@google.com \
--to=vvvvvv@google.com \
--cc=kernel-team@android.com \
--cc=libabigail@sourceware.org \
--cc=maennich@google.com \
/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).