aboutsummaryrefslogtreecommitdiff
path: root/ltrace-elf.c
diff options
context:
space:
mode:
Diffstat (limited to 'ltrace-elf.c')
-rw-r--r--ltrace-elf.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/ltrace-elf.c b/ltrace-elf.c
index 3f0c636..19f1c64 100644
--- a/ltrace-elf.c
+++ b/ltrace-elf.c
@@ -143,6 +143,33 @@ elf_get_section_type(struct ltelf *lte, GElf_Word type,
&type_p, &type);
}
+struct section_named_data {
+ struct ltelf *lte;
+ const char *name;
+};
+
+static int
+name_p(Elf_Scn *scn, GElf_Shdr *shdr, void *d)
+{
+ struct section_named_data *data = d;
+ const char *name = elf_strptr(data->lte->elf,
+ data->lte->ehdr.e_shstrndx,
+ shdr->sh_name);
+ return strcmp(name, data->name) == 0;
+}
+
+int
+elf_get_section_named(struct ltelf *lte, const char *name,
+ Elf_Scn **tgt_sec, GElf_Shdr *tgt_shdr)
+{
+ struct section_named_data data = {
+ .lte = lte,
+ .name = name,
+ };
+ return elf_get_section_if(lte, tgt_sec, tgt_shdr,
+ &name_p, &data);
+}
+
static int
need_data(Elf_Data *data, GElf_Xword offset, GElf_Xword size)
{