public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/14] [LoongArch] Add relocations and ELF flags to elf.h
@ 2021-08-19  3:30 Paul Hua
  2021-08-19  3:48 ` Paul Hua
  0 siblings, 1 reply; 2+ messages in thread
From: Paul Hua @ 2021-08-19  3:30 UTC (permalink / raw)
  To: libc-alpha; +Cc: Xu Chenghua, caiyinyu, huangpei

[-- Attachment #1: Type: text/plain, Size: 1 bytes --]



[-- Attachment #2: 0001-LoongArch-Add-relocations-and-ELF-flags-to-elf.h.patch --]
[-- Type: text/x-patch, Size: 5311 bytes --]

From 07569b3406100ecc60b175cb7cfadf13547fe38d Mon Sep 17 00:00:00 2001
From: caiyinyu <caiyinyu@loongson.cn>
Date: Tue, 27 Jul 2021 15:14:34 +0800
Subject: [PATCH 01/14] LoongArch: Add relocations and ELF flags to elf.h

        * elf/elf.h (EM_LOONGARCH): New define.
        (EF_LARCH_ABI): Likewise.
        (EF_LARCH_ABI_LP64): Likewise.
        (EF_LARCH_ABI_LP32): Likewise.
        (R_LARCH_NONE): Likewise.
        (R_LARCH_32): Likewise.
        (R_LARCH_64): Likewise.
        (R_LARCH_RELATIVE): Likewise.
        (R_LARCH_COPY): Likewise.
        (R_LARCH_JUMP_SLOT): Likewise.
        (R_LARCH_TLS_DTPMOD32): Likewise.
        (R_LARCH_TLS_DTPMOD64): Likewise.
        (R_LARCH_TLS_DTPREL32): Likewise.
        (R_LARCH_TLS_DTPREL64): Likewise.
        (R_LARCH_TLS_TPREL32): Likewise.
        (R_LARCH_TLS_TPREL64): Likewise.
        (R_LARCH_IRELATIVE): Likewise.
        (R_LARCH_MARK_LA): Likewise.
        (R_LARCH_MARK_PCREL): Likewise.
        (R_LARCH_SOP_PUSH_PCREL): Likewise.
        (R_LARCH_SOP_PUSH_ABSOLUTE): Likewise.
        (R_LARCH_SOP_PUSH_DUP): Likewise.
        (R_LARCH_SOP_PUSH_GPREL): Likewise.
        (R_LARCH_SOP_PUSH_TLS_TPREL): Likewise.
        (R_LARCH_SOP_PUSH_TLS_GOT): Likewise.
        (R_LARCH_SOP_PUSH_TLS_GD): Likewise.
        (R_LARCH_SOP_PUSH_PLT_PCREL): Likewise.
        (R_LARCH_SOP_ASSERT): Likewise.
        (R_LARCH_SOP_NOT): Likewise.
        (R_LARCH_SOP_SUB): Likewise.
        (R_LARCH_SOP_SL): Likewise.
        (R_LARCH_SOP_SR): Likewise.
        (R_LARCH_SOP_ADD): Likewise.
        (R_LARCH_SOP_AND): Likewise.
        (R_LARCH_SOP_IF_ELSE): Likewise.
        (R_LARCH_SOP_POP_32_S_10_5): Likewise.
        (R_LARCH_SOP_POP_32_U_10_12): Likewise.
        (R_LARCH_SOP_POP_32_S_10_12): Likewise.
        (R_LARCH_SOP_POP_32_S_10_16): Likewise.
        (R_LARCH_SOP_POP_32_S_10_16_S2): Likewise.
        (R_LARCH_SOP_POP_32_S_5_20): Likewise.
        (R_LARCH_SOP_POP_32_S_0_5_10_16_S2): Likewise.
        (R_LARCH_SOP_POP_32_S_0_10_10_16_S2): Likewise.
        (R_LARCH_SOP_POP_32_U): Likewise.
        (R_LARCH_ADD8): Likewise.
        (R_LARCH_ADD16): Likewise.
        (R_LARCH_ADD24): Likewise.
        (R_LARCH_ADD32): Likewise.
        (R_LARCH_ADD64): Likewise.
        (R_LARCH_SUB8): Likewise.
        (R_LARCH_SUB16): Likewise.
        (R_LARCH_SUB24): Likewise.
        (R_LARCH_SUB32): Likewise.
        (R_LARCH_SUB64): Likewise.
        (R_LARCH_GNU_VTINHERIT): Likewise.
        (R_LARCH_GNU_VTENTRY): Likewise.
---
 elf/elf.h | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 71 insertions(+), 1 deletion(-)

diff --git a/elf/elf.h b/elf/elf.h
index 4738dfa28f..03ece6832d 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.  */
 
@@ -4034,6 +4035,75 @@ enum
 #define R_NDS32_TLS_TPOFF	102
 #define R_NDS32_TLS_DESC	119
 
+/* LoongArch ELF Flags */
+#define EF_LARCH_ABI    	0x0003
+#define EF_LARCH_ABI_LP64	0x0003
+#define EF_LARCH_ABI_LP32	0x0001
+
+/* 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
+
+  /* I don't know what it is.  Existing in almost all other arch.  */
+#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
-- 
2.27.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/14] [LoongArch] Add relocations and ELF flags to elf.h
  2021-08-19  3:30 [PATCH 1/14] [LoongArch] Add relocations and ELF flags to elf.h Paul Hua
@ 2021-08-19  3:48 ` Paul Hua
  0 siblings, 0 replies; 2+ messages in thread
