aboutsummaryrefslogtreecommitdiff
path: root/ltrace-elf.c
diff options
context:
space:
mode:
authorPetr Machata <pmachata@redhat.com>2012-04-30 20:53:22 +0200
committerPetr Machata <pmachata@redhat.com>2012-04-30 20:53:22 +0200
commit5b3e26acd50d74e8b7c007f8b5dfb1a825ef9aff (patch)
tree772060b93ec39b2fefdb03d908d1abf6d4252f81 /ltrace-elf.c
parent3a01cd7a2fcf200cedd0770e137a28764f679c3c (diff)
downloadltrace-5b3e26acd50d74e8b7c007f8b5dfb1a825ef9aff.tar.gz
Add elf_get_section_named
Document elf_get_section_* in ChangeLog
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)
{