Cherry-pick 7.11 changes to 8.3

Cherry-picked commits:
c64829b: Fallback to open if multifs_open fails.
2177073: Fix gdbserver process interruption.
35ee683: Remove gdb hack.
78af0f6: Handle cross compile for locale configuration
5cbd102: Specify osabi in arm/aarch64 tdescs.
dfc5ca4: Set the default gdb osabi to GNU/Linux.

Bug: 62547070
Test: build
Change-Id: I00a97aa866255ed853c13b8f11dc1a996ea810f2
diff --git a/gdb-8.3/bfd/elf-bfd.h b/gdb-8.3/bfd/elf-bfd.h
index 56cddda..9e1e00c 100644
--- a/gdb-8.3/bfd/elf-bfd.h
+++ b/gdb-8.3/bfd/elf-bfd.h
@@ -689,7 +689,7 @@
 
 struct elf_size_info {
   unsigned char sizeof_ehdr, sizeof_phdr, sizeof_shdr;
-  unsigned char sizeof_rel, sizeof_rela, sizeof_sym, sizeof_dyn, sizeof_note;
+  unsigned char sizeof_rel, sizeof_rela, sizeof_relr, sizeof_sym, sizeof_dyn, sizeof_note;
 
   /* The size of entries in the .hash section.  */
   unsigned char sizeof_hash_entry;
diff --git a/gdb-8.3/bfd/elf.c b/gdb-8.3/bfd/elf.c
index f16acaa..fdec27d 100644
--- a/gdb-8.3/bfd/elf.c
+++ b/gdb-8.3/bfd/elf.c
@@ -1718,6 +1718,9 @@
 	    case DT_RELA: name = "RELA"; break;
 	    case DT_RELASZ: name = "RELASZ"; break;
 	    case DT_RELAENT: name = "RELAENT"; break;
+	    case DT_RELR: name = "RELR"; break;
+	    case DT_RELRSZ: name = "RELRSZ"; break;
+	    case DT_RELRENT: name = "RELRENT"; break;
 	    case DT_STRSZ: name = "STRSZ"; break;
 	    case DT_SYMENT: name = "SYMENT"; break;
 	    case DT_INIT: name = "INIT"; break;
@@ -1755,6 +1758,7 @@
 	    case DT_PLTPAD: name = "PLTPAD"; break;
 	    case DT_MOVETAB: name = "MOVETAB"; break;
 	    case DT_SYMINFO: name = "SYMINFO"; break;
+	    case DT_RELRCOUNT: name = "RELRCOUNT"; break;
 	    case DT_RELACOUNT: name = "RELACOUNT"; break;
 	    case DT_RELCOUNT: name = "RELCOUNT"; break;
 	    case DT_FLAGS_1: name = "FLAGS_1"; break;
@@ -2322,16 +2326,30 @@
 
     case SHT_REL:
     case SHT_RELA:
+    case SHT_RELR:
       /* *These* do a lot of work -- but build no sections!  */
       {
 	asection *target_sect;
 	Elf_Internal_Shdr *hdr2, **p_hdr;
 	unsigned int num_sec = elf_numsections (abfd);
 	struct bfd_elf_section_data *esdt;
+	bfd_size_type size;
 
-	if (hdr->sh_entsize
-	    != (bfd_size_type) (hdr->sh_type == SHT_REL
-				? bed->s->sizeof_rel : bed->s->sizeof_rela))
+	switch (hdr->sh_type)
+	{
+        case SHT_REL:
+	  size = bed->s->sizeof_rel;
+	  break;
+        case SHT_RELA:
+	  size = bed->s->sizeof_rela;
+	  break;
+        case SHT_RELR:
+	  size = bed->s->sizeof_relr;
+	  break;
+        default:
+	  goto fail;
+        }
+	if (hdr->sh_entsize  != size)
 	  goto fail;
 
 	/* Check for a bogus link to avoid crashing.  */
@@ -2401,7 +2419,8 @@
 	    || hdr->sh_info == SHN_UNDEF
 	    || hdr->sh_info >= num_sec
 	    || elf_elfsections (abfd)[hdr->sh_info]->sh_type == SHT_REL
-	    || elf_elfsections (abfd)[hdr->sh_info]->sh_type == SHT_RELA)
+	    || elf_elfsections (abfd)[hdr->sh_info]->sh_type == SHT_RELA
+	    || elf_elfsections (abfd)[hdr->sh_info]->sh_type == SHT_RELR)
 	  {
 	    ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name,
 						   shindex);
