public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Paul Iannetta <piannetta@kalrayinc.com>
To: binutils@sourceware.org
Cc: Paul Iannetta <piannetta@kalrayinc.com>
Subject: [PATCH 2/7] kvx: Add binutils files.
Date: Fri, 21 Jul 2023 09:49:51 +0200	[thread overview]
Message-ID: <20230721074956.7188-3-piannetta@kalrayinc.com> (raw)
In-Reply-To: <20230721074956.7188-1-piannetta@kalrayinc.com>

binutils/ChangeLog:

2023-07-20  Paul Iannetta  <piannetta@kalrayinc.com>

	* readelf.c (guess_is_rela): Add EM_KVX.
	(dump_relocations): Likewise.
	(get_machine_flags): Likewise.
	(is_32bit_abs_reloc): Likewise.
	(is_32bit_pcrel_reloc): Likewise.
	(is_64bit_abs_reloc): Likewise.
	(is_16bit_abs_reloc): Likewise.
	(is_none_reloc): Likewise.
	* testsuite/binutils-all/dw2-decodedline-2.S: New test.
	* testsuite/binutils-all/kvx/kvx.exp: New file.
	* testsuite/binutils-all/kvx/pcrel_bundle.d: New test.
	* testsuite/binutils-all/kvx/pcrel_bundle.s: New test.
	* testsuite/binutils-all/kvx/pcrel_bundle32bits.d: New test.
	* testsuite/binutils-all/kvx/pcrel_bundle32bits.s: New test.
	* testsuite/binutils-all/objcopy.exp:
	* testsuite/binutils-all/objdump.exp:
	* testsuite/lib/binutils-common.exp:
---
 binutils/readelf.c                            | 26 +++++++++++++
 .../binutils-all/dw2-decodedline-2.S          | 18 +++++++++
 binutils/testsuite/binutils-all/kvx/kvx.exp   | 37 +++++++++++++++++++
 .../testsuite/binutils-all/kvx/pcrel_bundle.d | 33 +++++++++++++++++
 .../testsuite/binutils-all/kvx/pcrel_bundle.s | 25 +++++++++++++
 .../binutils-all/kvx/pcrel_bundle32bits.d     | 33 +++++++++++++++++
 .../binutils-all/kvx/pcrel_bundle32bits.s     | 25 +++++++++++++
 binutils/testsuite/binutils-all/objcopy.exp   |  1 +
 binutils/testsuite/binutils-all/objdump.exp   |  2 +
 binutils/testsuite/lib/binutils-common.exp    |  6 +++
 10 files changed, 206 insertions(+)
 create mode 100644 binutils/testsuite/binutils-all/dw2-decodedline-2.S
 create mode 100644 binutils/testsuite/binutils-all/kvx/kvx.exp
 create mode 100644 binutils/testsuite/binutils-all/kvx/pcrel_bundle.d
 create mode 100644 binutils/testsuite/binutils-all/kvx/pcrel_bundle.s
 create mode 100644 binutils/testsuite/binutils-all/kvx/pcrel_bundle32bits.d
 create mode 100644 binutils/testsuite/binutils-all/kvx/pcrel_bundle32bits.s

diff --git a/binutils/readelf.c b/binutils/readelf.c
index bb488ef2a5e..d675440eddd 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -121,6 +121,7 @@
 #include "elf/i960.h"
 #include "elf/ia64.h"
 #include "elf/ip2k.h"
+#include "elf/kvx.h"
 #include "elf/lm32.h"
 #include "elf/iq2000.h"
 #include "elf/m32c.h"
@@ -1083,6 +1084,7 @@ guess_is_rela (unsigned int e_machine)
     case EM_IP2K:
     case EM_IP2K_OLD:
     case EM_IQ2000:
+    case EM_KVX:
     case EM_LATTICEMICO32:
     case EM_M32C_OLD:
     case EM_M32C:
