Note on handling Android special symbols

Dmitry Antipov <[email protected]>
Newsgroups gmane.comp.gdb.devel
Message-ID <[email protected]>
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
android_oat_odex_special_symbols.patch (text/x-patch, 1.1 KB)
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.  */
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.