public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: caiyinyu <caiyinyu@loongson.cn>
To: libc-alpha@sourceware.org
Cc: joseph_myers@mentor.com, xuchenghua@loongson.cn,
	caiyinyu@loongson.cn, adhemerval.zanella@linaro.org
Subject: [PATCH v4 03/13] LoongArch: Add relocations and ELF flags to elf.h and scripts/glibcelf.py
Date: Mon,  9 May 2022 10:30:00 +0800	[thread overview]
Message-ID: <20220509023010.1250020-4-caiyinyu@loongson.cn> (raw)
In-Reply-To: <20220509023010.1250020-1-caiyinyu@loongson.cn>

---
 elf/elf.h           | 68 ++++++++++++++++++++++++++++++++++++++++++++-
 scripts/glibcelf.py |  3 +-
 2 files changed, 69 insertions(+), 2 deletions(-)

diff --git a/elf/elf.h b/elf/elf.h
index 0195029188..0f1455c052 100644
--- a/elf/elf.h
+++ b/elf/elf.h
@@ -358,8 +358,9 @@ typedef struct
 
 #define EM_BPF		247	/* Linux BPF -- in-kernel virtual machine */
 #define EM_CSKY		252     /* C-SKY */
+#define EM_LOONGARCH	258	/* LoongArch */
 
-#define EM_NUM		253
+#define EM_NUM		259
 
 /* Old spellings/synonyms.  */
 
@@ -4065,6 +4066,71 @@ enum
 #define R_NDS32_TLS_TPOFF	102
 #define R_NDS32_TLS_DESC	119
 
+/* LoongArch ELF Flags */
+#define EF_LARCH_ABI    	0x07
+#define EF_LARCH_ABI_LP64D	0x03
+
+/* LoongArch specific dynamic relocations */
+#define R_LARCH_NONE		0
+#define R_LARCH_32		1
+#define R_LARCH_64		2
+#define R_LARCH_RELATIVE	3
+#define R_LARCH_COPY		4
+#define R_LARCH_JUMP_SLOT	5
+#define R_LARCH_TLS_DTPMOD32	6
+#define R_LARCH_TLS_DTPMOD64	7
+#define R_LARCH_TLS_DTPREL32	8
+#define R_LARCH_TLS_DTPREL64	9
+#define R_LARCH_TLS_TPREL32	10
+#define R_LARCH_TLS_TPREL64	11
+#define R_LARCH_IRELATIVE	12
+
+/* Reserved for future relocs that the dynamic linker must understand.  */
+
+/* used by the static linker for relocating .text.  */
+#define R_LARCH_MARK_LA  20
+#define R_LARCH_MARK_PCREL  21
+#define R_LARCH_SOP_PUSH_PCREL  22
+#define R_LARCH_SOP_PUSH_ABSOLUTE  23
+#define R_LARCH_SOP_PUSH_DUP  24
+#define R_LARCH_SOP_PUSH_GPREL  25
+#define R_LARCH_SOP_PUSH_TLS_TPREL  26
+#define R_LARCH_SOP_PUSH_TLS_GOT  27
+#define R_LARCH_SOP_PUSH_TLS_GD  28
+#define R_LARCH_SOP_PUSH_PLT_PCREL  29
+#define R_LARCH_SOP_ASSERT  30
+#define R_LARCH_SOP_NOT  31
+#define R_LARCH_SOP_SUB  32
+#define R_LARCH_SOP_SL  33
+#define R_LARCH_SOP_SR  34
+#define R_LARCH_SOP_ADD  35
+#define R_LARCH_SOP_AND  36
+#define R_LARCH_SOP_IF_ELSE  37
+#define R_LARCH_SOP_POP_32_S_10_5  38
+#define R_LARCH_SOP_POP_32_U_10_12  39
+#define R_LARCH_SOP_POP_32_S_10_12  40
+#define R_LARCH_SOP_POP_32_S_10_16  41
+#define R_LARCH_SOP_POP_32_S_10_16_S2  42
+#define R_LARCH_SOP_POP_32_S_5_20  43
+#define R_LARCH_SOP_POP_32_S_0_5_10_16_S2  44
+#define R_LARCH_SOP_POP_32_S_0_10_10_16_S2  45
+#define R_LARCH_SOP_POP_32_U  46
+
+/* used by the static linker for relocating non .text.  */
+#define R_LARCH_ADD8  47
+#define R_LARCH_ADD16  48
+#define R_LARCH_ADD24  49
+#define R_LARCH_ADD32  50
+#define R_LARCH_ADD64  51
+#define R_LARCH_SUB8  52
+#define R_LARCH_SUB16  53
+#define R_LARCH_SUB24  54
+#define R_LARCH_SUB32  55
+#define R_LARCH_SUB64  56
+#define R_LARCH_GNU_VTINHERIT  57
+#define R_LARCH_GNU_VTENTRY  58
+
+
 /* ARCompact/ARCv2 specific relocs.  */
 #define R_ARC_NONE		0x0
 #define R_ARC_8			0x1
