[v2,3/5,LoongArch] Binutils support.

Message ID CAKjxQHmhU+yaQd8-FJdcCNWxG9HJaN=im749-_N37yR_CeuV2Q@mail.gmail.com
State New
Headers show
Series
  • Add LoongArch port support.
Related show

Commit Message

H.J. Lu via Binutils Sept. 19, 2021, 2:07 p.m.
From 9d9febbf7f6b3dbcf084e37b83d21cba8001b3ac Mon Sep 17 00:00:00 2001
From: Chenghua Xu <xuchenghua@loongson.cn>

Date: Sun, 19 Sep 2021 09:42:59 +0800
Subject: [PATCH 3/5] binutils: LoongArch Binutils Port.

---
 binutils/readelf.c                          | 10 ++++++++++
 binutils/testsuite/binutils-all/objdump.exp |  2 +-
 2 files changed, 11 insertions(+), 1 deletion(-)

 # Make sure the target CPU shows up in the list.
 lappend cpus_expected ${target_cpu}
-- 
2.27.0

Comments

Chenghua Xu Sept. 25, 2021, 3:03 a.m. | #1
From 9d9febbf7f6b3dbcf084e37b83d21cba8001b3ac Mon Sep 17 00:00:00 2001
From: Chenghua Xu <xuchenghua@loongson.cn>
Date: Sun, 19 Sep 2021 09:42:59 +0800
Subject: [PATCH 3/5] binutils: LoongArch Binutils Port.

---
 binutils/readelf.c                          | 10 ++++++++++
 binutils/testsuite/binutils-all/objdump.exp |  2 +-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/binutils/readelf.c b/binutils/readelf.c
index 4a6fcff3cc1..031bcd3711e 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -162,6 +162,7 @@
 #include "elf/xstormy16.h"
 #include "elf/xtensa.h"
 #include "elf/z80.h"
+#include "elf/loongarch.h"
 
 #include "getopt.h"
 #include "libiberty.h"
@@ -1653,6 +1654,11 @@ dump_relocations (Filedata *          filedata,
 	case EM_Z80:
 	  rtype = elf_z80_reloc_type (type);
 	  break;
+
+	case EM_LOONGARCH:
+	  rtype = elf_loongarch_reloc_type (type);
+	  break;
+
 	}
 
       if (rtype == NULL)
@@ -13673,6 +13679,8 @@ is_32bit_abs_reloc (Filedata * filedata, unsigned int reloc_type)
       return reloc_type == 2; /* R_IQ2000_32.  */
     case EM_LATTICEMICO32:
       return reloc_type == 3; /* R_LM32_32.  */
+    case EM_LOONGARCH:
+      return reloc_type == 1; /* R_LARCH_32. */
     case EM_M32C_OLD:
     case EM_M32C:
       return reloc_type == 3; /* R_M32C_32.  */
@@ -13890,6 +13898,8 @@ is_64bit_abs_reloc (Filedata * filedata, unsigned int reloc_type)
     case EM_IA_64:
       return (reloc_type == 0x26    /* R_IA64_DIR64MSB.  */
 	      || reloc_type == 0x27 /* R_IA64_DIR64LSB.  */);
+    case EM_LOONGARCH:
+      return reloc_type == 2;      /* R_LARCH_64 */
     case EM_PARISC:
       return reloc_type == 80; /* R_PARISC_DIR64.  */
     case EM_PPC64:
diff --git a/binutils/testsuite/binutils-all/objdump.exp b/binutils/testsuite/binutils-all/objdump.exp
index 0b797f9e9b4..2e23aca0d47 100644
--- a/binutils/testsuite/binutils-all/objdump.exp
+++ b/binutils/testsuite/binutils-all/objdump.exp
@@ -40,7 +40,7 @@ lappend cpus_expected m16c m32c m32r m68hc11 m68hc12 m68k MCore mep c5 h1 MicroB
 lappend cpus_expected mips mn10200 mn10300 ms1 msp MSP430 nds32 n1h_v3 ns32k
 lappend cpus_expected or1k or1knd pj powerpc pyramid riscv romp rs6000 s390 sh sparc
 lappend cpus_expected tic54x tilegx tms320c30 tms320c4x tms320c54x