diff --git a/gdb-8.3/bfd/elf32-arm.c b/gdb-8.3/bfd/elf32-arm.c
index 28ee9d5..53115bc 100644
--- a/gdb-8.3/bfd/elf32-arm.c
+++ b/gdb-8.3/bfd/elf32-arm.c
@@ -19825,6 +19825,7 @@
   sizeof (Elf32_External_Shdr),
   sizeof (Elf32_External_Rel),
   sizeof (Elf32_External_Rela),
+  sizeof (Elf32_External_Relr),
   sizeof (Elf32_External_Sym),
   sizeof (Elf32_External_Dyn),
   sizeof (Elf_External_Note),
diff --git a/gdb-8.3/bfd/elfcode.h b/gdb-8.3/bfd/elfcode.h
index ec5ea76..df8e547 100644
--- a/gdb-8.3/bfd/elfcode.h
+++ b/gdb-8.3/bfd/elfcode.h
@@ -80,6 +80,7 @@
 #define Elf_External_Phdr	NAME(Elf,External_Phdr)
 #define Elf_External_Rel	NAME(Elf,External_Rel)
 #define Elf_External_Rela	NAME(Elf,External_Rela)
+#define Elf_External_Relr	NAME(Elf,External_Relr)
 #define Elf_External_Dyn	NAME(Elf,External_Dyn)
 
 #define elf_core_file_failing_command	NAME(bfd_elf,core_file_failing_command)
@@ -1912,6 +1913,7 @@
   sizeof (Elf_External_Shdr),
   sizeof (Elf_External_Rel),
   sizeof (Elf_External_Rela),
+  sizeof (Elf_External_Relr),
   sizeof (Elf_External_Sym),
   sizeof (Elf_External_Dyn),
   sizeof (Elf_External_Note),
diff --git a/gdb-8.3/bfd/elfnn-aarch64.c b/gdb-8.3/bfd/elfnn-aarch64.c
index faa2761..7da34e0 100644
--- a/gdb-8.3/bfd/elfnn-aarch64.c
+++ b/gdb-8.3/bfd/elfnn-aarch64.c
@@ -9626,6 +9626,7 @@
   sizeof (ElfNN_External_Shdr),
   sizeof (ElfNN_External_Rel),
   sizeof (ElfNN_External_Rela),
+  sizeof (ElfNN_External_Relr),
   sizeof (ElfNN_External_Sym),
   sizeof (ElfNN_External_Dyn),
   sizeof (Elf_External_Note),
diff --git a/gdb-8.3/gdb/arch/aarch64.c b/gdb-8.3/gdb/arch/aarch64.c
index d36ed9d..e0abe19 100644
--- a/gdb-8.3/gdb/arch/aarch64.c
+++ b/gdb-8.3/gdb/arch/aarch64.c
@@ -32,6 +32,7 @@
 
 #ifndef IN_PROCESS_AGENT
   set_tdesc_architecture (tdesc, "aarch64");
+  set_tdesc_osabi (tdesc, "GNU/Linux");
 #endif
 
   long regnum = 0;
diff --git a/gdb-8.3/gdb/configure b/gdb-8.3/gdb/configure
index 854837c..368c5b7 100755
--- a/gdb-8.3/gdb/configure
+++ b/gdb-8.3/gdb/configure
@@ -6780,7 +6780,7 @@
 
 # For other settings, only the main target counts.
 gdb_sim=
-gdb_osabi=
+gdb_osabi=GDB_OSABI_LINUX
 build_gdbserver=
 targ=$target; . ${srcdir}/configure.tgt
 
diff --git a/gdb-8.3/gdb/features/aarch64.xml b/gdb-8.3/gdb/features/aarch64.xml
index 8a07356..a945c5a 100644
--- a/gdb-8.3/gdb/features/aarch64.xml
+++ b/gdb-8.3/gdb/features/aarch64.xml
@@ -9,6 +9,7 @@
 <!DOCTYPE target SYSTEM "gdb-target.dtd">
 <target>
   <architecture>aarch64</architecture>
+  <osabi>GNU/Linux</osabi>
   <xi:include href="aarch64-core.xml"/>
   <xi:include href="aarch64-fpu.xml"/>
 </target>
