summaryrefslogtreecommitdiffstats
path: root/src/backends/ppc64_resolve_sym.c
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2015-02-25 16:51:55 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-02-25 16:51:55 +0000
commit412f6b917fc658c24dd7d624bb82bf1a1e791b95 (patch)
treea63e40b5dd9927bd04ec7427c8797975c2a71f85 /src/backends/ppc64_resolve_sym.c
parenta969285f70219c5d35ee5aa8ceab0f532fc1e54d (diff)
parent7401a30e8b3a0de25d7e8a6b635fc33f45894118 (diff)
downloadandroid_external_elfutils-412f6b917fc658c24dd7d624bb82bf1a1e791b95.tar.gz
android_external_elfutils-412f6b917fc658c24dd7d624bb82bf1a1e791b95.tar.bz2
android_external_elfutils-412f6b917fc658c24dd7d624bb82bf1a1e791b95.zip
am 7401a30e: am 36e62782: Merge "Upgrade to elfutils 0.161."
* commit '7401a30e8b3a0de25d7e8a6b635fc33f45894118': Upgrade to elfutils 0.161.
Diffstat (limited to 'src/backends/ppc64_resolve_sym.c')
-rw-r--r--src/backends/ppc64_resolve_sym.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/backends/ppc64_resolve_sym.c b/src/backends/ppc64_resolve_sym.c
new file mode 100644
index 00000000..03f65584
--- /dev/null
+++ b/src/backends/ppc64_resolve_sym.c
@@ -0,0 +1,63 @@
+/* Resolve symbol values through .opd function descriptors.
+ Copyright (C) 2013 Red Hat, Inc.
+ This file is part of elfutils.
+
+ This file is free software; you can redistribute it and/or modify
+ it under the terms of either
+
+ * the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 3 of the License, or (at
+ your option) any later version
+
+ or
+
+ * the GNU General Public License as published by the Free
+ Software Foundation; either version 2 of the License, or (at
+ your option) any later version
+
+ or both in parallel, as here.
+
+ elfutils is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received copies of the GNU General Public License and
+ the GNU Lesser General Public License along with this program. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#define BACKEND ppc64_
+#include "libebl_CPU.h"
+
+/* Resolve a function descriptor if addr points into the .opd section.
+ The .opd section contains function descriptors consisting of 3 addresses.
+ function, toc and chain. We are just interested in the first.
+ http://refspecs.linuxfoundation.org/ELF/ppc64/PPC-elf64abi-1.9.html#FUNC-DES
+
+ Returns true if the given address could be resolved, false otherwise.
+*/
+bool
+ppc64_resolve_sym_value (Ebl *ebl, GElf_Addr *addr)
+{
+ if (ebl->fd_data != NULL && *addr >= ebl->fd_addr
+ && *addr + sizeof (Elf64_Addr) <= ebl->fd_addr + ebl->fd_data->d_size)
+ {
+ GElf_Ehdr ehdr_mem, *ehdr = gelf_getehdr (ebl->elf, &ehdr_mem);
+ if (ehdr != NULL)
+ {
+ Elf_Data opd_in, opd_out;
+ opd_in.d_buf = ebl->fd_data->d_buf + (*addr - ebl->fd_addr);
+ opd_out.d_buf = addr;
+ opd_out.d_size = opd_in.d_size = sizeof (Elf64_Addr);
+ opd_out.d_type = opd_in.d_type = ELF_T_ADDR;
+ if (elf64_xlatetom (&opd_out, &opd_in,
+ ehdr->e_ident[EI_DATA]) != NULL)
+ return true;
+ }
+ }
+ return false;
+}