public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: liuzhensong <liuzhensong@loongson.cn>
To: binutils@sourceware.org
Cc: i.swmail@xen0n.name, xry111@xry111.site, maskray@google.com,
	caiyinyu@loongson.cn, chenglulu@loongson.cn,
	mengqinggang@loongson.cn, xuchenghua@loongson.cn,
	liuzhensong <liuzhensong@loongson.cn>
Subject: [PATCH] LoongArch: Set e_flags to 0x40 of ELF while using new relocations.
Date: Wed, 17 Aug 2022 15:11:36 +0800	[thread overview]
Message-ID: <20220817071136.2325331-1-liuzhensong@loongson.cn> (raw)

---
 bfd/elfnn-loongarch.c     | 10 ++++++++++
 binutils/readelf.c        | 11 ++++++++---
 gas/config/tc-loongarch.c |  1 +
 include/elf/loongarch.h   |  7 +++++++
 4 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c
index 8d0f66ea7c1..ff1b25dde34 100644
--- a/bfd/elfnn-loongarch.c
+++ b/bfd/elfnn-loongarch.c
@@ -416,6 +416,16 @@ elfNN_loongarch_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info)
       elf_elfheader (obfd)->e_flags = in_flags;
       return true;
     }
+  else if (out_flags != in_flags)
+    {
+      /* Only check relocation version.
+	 The obj_v0 is compatible with obj_v1 in this "release cycle".  */
+      if ((EF_LOONGARCH_IS_OBJ_V0 (out_flags)
+	   && EF_LOONGARCH_IS_OBJ_V1 (in_flags))
+	  || (EF_LOONGARCH_IS_OBJ_V0 (in_flags)
+	      && EF_LOONGARCH_IS_OBJ_V1 (out_flags)))
+	elf_elfheader (obfd)->e_flags |= EF_LOONGARCH_ABI_OBJ_V1;
+    }
 
   /* Disallow linking different ABIs.  */
   if (EF_LOONGARCH_ABI(out_flags ^ in_flags) & EF_LOONGARCH_ABI_MASK)
diff --git a/binutils/readelf.c b/binutils/readelf.c
index 1ec25239938..4aa164bc3d9 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -4346,11 +4346,16 @@ get_machine_flags (Filedata * filedata, unsigned e_flags, unsigned e_machine)
 	    strcat (buf, ", ILP32");
 
 	  if (EF_LOONGARCH_IS_SOFT_FLOAT (e_flags))
-	    strcat (buf, ", SOFT-FLOAT");
+	    strcat (buf, "S");
 	  else if (EF_LOONGARCH_IS_SINGLE_FLOAT (e_flags))
-	    strcat (buf, ", SINGLE-FLOAT");
+	    strcat (buf, "F");
 	  else if (EF_LOONGARCH_IS_DOUBLE_FLOAT (e_flags))
-	    strcat (buf, ", DOUBLE-FLOAT");
+	    strcat (buf, "D");
+
+	  if (EF_LOONGARCH_IS_OBJ_V0 (e_flags))
+	    strcat (buf, ", ABI-v0");
+	  else if (EF_LOONGARCH_IS_OBJ_V1 (e_flags))
+	    strcat (buf, ", ABI-v1");
 
 	  break;
 	}
diff --git a/gas/config/tc-loongarch.c b/gas/config/tc-loongarch.c
index fbbaca55085..6a4d7e00ab5 100644
--- a/gas/config/tc-loongarch.c
+++ b/gas/config/tc-loongarch.c
@@ -234,6 +234,7 @@ loongarch_after_parse_args ()
 	as_bad ("unknown default architecture `%s'", default_arch);
     }
 
+  LARCH_opts.ase_abi |= EF_LOONGARCH_ABI_OBJ_V1;
   /* Set default ISA double-float.  */
   if (!LARCH_opts.ase_nf
       && !LARCH_opts.ase_sf
diff --git a/include/elf/loongarch.h b/include/elf/loongarch.h
index 74757b82ca8..f8f7adb1655 100644
--- a/include/elf/loongarch.h
+++ b/include/elf/loongarch.h
@@ -248,6 +248,9 @@ END_RELOC_NUMBERS (R_LARCH_count)
 #define EF_LOONGARCH_ABI_SINGLE_FLOAT_MASK	0x2
 #define EF_LOONGARCH_ABI_DOUBLE_FLOAT_MASK	0x3
 
+#define EF_LOONGARCH_ABI_OBJ_V1  		0x40
+#define EF_LOONGARCH_ABI_OBJ_MASK		0xC0
+
 #define EF_LOONGARCH_ABI(abi)	(EF_LOONGARCH_ABI_MASK & (abi))
 
 #define EF_LOONGARCH_IS_LP64(abi) \
@@ -264,4 +267,8 @@ END_RELOC_NUMBERS (R_LARCH_count)
 #define EF_LOONGARCH_IS_DOUBLE_FLOAT(abi) \
   (!((EF_LOONGARCH_ABI(abi) & EF_LOONGARCH_ABI_FLOAT_MASK) ^ EF_LOONGARCH_ABI_DOUBLE_FLOAT_MASK))
 
+#define EF_LOONGARCH_IS_OBJ_V0(abi) (!((abi) & EF_LOONGARCH_ABI_OBJ_MASK))
+#define EF_LOONGARCH_IS_OBJ_V1(abi) \
+      (((abi) & EF_LOONGARCH_ABI_OBJ_MASK) == EF_LOONGARCH_ABI_OBJ_V1)
+
 #endif /* _ELF_LOONGARCH_H */
-- 
2.31.1


                 reply	other threads:[~2022-08-17  7:11 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20220817071136.2325331-1-liuzhensong@loongson.cn \
    --to=liuzhensong@loongson.cn \
    --cc=binutils@sourceware.org \
    --cc=caiyinyu@loongson.cn \
    --cc=chenglulu@loongson.cn \
    --cc=i.swmail@xen0n.name \
    --cc=maskray@google.com \
    --cc=mengqinggang@loongson.cn \
    --cc=xry111@xry111.site \
    --cc=xuchenghua@loongson.cn \
    /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).