public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Patch 1 of 2 for aarch64 ILP32 support in gdb
@ 2017-01-25  0:19 Steve Ellcey
  2017-01-25 10:45 ` Nick Clifton
  2017-01-25 15:37 ` Yao Qi
  0 siblings, 2 replies; 4+ messages in thread
From: Steve Ellcey @ 2017-01-25  0:19 UTC (permalink / raw)
  To: binutils, gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1110 bytes --]

This is a follow up to a post from some time ago to enable aarch64
ILP32 support in gdb.

	https://sourceware.org/ml/binutils/2016-09/msg00004.html

Andrew Pinksi submitted these patches and I have updated them,
addressed the comments that were made at the time, and retested
them.  Andrew broke them down into 3 patches I am submitting it as two
patches, this first one is the changes to bfd.  This patch removes the
ilp32/lp64 checking that is done in compatible and moves it to
elfNN_aarch64_merge_private_bfd_data.  Doing it in compatible is too
early for gdb.  The patch also adds an endianness check to
elfNN_aarch64_merge_private_bfd_data.  The second patch will contain
the gdb changes.

Steve Ellcey
sellcey@cavium.com


2017-01-24  Andrew Pinski  <apinski@cavium.com>
	    Steve Ellcey  <sellcey@cavium.com>

	* cpu-aarch64.c (compatible):
	Don't reject different ILP32/LP64 ABI's here.
	* elfnn-aarch64.c (elfNN_aarch64_merge_private_bfd_data):
	Add an error message on why endianess is rejected.
	Reject different ILP32/LP64 ABI settings.

[-- Attachment #2: bfd.patch --]
[-- Type: text/x-patch, Size: 2161 bytes --]

diff --git a/bfd/cpu-aarch64.c b/bfd/cpu-aarch64.c
index 7cb81f3..63fba48 100644
--- a/bfd/cpu-aarch64.c
+++ b/bfd/cpu-aarch64.c
@@ -25,7 +25,8 @@
 
 /* This routine is provided two arch_infos and works out which Aarch64
    machine which would be compatible with both and returns a pointer
-   to its info structure.  */
+   to its info structure.  ABI (ilp32 vs. lp64) and endianness compatibility
+   are checked in elfNN_aarch64_merge_private_bfd_data.  */
 
 static const bfd_arch_info_type *
 compatible (const bfd_arch_info_type * a, const bfd_arch_info_type * b)
@@ -38,10 +39,6 @@ compatible (const bfd_arch_info_type * a, const bfd_arch_info_type * b)
   if (a->mach == b->mach)
     return a;
 
-  /* Don't allow mixing ilp32 with lp64.  */
-  if ((a->mach & bfd_mach_aarch64_ilp32) != (b->mach & bfd_mach_aarch64_ilp32))
-    return NULL;
-
   /* Otherwise if either a or b is the 'default' machine
      then it can be polymorphed into the other.  */
   if (a->the_default)
diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
index c86a3e1..9b82f4b 100644
--- a/bfd/elfnn-aarch64.c
+++ b/bfd/elfnn-aarch64.c
@@ -6597,11 +6597,26 @@ elfNN_aarch64_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info)
 
   /* Check if we have the same endianess.  */
   if (!_bfd_generic_verify_endian_match (ibfd, info))
-    return FALSE;
+    {
+      (*_bfd_error_handler)
+	(_("%B: endianness incompatible with that of the selected emulation"),
+	   ibfd);
+      return FALSE;
+    }
 
   if (!is_aarch64_elf (ibfd) || !is_aarch64_elf (obfd))
     return TRUE;
 
