* [PATCH 1/2] elf_helpers: new utility function find_strtab_for_symtab_section
@ 2021-11-10 12:50 Jose E. Marchesi
2021-11-10 12:50 ` [PATCH 2/2] abg-ctf-reader: use the right string table for CTF data Jose E. Marchesi
2021-11-10 15:53 ` [PATCH 1/2] elf_helpers: new utility function find_strtab_for_symtab_section Dodji Seketeli
0 siblings, 2 replies; 4+ messages in thread
From: Jose E. Marchesi @ 2021-11-10 12:50 UTC (permalink / raw)
To: libabigail
This patch adds a new utility function that, given a section
containing a symbol table, returns the corresponding string table
section.
Signed-off-by: Jose E. Marchesi <jose.marchesi@oracle.com>
* src/abg-elf-helpers.h: Prototype for find_strtab_for_symtab_section.
* src/abg-elf-helpers.cc (find_strtab_for_symtab_section): New function.
---
src/abg-elf-helpers.cc | 23 +++++++++++++++++++++++
src/abg-elf-helpers.h | 4 ++++
2 files changed, 27 insertions(+)
diff --git a/src/abg-elf-helpers.cc b/src/abg-elf-helpers.cc
index 998675a6..ee631831 100644
--- a/src/abg-elf-helpers.cc
+++ b/src/abg-elf-helpers.cc
@@ -649,6 +649,29 @@ find_relocation_section(Elf* elf_handle, Elf_Scn* target_section)
return NULL;
}
+/// Return the string table used by the given symbol table.
+///
+/// @param elf_handle the elf handle to use.
+///
+/// @param symtab_section section containing a symbol table.
+///
+/// @return the string table linked by the symtab, if it is not NULL.
+Elf_Scn*
+find_strtab_for_symtab_section(Elf* elf_handle, Elf_Scn* symtab_section)
+{
+ Elf_Scn *strtab_section = NULL;
+
+ if (symtab_section)
+ {
+ GElf_Shdr symtab_shdr_mem, *symtab_shdr;
+
+ symtab_shdr = gelf_getshdr(symtab_section, &symtab_shdr_mem);
+ strtab_section = elf_getscn(elf_handle, symtab_shdr->sh_link);
+ }
+
+ return strtab_section;
+}
+
/// Get the version definition (from the SHT_GNU_verdef section) of a
/// given symbol represented by a pointer to GElf_Versym.
///
diff --git a/src/abg-elf-helpers.h b/src/abg-elf-helpers.h
index 59ea0a74..718ce9c1 100644
--- a/src/abg-elf-helpers.h
+++ b/src/abg-elf-helpers.h
@@ -112,6 +112,10 @@ find_ksymtab_strings_section(Elf *elf_handle);
Elf_Scn*
find_relocation_section(Elf* elf_handle, Elf_Scn* target_section);
+Elf_Scn*
+find_strtab_for_symtab_section(Elf* elf_handle,
+ Elf_Scn* symtab_section);
+
//
// Helpers for symbol versioning
//
--
2.11.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/2] abg-ctf-reader: use the right string table for CTF data
2021-11-10 12:50 [PATCH 1/2] elf_helpers: new utility function find_strtab_for_symtab_section Jose E. Marchesi
@ 2021-11-10 12:50 ` Jose E. Marchesi
2021-11-10 15:54 ` Dodji Seketeli
2021-11-10 15:53 ` [PATCH 1/2] elf_helpers: new utility function find_strtab_for_symtab_section Dodji Seketeli
1 sibling, 1 reply; 4+ messages in thread
From: Jose E. Marchesi @ 2021-11-10 12:50 UTC (permalink / raw)
To: libabigail
The CTF library needs the string table associated with the symbol
table of the ELF file. This patch makes the CTF reader to use the
right string table.
Signed-off-by: Jose E. Marchesi <jose.marchesi@oracle.com>
* src/abg-ctf-reader.cc (slurp_elf_info): Use
find_strtab_for_symtab_section.
---
src/abg-ctf-reader.cc | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/abg-ctf-reader.cc b/src/abg-ctf-reader.cc
index 51fb2ed9..27eddc2e 100644
--- a/src/abg-ctf-reader.cc
+++ b/src/abg-ctf-reader.cc
@@ -1040,7 +1040,8 @@ slurp_elf_info(read_context *ctxt, corpus_sptr corp)
/* Get the raw ELF section contents for libctf. */
Elf_Scn *ctf_scn = elf_helpers::find_section(ctxt->elf_handler, ".ctf", SHT_PROGBITS);
Elf_Scn *symtab_scn = elf_helpers::find_symbol_table_section(ctxt->elf_handler);
- Elf_Scn *strtab_scn = elf_helpers::find_section(ctxt->elf_handler, SHT_STRTAB);
+ Elf_Scn *strtab_scn = elf_helpers::find_strtab_for_symtab_section(ctxt->elf_handler,
+ symtab_scn);
if (ctf_scn == NULL || symtab_scn == NULL || strtab_scn == NULL)
return 0;
--
2.11.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] elf_helpers: new utility function find_strtab_for_symtab_section
2021-11-10 12:50 [PATCH 1/2] elf_helpers: new utility function find_strtab_for_symtab_section Jose E. Marchesi
2021-11-10 12:50 ` [PATCH 2/2] abg-ctf-reader: use the right string table for CTF data Jose E. Marchesi
@ 2021-11-10 15:53 ` Dodji Seketeli
1 sibling, 0 replies; 4+ messages in thread
From: Dodji Seketeli @ 2021-11-10 15:53 UTC (permalink / raw)
To: Jose E. Marchesi via Libabigail
"Jose E. Marchesi via Libabigail" <libabigail@sourceware.org> a écrit:
> This patch adds a new utility function that, given a section
> containing a symbol table, returns the corresponding string table
> section.
>
> Signed-off-by: Jose E. Marchesi <jose.marchesi@oracle.com>
>
> * src/abg-elf-helpers.h: Prototype for find_strtab_for_symtab_section.
> * src/abg-elf-helpers.cc (find_strtab_for_symtab_section): New function.
Applied to master. Thanks!
Cheers,
--
Dodji
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] abg-ctf-reader: use the right string table for CTF data
2021-11-10 12:50 ` [PATCH 2/2] abg-ctf-reader: use the right string table for CTF data Jose E. Marchesi
@ 2021-11-10 15:54 ` Dodji Seketeli
0 siblings, 0 replies; 4+ messages in thread
From: Dodji Seketeli @ 2021-11-10 15:54 UTC (permalink / raw)
To: Jose E. Marchesi via Libabigail
"Jose E. Marchesi via Libabigail" <libabigail@sourceware.org> a écrit:
> The CTF library needs the string table associated with the symbol
> table of the ELF file. This patch makes the CTF reader to use the
> right string table.
>
> Signed-off-by: Jose E. Marchesi <jose.marchesi@oracle.com>
>
> * src/abg-ctf-reader.cc (slurp_elf_info): Use
> find_strtab_for_symtab_section.
Applied to master. Thanks!
Cheers,
--
Dodji
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-11-10 15:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-10 12:50 [PATCH 1/2] elf_helpers: new utility function find_strtab_for_symtab_section Jose E. Marchesi
2021-11-10 12:50 ` [PATCH 2/2] abg-ctf-reader: use the right string table for CTF data Jose E. Marchesi
2021-11-10 15:54 ` Dodji Seketeli
2021-11-10 15:53 ` [PATCH 1/2] elf_helpers: new utility function find_strtab_for_symtab_section Dodji Seketeli
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).