diff --git a/gdb-8.3/gdb/features/arm/arm-with-iwmmxt.c b/gdb-8.3/gdb/features/arm/arm-with-iwmmxt.c
index 8729285..85ddbda 100644
--- a/gdb-8.3/gdb/features/arm/arm-with-iwmmxt.c
+++ b/gdb-8.3/gdb/features/arm/arm-with-iwmmxt.c
@@ -12,6 +12,8 @@
   struct target_desc *result = allocate_target_description ();
   set_tdesc_architecture (result, bfd_scan_arch ("iwmmxt"));
 
+  set_tdesc_osabi (result, osabi_from_tdesc_string ("GNU/Linux"));
+
   struct tdesc_feature *feature;
 
   feature = tdesc_create_feature (result, "org.gnu.gdb.arm.core");
diff --git a/gdb-8.3/gdb/features/arm/arm-with-iwmmxt.xml b/gdb-8.3/gdb/features/arm/arm-with-iwmmxt.xml
index 9455cb5..2a0ad67 100644
--- a/gdb-8.3/gdb/features/arm/arm-with-iwmmxt.xml
+++ b/gdb-8.3/gdb/features/arm/arm-with-iwmmxt.xml
@@ -8,6 +8,7 @@
 <!DOCTYPE target SYSTEM "gdb-target.dtd">
 <target>
   <architecture>iwmmxt</architecture>
+  <osabi>GNU/Linux</osabi>
   <xi:include href="arm-core.xml"/>
   <xi:include href="xscale-iwmmxt.xml"/>
 </target>
diff --git a/gdb-8.3/gdb/features/arm/arm-with-neon.c b/gdb-8.3/gdb/features/arm/arm-with-neon.c
index 682ad75..b0ac5d8 100644
--- a/gdb-8.3/gdb/features/arm/arm-with-neon.c
+++ b/gdb-8.3/gdb/features/arm/arm-with-neon.c
@@ -12,6 +12,8 @@
   struct target_desc *result = allocate_target_description ();
   set_tdesc_architecture (result, bfd_scan_arch ("arm"));
 
+  set_tdesc_osabi (result, osabi_from_tdesc_string ("GNU/Linux"));
+
   struct tdesc_feature *feature;
 
   feature = tdesc_create_feature (result, "org.gnu.gdb.arm.core");
diff --git a/gdb-8.3/gdb/features/arm/arm-with-neon.xml b/gdb-8.3/gdb/features/arm/arm-with-neon.xml
index 8a9ade1..d3ee1bd 100644
--- a/gdb-8.3/gdb/features/arm/arm-with-neon.xml
+++ b/gdb-8.3/gdb/features/arm/arm-with-neon.xml
@@ -8,6 +8,7 @@
 <!DOCTYPE target SYSTEM "gdb-target.dtd">
 <target>
   <architecture>arm</architecture>
+  <osabi>GNU/Linux</osabi>
   <xi:include href="arm-core.xml"/>
   <xi:include href="arm-vfpv3.xml"/>
   <feature name="org.gnu.gdb.arm.neon"/>
diff --git a/gdb-8.3/gdb/features/arm/arm-with-vfpv2.c b/gdb-8.3/gdb/features/arm/arm-with-vfpv2.c
index 368256c..c836629 100644
--- a/gdb-8.3/gdb/features/arm/arm-with-vfpv2.c
+++ b/gdb-8.3/gdb/features/arm/arm-with-vfpv2.c
@@ -12,6 +12,8 @@
   struct target_desc *result = allocate_target_description ();
   set_tdesc_architecture (result, bfd_scan_arch ("arm"));
 
+  set_tdesc_osabi (result, osabi_from_tdesc_string ("GNU/Linux"));
+
   struct tdesc_feature *feature;
 
   feature = tdesc_create_feature (result, "org.gnu.gdb.arm.core");
diff --git a/gdb-8.3/gdb/features/arm/arm-with-vfpv2.xml b/gdb-8.3/gdb/features/arm/arm-with-vfpv2.xml
index 881ac63..d9c6bf2 100644
--- a/gdb-8.3/gdb/features/arm/arm-with-vfpv2.xml
+++ b/gdb-8.3/gdb/features/arm/arm-with-vfpv2.xml
@@ -8,6 +8,7 @@
 <!DOCTYPE target SYSTEM "gdb-target.dtd">
 <target>
   <architecture>arm</architecture>
+  <osabi>GNU/Linux</osabi>
   <xi:include href="arm-core.xml"/>
   <xi:include href="arm-vfpv2.xml"/>
 </target>
