Hi!

On Sat, 2022-11-05 at 18:08:03 +0800, 张丹丹 wrote:
> Package: dpkg
> Version: 1.21.10
> Severity: wishlist
> Tags: patch
> User: debian-de...@lists.debian.org
> Usertags: loongarch64

> According to the result of disscussion from 
> debian-d...@lists.debian.org(https://lists.debian.org/debian-dpkg/2022/11/msg00001.html),
>  guil...@debian.org, hel...@subdivi.de, *@loongson.cn and so on.
> Dpkg architecture of loong64 just determine the name of the software packages.
> Should add loong64 architecture to dpkg package?
> 
> - Add support for loongarch64 CPU.
> Here is a simple patch to dpkg for the loongarch64.
> Please download from attachment.
> 
> - Have an official GNU triplet in the GNU config project. 
> https://git.savannah.gnu.org/cgit/config.git/commit/?id=c8ddc8472f8efcadafc1ef53ca1d863415fddd5f
> 
> - GNU binutils, gcc, and the respective libc project have merged by upstream.
> Binutils: 
> https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob_plain;f=binutils/NEWS;hb=refs/heads/binutils-2_39-branch
> Gcc: https://gcc.gnu.org/gcc-12/changes.html
> Glibc: https://sourceware.org/pipermail/libc-alpha/2022-August/141193.html
> 
> 
> - Please tell me if I've missed something.

I think the part that was missing, which was asked on the list, and a
rather important part of this! :) Is the ABI this conforms to.

I'm attaching a patch that updates the test suite so that it passes,
and adds what I think (but I don't know as I didn't check deeper) might
change the ABI for built objects, which ties into the ABI this
architecture is intended to conform to.

I guess the main question is whether objects with these different
EF_LOONGARCH_* flags can be mixed when linking or they are ABI
incompatible, as the code in the patch now assume.

Thanks,
Guillem
From bd0462298d5cf833ab47b0124ca470d0e156d902 Mon Sep 17 00:00:00 2001
From: Guillem Jover <guil...@debian.org>
Date: Fri, 11 Nov 2022 12:43:38 +0100
Subject: [PATCH] arch: Add support for loong64 CPU
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This is based on the LoongArch 64-bit little-endian hard-float ISA.

Closes: #1023486
Based-on-patch-by: 张丹丹 <zhangdan...@loongson.cn>
---
 data/cputable                  | 1 +
 scripts/Dpkg/Shlibs/Objdump.pm | 9 +++++++++
 scripts/t/Dpkg_Arch.t          | 4 ++--
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/data/cputable b/data/cputable
index 172cea3f5..7b1ee2c58 100644
--- a/data/cputable
+++ b/data/cputable
@@ -26,6 +26,7 @@ arm		arm		arm.*			32	little
 arm64		aarch64		aarch64			64	little
 avr32		avr32		avr32			32	big
 hppa		hppa		hppa.*			32	big
+loong64		loongarch64	loongarch64		64	little
 i386		i686		(i[34567]86|pentium)	32	little
 ia64		ia64		ia64			64	little
 m32r		m32r		m32r			32	big
diff --git a/scripts/Dpkg/Shlibs/Objdump.pm b/scripts/Dpkg/Shlibs/Objdump.pm
index baeb8bb5c..9deedb4b4 100644
--- a/scripts/Dpkg/Shlibs/Objdump.pm
+++ b/scripts/Dpkg/Shlibs/Objdump.pm
@@ -101,6 +101,7 @@ use constant {
     ELF_MACH_XTENSA         => 94,
     ELF_MACH_MICROBLAZE     => 189,
     ELF_MACH_ARCV2          => 195,
+    ELF_MACH_LOONGARCH      => 258,
     ELF_MACH_AVR_OLD        => 0x1057,
     ELF_MACH_OR1K_OLD       => 0x8472,
     ELF_MACH_ALPHA          => 0x9026,
@@ -125,6 +126,13 @@ use constant {
 
     ELF_FLAG_IA64_ABI64     => 0x00000010,
 
+    ELF_FLAG_LOONGARCH_SOFT_FLOAT   => 0x00000001,
+    ELF_FLAG_LOONGARCH_SINGLE_FLOAT => 0x00000002,
+    ELF_FLAG_LOONGARCH_DOUBLE_FLOAT => 0x00000003,
+    ELF_FLAG_LOONGARCH_ABI_MASK     => 0x00000007,
+    ELF_FLAG_LOONGARCH_OBJABI_V1    => 0x00000040,
+    ELF_FLAG_LOONGARCH_OBJABI_MASK  => 0x000000c0,
+
     ELF_FLAG_MIPS_ABI2      => 0x00000020,
     ELF_FLAG_MIPS_32BIT     => 0x00000100,
     ELF_FLAG_MIPS_FP64      => 0x00000200,
@@ -158,6 +166,7 @@ my %elf_mach_map = (
 # behavior, and we do not drop dependencies.
 my %elf_flags_mask = (
     ELF_MACH_IA64()     => ELF_FLAG_IA64_ABI64,
+    ELF_MACH_LOONGARCH() => ELF_FLAG_LOONGARCH_ABI_MASK | ELF_FLAG_LOONGARCH_OBJABI_MASK,
     ELF_MACH_MIPS()     => ELF_FLAG_MIPS_ABI_MASK | ELF_FLAG_MIPS_ABI2,
     ELF_MACH_PPC64()    => ELF_FLAG_PPC64_ABI64,
 );
diff --git a/scripts/t/Dpkg_Arch.t b/scripts/t/Dpkg_Arch.t
index 012f67c63..59855dfa4 100644
--- a/scripts/t/Dpkg_Arch.t
+++ b/scripts/t/Dpkg_Arch.t
@@ -16,7 +16,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 18407;
+use Test::More tests => 18900;
 
 use_ok('Dpkg::Arch', qw(debarch_to_debtuple debarch_to_multiarch
                         debarch_eq debarch_is debarch_is_wildcard
@@ -28,7 +28,7 @@ use_ok('Dpkg::Arch', qw(debarch_to_debtuple debarch_to_multiarch
                         get_host_gnu_type
                         get_valid_arches));
 
-my $KNOWN_ARCHES_TOTAL = 554;
+my $KNOWN_ARCHES_TOTAL = 569;
 my @valid_arches = get_valid_arches();
 
 sub get_valid_wildcards
-- 
2.38.1

Reply via email to