-lappend cpus_expected v850 vax x86-64 xscale xtensa z8k z8001 z8002
+lappend cpus_expected v850 vax x86-64 xscale xtensa z8k z8001 z8002 Loongarch64
 
 # Make sure the target CPU shows up in the list.
 lappend cpus_expected ${target_cpu}
H.J. Lu via Binutils Sept. 30, 2021, 9:20 a.m. | #2
On Sat, Sep 25, 2021 at 11:03 AM 徐成华 <xuchenghua@loongson.cn> wrote:
>

> From 9d9febbf7f6b3dbcf084e37b83d21cba8001b3ac Mon Sep 17 00:00:00 2001

> From: Chenghua Xu <xuchenghua@loongson.cn>

> Date: Sun, 19 Sep 2021 09:42:59 +0800

> Subject: [PATCH 3/5] binutils: LoongArch Binutils Port.

>

> ---

>  binutils/readelf.c                          | 10 ++++++++++

>  binutils/testsuite/binutils-all/objdump.exp |  2 +-

>  2 files changed, 11 insertions(+), 1 deletion(-)

>

> diff --git a/binutils/readelf.c b/binutils/readelf.c

> index 4a6fcff3cc1..031bcd3711e 100644

> --- a/binutils/readelf.c

> +++ b/binutils/readelf.c

> @@ -162,6 +162,7 @@

>  #include "elf/xstormy16.h"

>  #include "elf/xtensa.h"

>  #include "elf/z80.h"

> +#include "elf/loongarch.h"

>

>  #include "getopt.h"

>  #include "libiberty.h"

> @@ -1653,6 +1654,11 @@ dump_relocations (Filedata *          filedata,

>         case EM_Z80:

>           rtype = elf_z80_reloc_type (type);

>           break;

> +

> +       case EM_LOONGARCH:

> +         rtype = elf_loongarch_reloc_type (type);

> +         break;

> +

>         }

>

>        if (rtype == NULL)

> @@ -13673,6 +13679,8 @@ is_32bit_abs_reloc (Filedata * filedata, unsigned int reloc_type)

>        return reloc_type == 2; /* R_IQ2000_32.  */

>      case EM_LATTICEMICO32:

>        return reloc_type == 3; /* R_LM32_32.  */

> +    case EM_LOONGARCH:

> +      return reloc_type == 1; /* R_LARCH_32. */

>      case EM_M32C_OLD:

>      case EM_M32C:

>        return reloc_type == 3; /* R_M32C_32.  */

> @@ -13890,6 +13898,8 @@ is_64bit_abs_reloc (Filedata * filedata, unsigned int reloc_type)

>      case EM_IA_64:

>        return (reloc_type == 0x26    /* R_IA64_DIR64MSB.  */

>               || reloc_type == 0x27 /* R_IA64_DIR64LSB.  */);

> +    case EM_LOONGARCH:

> +      return reloc_type == 2;      /* R_LARCH_64 */

>      case EM_PARISC:

>        return reloc_type == 80; /* R_PARISC_DIR64.  */

>      case EM_PPC64:

> diff --git a/binutils/testsuite/binutils-all/objdump.exp b/binutils/testsuite/binutils-all/objdump.exp

> index 0b797f9e9b4..2e23aca0d47 100644

> --- a/binutils/testsuite/binutils-all/objdump.exp

> +++ b/binutils/testsuite/binutils-all/objdump.exp

> @@ -40,7 +40,7 @@ lappend cpus_expected m16c m32c m32r m68hc11 m68hc12 m68k MCore mep c5 h1 MicroB

>  lappend cpus_expected mips mn10200 mn10300 ms1 msp MSP430 nds32 n1h_v3 ns32k