diff --git a/scripts/glibcelf.py b/scripts/glibcelf.py
index f847b36c55..b7570ae2f3 100644
--- a/scripts/glibcelf.py
+++ b/scripts/glibcelf.py
@@ -252,7 +252,8 @@ class Machine(_OpenIntEnum):
     EM_RISCV = 243
     EM_BPF = 247
     EM_CSKY = 252
-    EM_NUM = 253
+    EM_LOONGARCH = 258
+    EM_NUM = 259
     EM_ALPHA = 0x9026
 
 class Et(_OpenIntEnum):
-- 
2.31.1


  parent reply	other threads:[~2022-05-09  2:30 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-09  2:29 [PATCH v4 00/13] GLIBC LoongArch PATCHES caiyinyu
2022-05-09  2:29 ` [PATCH v4 01/13] LoongArch: Update NEWS and README for the LoongArch port caiyinyu
2022-05-09  2:29 ` [PATCH v4 02/13] LoongArch: Add LoongArch entries to config.h.in caiyinyu
2022-05-09  2:30 ` caiyinyu [this message]
2022-05-09  2:30 ` [PATCH v4 04/13] LoongArch: ABI Implementation caiyinyu
2022-05-09  7:56   ` Fangrui Song
2022-05-24  9:49     ` 回复: " caiyinyu
2022-05-24 19:55       ` Fangrui Song
2022-05-09  8:20   ` Fangrui Song
2022-05-09 11:33     ` Adhemerval Zanella
2022-05-09 12:39   ` Adhemerval Zanella
2022-05-09 12:46     ` Florian Weimer
2022-05-29 13:10   ` Adhemerval Zanella
2022-05-09  2:30 ` [PATCH v4 05/13] LoongArch: Thread-Local Storage Support caiyinyu
2022-05-09  2:30 ` [PATCH v4 06/13] LoongArch: Generic <math.h> and soft-fp Routines caiyinyu
2022-05-09  2:30 ` [PATCH v4 07/13] LoongArch: Atomic and Locking Routines caiyinyu
2022-05-09  2:30 ` [PATCH v4 08/13] LoongArch: Linux Syscall Interface caiyinyu
2022-05-09  2:30 ` [PATCH v4 09/13] LoongArch: Linux ABI caiyinyu
2022-05-09  2:30 ` [PATCH v4 10/13] LoongArch: Add ABI Lists caiyinyu
  -- strict thread matches above, loose matches on Subject: below --
2022-05-09  2:25 [PATCH v3 00/13] GLIBC LoongArch PATCHES caiyinyu
2022-05-09  2:26 ` [PATCH v4 03/13] LoongArch: Add relocations and ELF flags to elf.h and scripts/glibcelf.py caiyinyu

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=20220509023010.1250020-4-caiyinyu@loongson.cn \
    --to=caiyinyu@loongson.cn \
    --cc=adhemerval.zanella@linaro.org \
    --cc=joseph_myers@mentor.com \
    --cc=libc-alpha@sourceware.org \
    --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).