summaryrefslogtreecommitdiff
path: root/tools/apriori/source.c
diff options
context:
space:
mode:
author The Android Open Source Project <initial-contribution@android.com> 2009-03-03 19:28:42 -0800
committer The Android Open Source Project <initial-contribution@android.com> 2009-03-03 19:28:42 -0800
commit88b607994a148f4af5bffee163e39ce8296750c6 (patch)
treefa249ff843e976cf034f2029437d3362a8396321 /tools/apriori/source.c
parent05806d7af62e07c6225b2e7103a1b115ecf6c9ad (diff)
auto import from //depot/cupcake/@135843
Diffstat (limited to 'tools/apriori/source.c')
-rw-r--r--tools/apriori/source.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/tools/apriori/source.c b/tools/apriori/source.c
new file mode 100644
index 0000000000..69c57c7746
--- /dev/null
+++ b/tools/apriori/source.c
@@ -0,0 +1,18 @@
+#include <source.h>
+
+void find_section(source_t *source, Elf64_Addr address,
+ Elf_Scn **scn,
+ GElf_Shdr *shdr,
+ Elf_Data **data)
+{
+ range_t *range = find_range(source->sorted_sections, address);
+ FAILIF(NULL == range,
+ "Cannot match address %lld to any range in [%s]!\n",
+ address,
+ source->name);
+ *scn = (Elf_Scn *)range->user;
+ ASSERT(*scn);
+ FAILIF_LIBELF(NULL == gelf_getshdr(*scn, shdr), gelf_getshdr);
+ *data = elf_getdata(*scn, NULL);
+ FAILIF_LIBELF(NULL == *data, elf_getdata);
+}