From: Paul Hua @ 2021-08-19  3:48 UTC (permalink / raw)
  To: libc-alpha; +Cc: Xu Chenghua, caiyinyu, huangpei

send as plain text.

From 07569b3406100ecc60b175cb7cfadf13547fe38d Mon Sep 17 00:00:00 2001
From: caiyinyu <caiyinyu@loongson.cn>
Date: Tue, 27 Jul 2021 15:14:34 +0800
Subject: [PATCH 01/14] LoongArch: Add relocations and ELF flags to elf.h

        * elf/elf.h (EM_LOONGARCH): New define.
        (EF_LARCH_ABI): Likewise.
        (EF_LARCH_ABI_LP64): Likewise.
        (EF_LARCH_ABI_LP32): Likewise.
        (R_LARCH_NONE): Likewise.
        (R_LARCH_32): Likewise.
        (R_LARCH_64): Likewise.
        (R_LARCH_RELATIVE): Likewise.
        (R_LARCH_COPY): Likewise.
        (R_LARCH_JUMP_SLOT): Likewise.
        (R_LARCH_TLS_DTPMOD32): Likewise.
        (R_LARCH_TLS_DTPMOD64): Likewise.
        (R_LARCH_TLS_DTPREL32): Likewise.
        (R_LARCH_TLS_DTPREL64): Likewise.
        (R_LARCH_TLS_TPREL32): Likewise.
        (R_LARCH_TLS_TPREL64): Likewise.
        (R_LARCH_IRELATIVE): Likewise.
        (R_LARCH_MARK_LA): Likewise.
        (R_LARCH_MARK_PCREL): Likewise.
        (R_LARCH_SOP_PUSH_PCREL): Likewise.
        (R_LARCH_SOP_PUSH_ABSOLUTE): Likewise.
        (R_LARCH_SOP_PUSH_DUP): Likewise.
        (R_LARCH_SOP_PUSH_GPREL): Likewise.
        (R_LARCH_SOP_PUSH_TLS_TPREL): Likewise.
        (R_LARCH_SOP_PUSH_TLS_GOT): Likewise.
        (R_LARCH_SOP_PUSH_TLS_GD): Likewise.
        (R_LARCH_SOP_PUSH_PLT_PCREL): Likewise.
        (R_LARCH_SOP_ASSERT): Likewise.
        (R_LARCH_SOP_NOT): Likewise.
        (R_LARCH_SOP_SUB): Likewise.
        (R_LARCH_SOP_SL): Likewise.
        (R_LARCH_SOP_SR): Likewise.
        (R_LARCH_SOP_ADD): Likewise.
        (R_LARCH_SOP_AND): Likewise.
        (R_LARCH_SOP_IF_ELSE): Likewise.
        (R_LARCH_SOP_POP_32_S_10_5): Likewise.
        (R_LARCH_SOP_POP_32_U_10_12): Likewise.
        (R_LARCH_SOP_POP_32_S_10_12): Likewise.
        (R_LARCH_SOP_POP_32_S_10_16): Likewise.
        (R_LARCH_SOP_POP_32_S_10_16_S2): Likewise.
        (R_LARCH_SOP_POP_32_S_5_20): Likewise.
        (R_LARCH_SOP_POP_32_S_0_5_10_16_S2): Likewise.
        (R_LARCH_SOP_POP_32_S_0_10_10_16_S2): Likewise.
        (R_LARCH_SOP_POP_32_U): Likewise.
        (R_LARCH_ADD8): Likewise.
        (R_LARCH_ADD16): Likewise.
        (R_LARCH_ADD24): Likewise.
        (R_LARCH_ADD32): Likewise.
        (R_LARCH_ADD64): Likewise.
        (R_LARCH_SUB8): Likewise.
        (R_LARCH_SUB16): Likewise.
        (R_LARCH_SUB24): Likewise.
        (R_LARCH_SUB32): Likewise.
        (R_LARCH_SUB64): Likewise.
        (R_LARCH_GNU_VTINHERIT): Likewise.
        (R_LARCH_GNU_VTENTRY): Likewise.
---
 elf/elf.h | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 71 insertions(+), 1 deletion(-)

diff --git a/elf/elf.h b/elf/elf.h
index 4738dfa28f..03ece6832d 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.  */

@@ -4034,6 +4035,75 @@ enum
 #define R_NDS32_TLS_TPOFF 102
 #define R_NDS32_TLS_DESC 119

+/* LoongArch ELF Flags */
+#define EF_LARCH_ABI     0x0003
+#define EF_LARCH_ABI_LP64 0x0003
+#define EF_LARCH_ABI_LP32 0x0001
+
+/* 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
+
+  /* I don't know what it is.  Existing in almost all other arch.  */
+#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
-- 
2.27.0


On Thu, Aug 19, 2021 at 11:30 AM Paul Hua <paul.hua.gm@gmail.com> wrote:
>
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-08-19  3:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-19  3:30 [PATCH 1/14] [LoongArch] Add relocations and ELF flags to elf.h Paul Hua
2021-08-19  3:48 ` Paul Hua

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).