>  lappend cpus_expected or1k or1knd pj powerpc pyramid riscv romp rs6000 s390 sh sparc

>  lappend cpus_expected tic54x tilegx tms320c30 tms320c4x tms320c54x

> -lappend cpus_expected v850 vax x86-64 xscale xtensa z8k z8001 z8002

> +lappend cpus_expected v850 vax x86-64 xscale xtensa z8k z8001 z8002 Loongarch64

>

>  # Make sure the target CPU shows up in the list.

>  lappend cpus_expected ${target_cpu}

> --

> 2.27.0

>

>

>

>

> </xuchenghua@loongson.cn>

>

> 本邮件及其附件含有龙芯中科的商业秘密信息,仅限于发送给上面地址中列出的个人或群组。禁止任何其他人以任何形式使用(包括但不限于全部或部分地泄露、复制或散发)本邮件及其附件中的信息。如果您错收本邮件,请您立即电话或邮件通知发件人并删除本邮件。

> This email and its attachments contain confidential information from Loongson Technology , which is intended only for the person or entity whose address is listed above. Any use of the information contained herein in any way (including, but not limited to, total or partial disclosure, reproduction or dissemination) by persons other than the intended recipient(s) is prohibited. If you receive this email in error, please notify the sender by phone or email immediately and delete it.
From c88c20892dcd2d587f43e5819c82baaed0047572 Mon Sep 17 00:00:00 2001
From: Chenghua Xu <xuchenghua@loongson.cn>
Date: Sun, 19 Sep 2021 09:42:59 +0800
Subject: [PATCH 3/5] binutils: LoongArch Binutils Port.

---
 binutils/NEWS                               |  2 ++
 binutils/readelf.c                          | 10 ++++++++++
 binutils/testsuite/binutils-all/objdump.exp |  2 +-
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/binutils/NEWS b/binutils/NEWS
index 8a73387bee8..e6977b650db 100644
--- a/binutils/NEWS
+++ b/binutils/NEWS
@@ -1,5 +1,7 @@
 -*- text -*-
 
+* Add support for the LoongArch instruction set.
+
 Changes in 2.37:
 
 * The readelf tool has a new command line option which can be used to specify
diff --git a/binutils/readelf.c b/binutils/readelf.c
index 4a6fcff3cc1..031bcd3711e 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -162,6 +162,7 @@
 #include "elf/xstormy16.h"
 #include "elf/xtensa.h"
 #include "elf/z80.h"
+#include "elf/loongarch.h"
 
 #include "getopt.h"
 #include "libiberty.h"
@@ -1653,6 +1654,11 @@ dump_relocations (Filedata *          filedata,
 	case EM_Z80:
 	  rtype = elf_z80_reloc_type (type);
 	  break;
+
+	case EM_LOONGARCH:
+	  rtype = elf_loongarch_reloc_type (type);
+	  break;
+
 	}
 
       if (rtype == NULL)
@@ -13673,6 +13679,8 @@ is_32bit_abs_reloc (Filedata * filedata, unsigned int reloc_type)
       return reloc_type == 2; /* R_IQ2000_32.  */
     case EM_LATTICEMICO32:
       return reloc_type == 3; /* R_LM32_32.  */
+    case EM_LOONGARCH:
+      return reloc_type == 1; /* R_LARCH_32. */
     case EM_M32C_OLD:
     case EM_M32C:
       return reloc_type == 3; /* R_M32C_32.  */
@@ -13890,6 +13898,8 @@ is_64bit_abs_reloc (Filedata * filedata, unsigned int reloc_type)
     case EM_IA_64:
       return (reloc_type == 0x26    /* R_IA64_DIR64MSB.  */
 	      || reloc_type == 0x27 /* R_IA64_DIR64LSB.  */);
+    case EM_LOONGARCH:
+      return reloc_type == 2;      /* R_LARCH_64 */
     case EM_PARISC:
       return reloc_type == 80; /* R_PARISC_DIR64.  */
     case EM_PPC64:
diff --git a/binutils/testsuite/binutils-all/objdump.exp b/binutils/testsuite/binutils-all/objdump.exp
index 0b797f9e9b4..2e23aca0d47 100644
--- a/binutils/testsuite/binutils-all/objdump.exp
+++ b/binutils/testsuite/binutils-all/objdump.exp
@@ -40,7 +40,7 @@ lappend cpus_expected m16c m32c m32r m68hc11 m68hc12 m68k MCore mep c5 h1 MicroB
 lappend cpus_expected mips mn10200 mn10300 ms1 msp MSP430 nds32 n1h_v3 ns32k
 lappend cpus_expected or1k or1knd pj powerpc pyramid riscv romp rs6000 s390 sh sparc
 lappend cpus_expected tic54x tilegx tms320c30 tms320c4x tms320c54x
-lappend cpus_expected v850 vax x86-64 xscale xtensa z8k z8001 z8002
+lappend cpus_expected v850 vax x86-64 xscale xtensa z8k z8001 z8002 Loongarch64
 
 # Make sure the target CPU shows up in the list.
 lappend cpus_expected ${target_cpu}

Patch

diff --git a/binutils/readelf.c b/binutils/readelf.c
index 4a6fcff3cc1..031bcd3711e 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -162,6 +162,7 @@ 
 #include "elf/xstormy16.h"
 #include "elf/xtensa.h"
 #include "elf/z80.h"
+#include "elf/loongarch.h"

 #include "getopt.h"
 #include "libiberty.h"
@@ -1653,6 +1654,11 @@  dump_relocations (Filedata *          filedata,
  case EM_Z80:
    rtype = elf_z80_reloc_type (type);
    break;
+
+ case EM_LOONGARCH:
+   rtype = elf_loongarch_reloc_type (type);
+   break;
+
  }

       if (rtype == NULL)
@@ -13673,6 +13679,8 @@  is_32bit_abs_reloc (Filedata * filedata,
unsigned int reloc_type)
       return reloc_type == 2; /* R_IQ2000_32.  */
     case EM_LATTICEMICO32:
       return reloc_type == 3; /* R_LM32_32.  */
+    case EM_LOONGARCH:
+      return reloc_type == 1; /* R_LARCH_32. */
     case EM_M32C_OLD:
     case EM_M32C:
       return reloc_type == 3; /* R_M32C_32.  */
@@ -13890,6 +13898,8 @@  is_64bit_abs_reloc (Filedata * filedata,
unsigned int reloc_type)
     case EM_IA_64:
       return (reloc_type == 0x26    /* R_IA64_DIR64MSB.  */
        || reloc_type == 0x27 /* R_IA64_DIR64LSB.  */);
+    case EM_LOONGARCH:
+      return reloc_type == 2;      /* R_LARCH_64 */
     case EM_PARISC:
       return reloc_type == 80; /* R_PARISC_DIR64.  */
     case EM_PPC64:
diff --git a/binutils/testsuite/binutils-all/objdump.exp
b/binutils/testsuite/binutils-all/objdump.exp
index 0b797f9e9b4..2e23aca0d47 100644
--- a/binutils/testsuite/binutils-all/objdump.exp
+++ b/binutils/testsuite/binutils-all/objdump.exp
@@ -40,7 +40,7 @@  lappend cpus_expected m16c m32c m32r m68hc11 m68hc12
m68k MCore mep c5 h1 MicroB
 lappend cpus_expected mips mn10200 mn10300 ms1 msp MSP430 nds32 n1h_v3 ns32k
 lappend cpus_expected or1k or1knd pj powerpc pyramid riscv romp
rs6000 s390 sh sparc
 lappend cpus_expected tic54x tilegx tms320c30 tms320c4x tms320c54x
-lappend cpus_expected v850 vax x86-64 xscale xtensa z8k z8001 z8002
+lappend cpus_expected v850 vax x86-64 xscale xtensa z8k z8001 z8002 Loongarch64