diff --git a/gdb-8.3/gdb/features/arm/arm-with-vfpv3.c b/gdb-8.3/gdb/features/arm/arm-with-vfpv3.c
index ade7c95..c2823c0 100644
--- a/gdb-8.3/gdb/features/arm/arm-with-vfpv3.c
+++ b/gdb-8.3/gdb/features/arm/arm-with-vfpv3.c
@@ -12,6 +12,8 @@
   struct target_desc *result = allocate_target_description ();
   set_tdesc_architecture (result, bfd_scan_arch ("arm"));
 
+  set_tdesc_osabi (result, osabi_from_tdesc_string ("GNU/Linux"));
+
   struct tdesc_feature *feature;
 
   feature = tdesc_create_feature (result, "org.gnu.gdb.arm.core");
diff --git a/gdb-8.3/gdb/features/arm/arm-with-vfpv3.xml b/gdb-8.3/gdb/features/arm/arm-with-vfpv3.xml
index 45b9cda..564339d 100644
--- a/gdb-8.3/gdb/features/arm/arm-with-vfpv3.xml
+++ b/gdb-8.3/gdb/features/arm/arm-with-vfpv3.xml
@@ -8,6 +8,7 @@
 <!DOCTYPE target SYSTEM "gdb-target.dtd">
 <target>
   <architecture>arm</architecture>
+  <osabi>GNU/Linux</osabi>
   <xi:include href="arm-core.xml"/>
   <xi:include href="arm-vfpv3.xml"/>
 </target>
diff --git a/gdb-8.3/gdb/gdbserver/configure b/gdb-8.3/gdb/gdbserver/configure
index 1ddbd6b..0789dca 100755
--- a/gdb-8.3/gdb/gdbserver/configure
+++ b/gdb-8.3/gdb/gdbserver/configure
@@ -7698,20 +7698,7 @@
 fi
 
 
-case "${target}" in
-  *-android*)
-    # Starting with NDK version 9, <elf.h> actually includes definitions
-    # of Elf32_auxv_t and Elf64_auxv_t. But sadly, <elf.h> includes
-    # <sys/exec_elf.h> which defines some of the ELF types incorrectly,
-    # leading to conflicts with the defintions from <linux/elf.h>.
-    # This makes it impossible for us to include both <elf.h> and
-    # <linux/elf.h>, which means that, in practice, we do not have
-    # access to Elf32_auxv_t and Elf64_auxv_t on this platform.
-    # Therefore, do not try to auto-detect availability, as it would
-    # get it wrong on this platform.
-    ;;
-  *)
-    ac_fn_c_check_type "$LINENO" "Elf32_auxv_t" "ac_cv_type_Elf32_auxv_t" "#include <elf.h>
+ac_fn_c_check_type "$LINENO" "Elf32_auxv_t" "ac_cv_type_Elf32_auxv_t" "#include <elf.h>
 
 "
 if test "x$ac_cv_type_Elf32_auxv_t" = xyes; then :
@@ -7734,9 +7721,6 @@
 
 fi
 
-esac
-
-
 
 # Check whether --with-pkgversion was given.
 if test "${with_pkgversion+set}" = set; then :