@@ -1767,6 +1769,10 @@ dump_relocations (Filedata *filedata,
 	  rtype = elf_ia64_reloc_type (type);
 	  break;
 
+	case EM_KVX:
+	  rtype = elf_kvx_reloc_type (type);
+	  break;
+
 	case EM_CRIS:
 	  rtype = elf_cris_reloc_type (type);
 	  break;
@@ -4351,6 +4357,17 @@ get_machine_flags (Filedata * filedata, unsigned e_flags, unsigned e_machine)
 	    strcat (buf, ", relocatable module");
 	  break;
 
+	case EM_KVX:
+	  if ((e_flags & (ELF_KVX_CORE_MAJOR_MASK | ELF_KVX_CORE_MINOR_MASK)) == ELF_KVX_CORE_KV3_1)
+	    strcat (buf, ", Kalray VLIW kv3-1");
+	  else if ((e_flags & (ELF_KVX_CORE_MAJOR_MASK | ELF_KVX_CORE_MINOR_MASK)) == ELF_KVX_CORE_KV3_2)
+	    strcat (buf, ", Kalray VLIW kv3-2");
+	  else if ((e_flags & (ELF_KVX_CORE_MAJOR_MASK | ELF_KVX_CORE_MINOR_MASK)) == ELF_KVX_CORE_KV4_1)
+	    strcat (buf, ", Kalray VLIW kv4-1");
+	  else
+	    strcat (buf, ", unknown KVX MPPA");
+	  break;
+
 	case EM_MSP430:
 	  strcat (buf, _(": architecture variant: "));
 	  switch (e_flags & EF_MSP430_MACH)
@@ -14385,6 +14402,8 @@ is_32bit_abs_reloc (Filedata * filedata, unsigned int reloc_type)
       return reloc_type == 2; /* R_IP2K_32.  */
     case EM_IQ2000:
       return reloc_type == 2; /* R_IQ2000_32.  */
+    case EM_KVX:
+      return reloc_type == 2; /* R_KVX_32.  */
     case EM_LATTICEMICO32:
       return reloc_type == 3; /* R_LM32_32.  */
     case EM_LOONGARCH:
@@ -14582,6 +14601,8 @@ is_32bit_pcrel_reloc (Filedata * filedata, unsigned int reloc_type)
     case EM_XTENSA_OLD:
     case EM_XTENSA:
       return reloc_type == 14; /* R_XTENSA_32_PCREL.  */
+    case EM_KVX:
+      return reloc_type == 7; /* R_KVX_32_PCREL */
     default:
       /* Do not abort or issue an error message here.  Not all targets use
 	 pc-relative 32-bit relocs in their DWARF debug information and we
@@ -14633,6 +14654,8 @@ is_64bit_abs_reloc (Filedata * filedata, unsigned int reloc_type)
       return reloc_type == 1; /* R_TILEGX_64.  */
     case EM_MIPS:
       return reloc_type == 18;	/* R_MIPS_64.  */
+    case EM_KVX:
+      return reloc_type == 3; /* R_KVX_64 */
     default:
       return false;
     }
@@ -14736,6 +14759,8 @@ is_16bit_abs_reloc (Filedata * filedata, unsigned int reloc_type)
     case EM_CYGNUS_MN10300:
     case EM_MN10300:
       return reloc_type == 2; /* R_MN10300_16.  */
+    case EM_KVX:
+      return reloc_type == 1; /* R_KVX_16 */
     case EM_MSP430:
       if (uses_msp430x_relocs (filedata))
 	return reloc_type == 2; /* R_MSP430_ABS16.  */
@@ -14998,6 +15023,7 @@ is_none_reloc (Filedata * filedata, unsigned int reloc_type)
     case EM_FT32:    /* R_FT32_NONE.  */
     case EM_IA_64:   /* R_IA64_NONE.  */
     case EM_K1OM:    /* R_X86_64_NONE.  */
+    case EM_KVX:      /* R_KVX_NONE.  */
     case EM_L1OM:    /* R_X86_64_NONE.  */
     case EM_M32R:    /* R_M32R_NONE.  */
     case EM_MIPS:    /* R_MIPS_NONE.  */
