This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Note on handling Android special symbols
- From: Dmitry Antipov <dantipov at nvidia dot com>
- To: <gdb at sourceware dot org>
- Cc: Ryan Bissell <rbissell at nvidia dot com>, Mikhail Filimonov <mfilimonov at nvidia dot com>
- Date: Mon, 29 Jan 2018 13:17:35 +0300
- Subject: Note on handling Android special symbols
- Authentication-results: sourceware.org; auth=none
- References: <CAOMFOmW-CcOLpM47JXn4_y9mwR+Ba7qr-zi5sa=n6O2PWNKcww@mail.gmail.com>
It seems that some special Android ART symbols in .oat and .odex framework
libraries can prevent GDB to detect ARM/Thumb mode under some circumstances;
since LLDB is known to have a kinda workaround, shouldn't GDB incorporate
something similar? See https://github.com/android-ndk/ndk/issues/628 and
https://reviews.llvm.org/rL274500 for details.
Dmitry
diff --git a/gdb/elfread.c b/gdb/elfread.c
index 103b2144c3..f144cdd45f 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -241,6 +241,11 @@ elf_symtab_read (minimal_symbol_reader &reader,
int stripped = (bfd_get_symcount (objfile->obfd) == 0);
int elf_make_msymbol_special_p
= gdbarch_elf_make_msymbol_special_p (gdbarch);
+ /* Hack to skip some special Android symbols. Stolen
+ from LLDB, see https://reviews.llvm.org/rL274500. */
+ const char *ext = strrchr (objfile_name (objfile), '.');
+ int skip_android_special_symbols_p
+ = ext ? (!strcmp (ext + 1, "oat") || !strcmp (ext + 1, "odex")) : 0;
for (i = 0; i < number_of_symbols; i++)
{
@@ -252,6 +257,11 @@ elf_symtab_read (minimal_symbol_reader &reader,
continue;
}
+ if (skip_android_special_symbols_p &&
+ (!strcmp (sym->name, "oatdata") ||
+ !strcmp (sym->name, "oatexec")))
+ continue;
+
/* Skip "special" symbols, e.g. ARM mapping symbols. These are
symbols which do not correspond to objects in the symbol table,
but have some other target-specific meaning. */