diff --git a/gdb-8.3/gdb/gdbserver/hostio.c b/gdb-8.3/gdb/gdbserver/hostio.c
index cf75de0..ae9e09f 100644
--- a/gdb-8.3/gdb/gdbserver/hostio.c
+++ b/gdb-8.3/gdb/gdbserver/hostio.c
@@ -302,7 +302,7 @@
 {
   char filename[HOSTIO_PATH_MAX];
   char *p;
-  int fileio_flags, fileio_mode, flags, fd;
+  int fileio_flags, fileio_mode, flags, fd = -1;
   mode_t mode;
   struct fd_list *new_fd;
 
@@ -326,7 +326,11 @@
   if (hostio_fs_pid != 0 && the_target->multifs_open != NULL)
     fd = the_target->multifs_open (hostio_fs_pid, filename,
 				   flags, mode);
-  else
+
+  /* HACK: multifs_open will fail for android applications, because run-as does
+     not switch to the same mount namespace as the running application. Retry
+     with regular open if this happens.  */
+  if (fd == -1)
     fd = open (filename, flags, mode);
 
   if (fd == -1)
diff --git a/gdb-8.3/gdb/gdbserver/linux-low.c b/gdb-8.3/gdb/gdbserver/linux-low.c
index 8c5a51f..0927159 100644
--- a/gdb-8.3/gdb/gdbserver/linux-low.c
+++ b/gdb-8.3/gdb/gdbserver/linux-low.c
@@ -5931,9 +5931,7 @@
 static void
 linux_request_interrupt (void)
 {
-  /* Send a SIGINT to the process group.  This acts just like the user
-     typed a ^C on the controlling terminal.  */
-  kill (-signal_pid, SIGINT);
+  kill (signal_pid, SIGINT);
 }
 
 /* Copy LEN bytes from inferior's auxiliary vector starting at OFFSET
diff --git a/gdb-8.3/gdb/gnulib/configure b/gdb-8.3/gdb/gnulib/configure
index 340c622..380266d 100644
--- a/gdb-8.3/gdb/gnulib/configure
+++ b/gdb-8.3/gdb/gnulib/configure
@@ -12393,6 +12393,8 @@
 $as_echo_n "checking for a traditional japanese locale... " >&6; }
 if ${gt_cv_locale_ja+:} false; then :
   $as_echo_n "(cached) " >&6
+elif test "$cross_compiling" = yes; then :
+  gt_cv_locale_ja=none
 else
 
     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -12532,6 +12534,8 @@
 $as_echo_n "checking for a transitional chinese locale... " >&6; }
 if ${gt_cv_locale_zh_CN+:} false; then :
   $as_echo_n "(cached) " >&6
+elif test "$cross_compiling" = yes; then :
+  gt_cv_locale_zh_CN=none
 else
 
     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -12664,6 +12668,8 @@
 $as_echo_n "checking for a french Unicode locale... " >&6; }
 if ${gt_cv_locale_fr_utf8+:} false; then :
   $as_echo_n "(cached) " >&6
+elif test "$cross_compiling" = yes; then :
+  gt_cv_locale_fr_utf8=none
 else
 
     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -12793,6 +12799,8 @@
 $as_echo_n "checking for a traditional french locale... " >&6; }
 if ${gt_cv_locale_fr+:} false; then :
   $as_echo_n "(cached) " >&6
+elif test "$cross_compiling" = yes; then :
+  gt_cv_locale_fr=none
 else
 
     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
diff --git a/gdb-8.3/include/elf/common.h b/gdb-8.3/include/elf/common.h
index e8faf67..45010d3 100644
--- a/gdb-8.3/include/elf/common.h
+++ b/gdb-8.3/include/elf/common.h
@@ -525,6 +525,10 @@
 #define SHT_GNU_verneed	SHT_SUNW_verneed
 #define SHT_GNU_versym	SHT_SUNW_versym
 
+/* Experimental support for SHT_RELR sections. For details, see proposal
+   at https://groups.google.com/forum/#!topic/generic-abi/bX460iggiKg */
+#define SHT_RELR	0x6fffff00	/* Relative relocations, only offsets */
+
 #define SHT_LOPROC	0x70000000	/* Processor-specific semantics, lo */
 #define SHT_HIPROC	0x7FFFFFFF	/* Processor-specific semantics, hi */
 #define SHT_LOUSER	0x80000000	/* Application-specific semantics */
@@ -1029,6 +1033,13 @@
 /* This tag is a GNU extension to the Solaris version scheme.  */
 #define DT_VERSYM	0x6ffffff0
 
+/* Experimental support for SHT_RELR sections. For details, see proposal
+   at https://groups.google.com/forum/#!topic/generic-abi/bX460iggiKg */
+#define DT_RELR		0x6fffe000
+#define DT_RELRSZ	0x6fffe001
+#define DT_RELRENT	0x6fffe003
+#define DT_RELRCOUNT	0x6fffe005
+
 #define DT_LOPROC	0x70000000
 #define DT_HIPROC	0x7fffffff
 
diff --git a/gdb-8.3/include/elf/external.h b/gdb-8.3/include/elf/external.h
index 73e3cbf..9d67981 100644
--- a/gdb-8.3/include/elf/external.h
+++ b/gdb-8.3/include/elf/external.h
@@ -212,6 +212,10 @@
 } Elf32_External_Rela;
 
 typedef struct {
+  unsigned char r_data[4];	/* jump and bitmap for relative relocations */
+} Elf32_External_Relr;
+
+typedef struct {
   unsigned char r_offset[8];	/* Location at which to apply the action */
   unsigned char	r_info[8];	/* index and type of relocation */
 } Elf64_External_Rel;
@@ -222,6 +226,10 @@
   unsigned char	r_addend[8];	/* Constant addend used to compute value */
 } Elf64_External_Rela;
 
+typedef struct {
+  unsigned char r_data[8];	/* jump and bitmap for relative relocations */
+} Elf64_External_Relr;
+
 /* dynamic section structure */
 
 typedef struct {