diff --git a/binutils/testsuite/binutils-all/dw2-decodedline-2.S b/binutils/testsuite/binutils-all/dw2-decodedline-2.S
new file mode 100644
index 00000000000..333cd3626a6
--- /dev/null
+++ b/binutils/testsuite/binutils-all/dw2-decodedline-2.S
@@ -0,0 +1,18 @@
+	.file	"dw2-decodedline.c"
+	.file 1 "dw2-decodedline.c"
+	.file 2 "directory/file1.c"
+	.text
+	.globl f1
+	.type	f1, %function
+f1:
+	.loc 2 1 0
+	nop
+	;;
+	.size	f1, .-f1
+	.globl main
+	.type	main, %function
+main:
+	.loc 1 2 0
+	nop
+	;;
+	.size	main, .-main
diff --git a/binutils/testsuite/binutils-all/kvx/kvx.exp b/binutils/testsuite/binutils-all/kvx/kvx.exp
new file mode 100644
index 00000000000..e096bebb65a
--- /dev/null
+++ b/binutils/testsuite/binutils-all/kvx/kvx.exp
@@ -0,0 +1,37 @@
+#   Copyright (C) 2009-2023 Free Software Foundation, Inc.
+#   Contributed by Kalray SA.
+
+#   This program is free software; you can redistribute it and/or modify
+#   it under the terms of the GNU General Public License as published by
+#   the Free Software Foundation; either version 3 of the License, or
+#   (at your option) any later version.
+
+#   This program 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 a copy of the GNU General Public License
+#   along with this program; see the file COPYING3. If not,
+#   see <http://www.gnu.org/licenses/>.  */
+
+if {!([istarget "kvx*-*-*"])
+    || ![is_elf_format]
+    || [is_remote host]} then {
+    return
+}
+
+global tempfile
+global copyfile
+set tempfile tmpdir/kvxtemp.o
+set copyfile tmpdir/kvxcopy
+
+## binutils test framework does not support the 'dump' EXTRA args to
+## simply share a single .s for 32 and 64bits test.
+# So we duplicate the source .s
+
+# 32bits test
+run_dump_test "pcrel_bundle32bits"
+
+# 64bits test
+run_dump_test "pcrel_bundle"
diff --git a/binutils/testsuite/binutils-all/kvx/pcrel_bundle.d b/binutils/testsuite/binutils-all/kvx/pcrel_bundle.d
new file mode 100644
index 00000000000..ff8df45bb0e
--- /dev/null
+++ b/binutils/testsuite/binutils-all/kvx/pcrel_bundle.d
@@ -0,0 +1,33 @@
+#name: pcrel_bundle
+#source: pcrel_bundle.s
+#PROG: objcopy
+#as:
+#objdump: -dr
+#...
+
+Disassembly of section .text:
+
+0000000000000000 <foo>:
+   0:	00 0e 00 f0 00 00 00 80 00 00 00 00             	pcrel \$r0 = 56 \(0x38\);;
+
+   c:	0d 00 00 98                                     	call 40 <bar>
+  10:	00 0b 00 f0 00 00 00 80 00 00 00 00             	pcrel \$r0 = 44 \(0x2c\);;
+
+  1c:	09 00 00 98                                     	call 40 <bar>
+  20:	00 07 00 f0 00 00 00 b8 00 00 00 80             	pcrel \$r0 = 28 \(0x1c\)
+  2c:	00 00 00 00                                     	ld \$r0 = 0 \(0x0\)\[\$r0\];;
+
+  30:	00 f0 03 7f                                     	nop;;
+
+  34:	00 f0 03 7f                                     	nop;;
+
+
+0000000000000038 <.table>:
+  38:	00 f0 03 7f                                     	nop;;
+
+  3c:	00 f0 03 7f                                     	nop;;
+
+
+0000000000000040 <bar>:
+  40:	00 f0 03 7f                                     	nop;;
+
diff --git a/binutils/testsuite/binutils-all/kvx/pcrel_bundle.s b/binutils/testsuite/binutils-all/kvx/pcrel_bundle.s
new file mode 100644
index 00000000000..feaa581ce8f
--- /dev/null
+++ b/binutils/testsuite/binutils-all/kvx/pcrel_bundle.s
@@ -0,0 +1,25 @@
+foo:
+	pcrel $r0 = @pcrel(.table)
+	;;
+	call bar
+	pcrel $r0 = @pcrel(.table)
+	;;
+	call bar
+	ld $r0 = 0[$r0]
+	pcrel $r0 = @pcrel(.table)
+	;;
+	nop
+	;;
+	nop
+	;;
+.table:
+	nop
+	;;
+	nop
+	;; 
+bar:
+	nop
+	;;
+	
+
+	
diff --git a/binutils/testsuite/binutils-all/kvx/pcrel_bundle32bits.d b/binutils/testsuite/binutils-all/kvx/pcrel_bundle32bits.d
new file mode 100644
index 00000000000..732b3c50507
--- /dev/null
+++ b/binutils/testsuite/binutils-all/kvx/pcrel_bundle32bits.d
@@ -0,0 +1,33 @@
+#name: pcrel_bundle
+#source: pcrel_bundle.s
+#PROG: objcopy
+#as: -m32
+#objdump: -dr
+#...
+
+Disassembly of section .text:
+
+00000000 <foo>:
+   0:	00 0b 00 f0 00 00 00 00                         	pcrel \$r0 = 44 \(0x2c\);;
+
+   8:	0b 00 00 98                                     	call 34 <bar>
+   c:	00 09 00 f0 00 00 00 00                         	pcrel \$r0 = 36 \(0x24\);;
+
+  14:	08 00 00 98                                     	call 34 <bar>
+  18:	00 06 00 f0 00 00 00 b8                         	pcrel \$r0 = 24 \(0x18\)
+  20:	00 00 00 00                                     	ld \$r0 = 0 \(0x0\)\[\$r0\];;
+
+  24:	00 f0 03 7f                                     	nop;;
+
+  28:	00 f0 03 7f                                     	nop;;
+
+
+0000002c <.table>:
+  2c:	00 f0 03 7f                                     	nop;;
+
+  30:	00 f0 03 7f                                     	nop;;
+
+
+00000034 <bar>:
+  34:	00 f0 03 7f                                     	nop;;
+
diff --git a/binutils/testsuite/binutils-all/kvx/pcrel_bundle32bits.s b/binutils/testsuite/binutils-all/kvx/pcrel_bundle32bits.s
new file mode 100644
index 00000000000..feaa581ce8f
--- /dev/null
+++ b/binutils/testsuite/binutils-all/kvx/pcrel_bundle32bits.s
@@ -0,0 +1,25 @@
+foo:
+	pcrel $r0 = @pcrel(.table)
+	;;
+	call bar
+	pcrel $r0 = @pcrel(.table)
+	;;
+	call bar
+	ld $r0 = 0[$r0]
+	pcrel $r0 = @pcrel(.table)
+	;;
+	nop
+	;;
+	nop
+	;;
+.table:
+	nop
+	;;
+	nop
+	;; 
+bar:
+	nop
+	;;
+	
+
+	
diff --git a/binutils/testsuite/binutils-all/objcopy.exp b/binutils/testsuite/binutils-all/objcopy.exp
index 41add0fecda..16d9c8dad59 100644
--- a/binutils/testsuite/binutils-all/objcopy.exp
+++ b/binutils/testsuite/binutils-all/objcopy.exp
@@ -693,6 +693,7 @@ proc copy_setup { } {
     }
 
     if { [istarget *-*-linux*]
+	 || [istarget kvx-*-*]
 	 || [istarget *-*-gnu*] } {
 	foreach i $gcc_gas_flag {
 	    set flags "additional_flags=$i $flags"
diff --git a/binutils/testsuite/binutils-all/objdump.exp b/binutils/testsuite/binutils-all/objdump.exp
index 28a7ad671cd..4fe9e499d49 100644
--- a/binutils/testsuite/binutils-all/objdump.exp
+++ b/binutils/testsuite/binutils-all/objdump.exp
@@ -482,6 +482,8 @@ if { ![is_elf_format]
 } else {
     if { [istarget "or1k*-*-*"] } then {
         set decodedline_testsrc $srcdir/$subdir/dw2-decodedline-1.S
+    } elseif { [istarget "kvx*-*-*"] } {
+        set decodedline_testsrc $srcdir/$subdir/dw2-decodedline-2.S
     } else {
         set decodedline_testsrc $srcdir/$subdir/dw2-decodedline.S
     }
diff --git a/binutils/testsuite/lib/binutils-common.exp b/binutils/testsuite/lib/binutils-common.exp
index 7e6bf16ee6e..0dd9bae98fc 100644
--- a/binutils/testsuite/lib/binutils-common.exp
+++ b/binutils/testsuite/lib/binutils-common.exp
@@ -41,6 +41,7 @@ proc is_elf_format {} {
 	 && ![istarget *-*-irix5*]
 	 && ![istarget *-*-irix6*]
 	 && ![istarget *-*-kaos*]
+   && ![istarget kvx-*-*]
 	 && ![istarget *-*-*linux*]
 	 && ![istarget *-*-lynxos*]
 	 && ![istarget *-*-nacl*]
@@ -371,6 +372,11 @@ proc check_pie_support { } {
     global pie_available_saved
     global ld
 
+    ## kvx-*-cos does support -shared but not PIE.
+    if { [istarget "kvx-*-cos"] } {
+        set pie_available_saved 0
+    }
+
     if {![info exists pie_available_saved]} {
 	set ld_output [remote_exec host $ld "-pie"]
 	if { [ string first "not supported" $ld_output ] >= 0 } {
-- 
2.35.1.500.gb896f729e2






  parent reply	other threads:[~2023-07-21  7:50 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-21  7:49 [PATCH 0/7] kvx: New port Paul Iannetta
2023-07-21  7:49 ` [PATCH 1/7] kvx: Add bf files Paul Iannetta
2023-07-21  7:49 ` Paul Iannetta [this message]
2023-07-21  7:49 ` [PATCH 3/7] kvx: Add gas file Paul Iannetta
2023-07-21  7:49 ` [PATCH 4/7] kvx: Add ld files Paul Iannetta
2023-07-21  7:49 ` [PATCH 5/7] kvx: Add include files Paul Iannetta
2023-07-21  7:49 ` [PATCH 6/7] kvx: Add opcodes file Paul Iannetta
2023-07-21  7:49 ` [PATCH 7/7] kvx: Add toplevel files Paul Iannetta
2023-07-21  8:29 ` [PATCH 0/7] kvx: New port Nick Clifton
     [not found]   ` <20230721090932.pspnpq2q2wjnshrh@ws2202.lin.mbt.kalray.eu>
     [not found]     ` <2050791e-38ee-5719-037f-c03c456f3e3d@redhat.com>
2023-07-21 16:47       ` Paul Iannetta
2023-07-21 17:00       ` Paul Iannetta
2023-07-21  8:57 ` YunQiang Su
2023-07-21 16:51   ` Paul Iannetta
2023-07-24  9:04 ` Nick Clifton
2023-07-24  9:38   ` Paul Iannetta
2023-07-24  9:28 ` Nick Clifton
2023-07-24 12:33   ` Paul Iannetta
2023-07-24 14:30     ` Paul Iannetta
2023-07-25 14:13     ` Nick Clifton
2023-07-26  7:36       ` Paul Iannetta
2023-07-26 13:32         ` Michael Matz
2023-07-26 21:46           ` Paul Iannetta
2023-07-26 21:24         ` [PATCH v2] " Paul Iannetta
2023-07-31 14:52           ` Nick Clifton
2023-08-02 14:38             ` [PATCH v3] " Paul Iannetta
2023-08-16 13:24               ` Nick Clifton
2023-08-17  9:45                 ` Luis Machado
2023-08-17 15:09                   ` Paul Iannetta
2023-08-17 16:28                     ` Luis Machado
2023-08-17 23:20                     ` Alan Modra
2023-08-18  7:13                       ` Paul Iannetta
2023-08-17 12:46                 ` Paul Iannetta
2023-07-24  9:53 ` [PATCH 0/7] " Nick Clifton
2023-07-24 12:27   ` Paul Iannetta

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230721074956.7188-3-piannetta@kalrayinc.com \
    --to=piannetta@kalrayinc.com \
    --cc=binutils@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).