+  /* Don't allow mixing ilp32 with lp64.  */
+  if ((bfd_get_arch_info (ibfd)->mach & bfd_mach_aarch64_ilp32)
+      != (bfd_get_arch_info (obfd)->mach & bfd_mach_aarch64_ilp32))
+    {
+      (*_bfd_error_handler)
+	(_("%B: ABI is incompatible with that of the selected emulation: \"%s\" != \"%s\""),
+	 ibfd, bfd_get_target (ibfd), bfd_get_target (obfd));
+      return FALSE;
+    }
+
   /* The input BFD must have had its flags initialised.  */
   /* The following seems bogus to me -- The flags are initialized in
      the assembler but I don't think an elf_flags_init field is

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Patch 1 of 2 for aarch64 ILP32 support in gdb
  2017-01-25  0:19 [PATCH] Patch 1 of 2 for aarch64 ILP32 support in gdb Steve Ellcey
@ 2017-01-25 10:45 ` Nick Clifton
  2017-01-25 15:37 ` Yao Qi
  1 sibling, 0 replies; 4+ messages in thread
From: Nick Clifton @ 2017-01-25 10:45 UTC (permalink / raw)
  To: Steve Ellcey, binutils, gdb-patches

Hi Steve,

> 2017-01-24  Andrew Pinski  <apinski@cavium.com>
> 	    Steve Ellcey  <sellcey@cavium.com>
> 
> 	* cpu-aarch64.c (compatible):
> 	Don't reject different ILP32/LP64 ABI's here.
> 	* elfnn-aarch64.c (elfNN_aarch64_merge_private_bfd_data):
> 	Add an error message on why endianess is rejected.
> 	Reject different ILP32/LP64 ABI settings.

Approved - please apply.

Cheers
  Nick


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Patch 1 of 2 for aarch64 ILP32 support in gdb
  2017-01-25  0:19 [PATCH] Patch 1 of 2 for aarch64 ILP32 support in gdb Steve Ellcey
  2017-01-25 10:45 ` Nick Clifton
@ 2017-01-25 15:37 ` Yao Qi
  2017-01-25 19:44   ` Steve Ellcey
  1 sibling, 1 reply; 4+ messages in thread
From: Yao Qi @ 2017-01-25 15:37 UTC (permalink / raw)
  To: Steve Ellcey; +Cc: binutils, gdb-patches

On 17-01-24 16:18:49, Steve Ellcey wrote:
> --- a/bfd/cpu-aarch64.c
> +++ b/bfd/cpu-aarch64.c
> @@ -25,7 +25,8 @@
>  
>  /* This routine is provided two arch_infos and works out which Aarch64
>     machine which would be compatible with both and returns a pointer
> -   to its info structure.  */
> +   to its info structure.  ABI (ilp32 vs. lp64) and endianness compatibility
> +   are checked in elfNN_aarch64_merge_private_bfd_data.  */
>  
>  static const bfd_arch_info_type *
>  compatible (const bfd_arch_info_type * a, const bfd_arch_info_type * b)
> @@ -38,10 +39,6 @@ compatible (const bfd_arch_info_type * a, const bfd_arch_info_type * b)
>    if (a->mach == b->mach)
>      return a;
>  
> -  /* Don't allow mixing ilp32 with lp64.  */
> -  if ((a->mach & bfd_mach_aarch64_ilp32) != (b->mach & bfd_mach_aarch64_ilp32))
> -    return NULL;
> -

Hi Steve,
GDB uses this function to check if selected arch is compatible with
the target arch.  If I load an ilp32 binary in aarch64 gdb, and connect
to gdbserver, I'll get a warning as below,

Reading symbols from ../1.o...(no debugging symbols found)...done.
(gdb) target remote linaro-junor1-1:1234
Remote debugging using linaro-junor1-1:1234
warning: Selected architecture aarch64:ilp32 is not compatible with reported target architecture aarch64

with your patch applied, the warning goes way.

(gdb) target remote linaro-junor1-1:1234
Remote debugging using linaro-junor1-1:1234
Reading /scratch/yao/toolchain/gcc-7/aarch64-linux-gnu/sysroot/lib/ld-linux-aarch64.so.1 from remote target...
Reading /scratch/yao/toolchain/gcc-7/aarch64-linux-gnu/sysroot/lib/ld-linux-aarch64.so.1 from remote target...
Reading symbols from target:/scratch/yao/toolchain/gcc-7/aarch64-linux-gnu/sysroot/lib/ld-linux-aarch64.so.1...done.
Python Exception <type 'exceptions.NameError'> Installation error: gdb.execute_unwinders function is missing: 
0x0000ffffb7fd2d00 in _start () from target:/scratch/yao/toolchain/gcc-7/aarch64-linux-gnu/sysroot/lib/ld-linux-aarch64.so.1

IMO, the warning above is useful, since aarch64:ilp32 is not supported
in gdb, can we commit this patch after ilp32 is supported in GDB (if
this patch only affects GDB).

-- 
Yao (齐尧)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Patch 1 of 2 for aarch64 ILP32 support in gdb
  2017-01-25 15:37 ` Yao Qi
@ 2017-01-25 19:44   ` Steve Ellcey
  0 siblings, 0 replies; 4+ messages in thread
From: Steve Ellcey @ 2017-01-25 19:44 UTC (permalink / raw)
  To: Yao Qi; +Cc: binutils, gdb-patches

On Wed, 2017-01-25 at 15:36 +0000, Yao Qi wrote:
> 
> Hi Steve,
> GDB uses this function to check if selected arch is compatible with
> the target arch.  If I load an ilp32 binary in aarch64 gdb, and
> connect
> to gdbserver, I'll get a warning as below,
> 
> IMO, the warning above is useful, since aarch64:ilp32 is not
> supported
> in gdb, can we commit this patch after ilp32 is supported in GDB (if
> this patch only affects GDB).

I submitted the GDB support for ilp32 as patch 2 of 2 to binutils
and gdb-patches so I can wait a little while and see if someone
approves that patch before checking this part in.

https://sourceware.org/ml/binutils/2017-01/msg00416.html
https://sourceware.org/ml/gdb-patches/2017-01/msg00509.html

Steve Ellcey
sellcey@cavium.com



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-01-25 19:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-25  0:19 [PATCH] Patch 1 of 2 for aarch64 ILP32 support in gdb Steve Ellcey
2017-01-25 10:45 ` Nick Clifton
2017-01-25 15:37 ` Yao Qi
2017-01-25 19:44   ` Steve Ellcey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).