Re: [PATCH V9 12/21] csky: ELF and module probe

2018-10-18 Thread Arnd Bergmann
On Thu, Oct 18, 2018 at 4:49 AM Guo Ren  wrote:
>
> On Wed, Oct 17, 2018 at 05:18:49PM +0200, Arnd Bergmann wrote:
> > On Tue, Oct 16, 2018 at 5:02 AM Guo Ren  wrote:
> > >
> > > This patch adds ELF definition and module relocate codes.
> > >
> > > Signed-off-by: Guo Ren 
> > > Cc: Arnd Bergmann 
> >
> > > +#ifdef __cskyBE__
> > > +#define ELF_DATA   ELFDATA2MSB
> > > +#else
> > > +#define ELF_DATA   ELFDATA2LSB
> > > +#endif
> >
> > You removed support for big-endian, right? I guess the #ifdef can also
> > get removed here then. Aside from that,
> Now, we only support little-endian and it could be removed. But maybe we
> need support big-endian in future, so I keep it here.

Ok, just made sure it was intentional.

   Arnd


Re: [PATCH V9 12/21] csky: ELF and module probe

2018-10-18 Thread Arnd Bergmann
On Thu, Oct 18, 2018 at 4:49 AM Guo Ren  wrote:
>
> On Wed, Oct 17, 2018 at 05:18:49PM +0200, Arnd Bergmann wrote:
> > On Tue, Oct 16, 2018 at 5:02 AM Guo Ren  wrote:
> > >
> > > This patch adds ELF definition and module relocate codes.
> > >
> > > Signed-off-by: Guo Ren 
> > > Cc: Arnd Bergmann 
> >
> > > +#ifdef __cskyBE__
> > > +#define ELF_DATA   ELFDATA2MSB
> > > +#else
> > > +#define ELF_DATA   ELFDATA2LSB
> > > +#endif
> >
> > You removed support for big-endian, right? I guess the #ifdef can also
> > get removed here then. Aside from that,
> Now, we only support little-endian and it could be removed. But maybe we
> need support big-endian in future, so I keep it here.

Ok, just made sure it was intentional.

   Arnd


Re: [PATCH V9 12/21] csky: ELF and module probe

2018-10-17 Thread Guo Ren
On Wed, Oct 17, 2018 at 05:18:49PM +0200, Arnd Bergmann wrote:
> On Tue, Oct 16, 2018 at 5:02 AM Guo Ren  wrote:
> >
> > This patch adds ELF definition and module relocate codes.
> >
> > Signed-off-by: Guo Ren 
> > Cc: Arnd Bergmann 
> 
> > +#ifdef __cskyBE__
> > +#define ELF_DATA   ELFDATA2MSB
> > +#else
> > +#define ELF_DATA   ELFDATA2LSB
> > +#endif
> 
> You removed support for big-endian, right? I guess the #ifdef can also
> get removed here then. Aside from that,
Now, we only support little-endian and it could be removed. But maybe we
need support big-endian in future, so I keep it here.

Best Regards
 Guo Ren


Re: [PATCH V9 12/21] csky: ELF and module probe

2018-10-17 Thread Guo Ren
On Wed, Oct 17, 2018 at 05:18:49PM +0200, Arnd Bergmann wrote:
> On Tue, Oct 16, 2018 at 5:02 AM Guo Ren  wrote:
> >
> > This patch adds ELF definition and module relocate codes.
> >
> > Signed-off-by: Guo Ren 
> > Cc: Arnd Bergmann 
> 
> > +#ifdef __cskyBE__
> > +#define ELF_DATA   ELFDATA2MSB
> > +#else
> > +#define ELF_DATA   ELFDATA2LSB
> > +#endif
> 
> You removed support for big-endian, right? I guess the #ifdef can also
> get removed here then. Aside from that,
Now, we only support little-endian and it could be removed. But maybe we
need support big-endian in future, so I keep it here.

Best Regards
 Guo Ren


Re: [PATCH V9 12/21] csky: ELF and module probe

2018-10-17 Thread Arnd Bergmann
On Tue, Oct 16, 2018 at 5:02 AM Guo Ren  wrote:
>
> This patch adds ELF definition and module relocate codes.
>
> Signed-off-by: Guo Ren 
> Cc: Arnd Bergmann 

> +#ifdef __cskyBE__
> +#define ELF_DATA   ELFDATA2MSB
> +#else
> +#define ELF_DATA   ELFDATA2LSB
> +#endif

You removed support for big-endian, right? I guess the #ifdef can also
get removed here then. Aside from that,

Reviewed-by: Arnd Bergmann 


Re: [PATCH V9 12/21] csky: ELF and module probe

2018-10-17 Thread Arnd Bergmann
On Tue, Oct 16, 2018 at 5:02 AM Guo Ren  wrote:
>
> This patch adds ELF definition and module relocate codes.
>
> Signed-off-by: Guo Ren 
> Cc: Arnd Bergmann 

> +#ifdef __cskyBE__
> +#define ELF_DATA   ELFDATA2MSB
> +#else
> +#define ELF_DATA   ELFDATA2LSB
> +#endif

You removed support for big-endian, right? I guess the #ifdef can also
get removed here then. Aside from that,

Reviewed-by: Arnd Bergmann 


[PATCH V9 12/21] csky: ELF and module probe

2018-10-15 Thread Guo Ren
This patch adds ELF definition and module relocate codes.

Signed-off-by: Guo Ren 
Cc: Arnd Bergmann 
---
 arch/csky/abiv1/inc/abi/elf.h | 26 
 arch/csky/abiv2/inc/abi/elf.h | 43 
 arch/csky/include/asm/elf.h   | 85 +++
 arch/csky/kernel/module.c | 92 +++
 4 files changed, 246 insertions(+)
 create mode 100644 arch/csky/abiv1/inc/abi/elf.h
 create mode 100644 arch/csky/abiv2/inc/abi/elf.h
 create mode 100644 arch/csky/include/asm/elf.h
 create mode 100644 arch/csky/kernel/module.c

diff --git a/arch/csky/abiv1/inc/abi/elf.h b/arch/csky/abiv1/inc/abi/elf.h
new file mode 100644
index 000..3058cc0
--- /dev/null
+++ b/arch/csky/abiv1/inc/abi/elf.h
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef __ABI_CSKY_ELF_H
+#define __ABI_CSKY_ELF_H
+
+#define ELF_CORE_COPY_REGS(pr_reg, regs) do {  \
+   pr_reg[0] = regs->pc;   \
+   pr_reg[1] = regs->regs[9];  \
+   pr_reg[2] = regs->usp;  \
+   pr_reg[3] = regs->sr;   \
+   pr_reg[4] = regs->a0;   \
+   pr_reg[5] = regs->a1;   \
+   pr_reg[6] = regs->a2;   \
+   pr_reg[7] = regs->a3;   \
+   pr_reg[8] = regs->regs[0];  \
+   pr_reg[9] = regs->regs[1];  \
+   pr_reg[10] = regs->regs[2]; \
+   pr_reg[11] = regs->regs[3]; \
+   pr_reg[12] = regs->regs[4]; \
+   pr_reg[13] = regs->regs[5]; \
+   pr_reg[14] = regs->regs[6]; \
+   pr_reg[15] = regs->regs[7]; \
+   pr_reg[16] = regs->regs[8]; \
+   pr_reg[17] = regs->lr;  \
+} while (0);
+#endif /* __ABI_CSKY_ELF_H */
diff --git a/arch/csky/abiv2/inc/abi/elf.h b/arch/csky/abiv2/inc/abi/elf.h
new file mode 100644
index 000..290f49e
--- /dev/null
+++ b/arch/csky/abiv2/inc/abi/elf.h
@@ -0,0 +1,43 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef __ABI_CSKY_ELF_H
+#define __ABI_CSKY_ELF_H
+
+/* The member sort in array pr_reg[x] is defined by GDB. */
+#define ELF_CORE_COPY_REGS(pr_reg, regs) do {  \
+   pr_reg[0] = regs->pc;   \
+   pr_reg[1] = regs->a1;   \
+   pr_reg[2] = regs->a0;   \
+   pr_reg[3] = regs->sr;   \
+   pr_reg[4] = regs->a2;   \
+   pr_reg[5] = regs->a3;   \
+   pr_reg[6] = regs->regs[0];  \
+   pr_reg[7] = regs->regs[1];  \
+   pr_reg[8] = regs->regs[2];  \
+   pr_reg[9] = regs->regs[3];  \
+   pr_reg[10] = regs->regs[4]; \
+   pr_reg[11] = regs->regs[5]; \
+   pr_reg[12] = regs->regs[6]; \
+   pr_reg[13] = regs->regs[7]; \
+   pr_reg[14] = regs->regs[8]; \
+   pr_reg[15] = regs->regs[9]; \
+   pr_reg[16] = regs->usp; \
+   pr_reg[17] = regs->lr;  \
+   pr_reg[18] = regs->exregs[0];   \
+   pr_reg[19] = regs->exregs[1];   \
+   pr_reg[20] = regs->exregs[2];   \
+   pr_reg[21] = regs->exregs[3];   \
+   pr_reg[22] = regs->exregs[4];   \
+   pr_reg[23] = regs->exregs[5];   \
+   pr_reg[24] = regs->exregs[6];   \
+   pr_reg[25] = regs->exregs[7];   \
+   pr_reg[26] = regs->exregs[8];   \
+   pr_reg[27] = regs->exregs[9];   \
+   pr_reg[28] = regs->exregs[10];  \
+   pr_reg[29] = regs->exregs[11];  \
+   pr_reg[30] = regs->exregs[12];  \
+   pr_reg[31] = regs->exregs[13];  \
+   pr_reg[32] = regs->exregs[14];  \
+   pr_reg[33] = regs->tls; \
+} while (0);
+#endif /* __ABI_CSKY_ELF_H */
diff --git a/arch/csky/include/asm/elf.h b/arch/csky/include/asm/elf.h
new file mode 100644
index 000..773b133
--- /dev/null
+++ b/arch/csky/include/asm/elf.h
@@ -0,0 +1,85 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+
+#ifndef __ASM_CSKY_ELF_H
+#define __ASM_CSKY_ELF_H
+
+#include 
+#include 
+
+#define ELF_ARCH 252
+
+/* CSKY Relocations */
+#define R_CSKY_NONE   0
+#define R_CSKY_32 1
+#define R_CSKY_PCIMM8BY4  2
+#define R_CSKY_PCIMM11BY2 3
+#define R_CSKY_PCIMM4BY2  4
+#define R_CSKY_PC32   5
+#define R_CSKY_PCRELJSR_IMM11BY2  6
+#define R_CSKY_GNU_VTINHERIT  7
+#define R_CSKY_GNU_VTENTRY8
+#define R_CSKY_RELATIVE   9
+#define R_CSKY_COPY   10
+#define R_CSKY_GLOB_DAT   11
+#define R_CSKY_JUMP_SLOT  12
+#define R_CSKY_ADDR_HI16  24
+#define R_CSKY_ADDR_LO16  25
+#define 

[PATCH V9 12/21] csky: ELF and module probe

2018-10-15 Thread Guo Ren
This patch adds ELF definition and module relocate codes.

Signed-off-by: Guo Ren 
Cc: Arnd Bergmann 
---
 arch/csky/abiv1/inc/abi/elf.h | 26 
 arch/csky/abiv2/inc/abi/elf.h | 43 
 arch/csky/include/asm/elf.h   | 85 +++
 arch/csky/kernel/module.c | 92 +++
 4 files changed, 246 insertions(+)
 create mode 100644 arch/csky/abiv1/inc/abi/elf.h
 create mode 100644 arch/csky/abiv2/inc/abi/elf.h
 create mode 100644 arch/csky/include/asm/elf.h
 create mode 100644 arch/csky/kernel/module.c

diff --git a/arch/csky/abiv1/inc/abi/elf.h b/arch/csky/abiv1/inc/abi/elf.h
new file mode 100644
index 000..3058cc0
--- /dev/null
+++ b/arch/csky/abiv1/inc/abi/elf.h
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef __ABI_CSKY_ELF_H
+#define __ABI_CSKY_ELF_H
+
+#define ELF_CORE_COPY_REGS(pr_reg, regs) do {  \
+   pr_reg[0] = regs->pc;   \
+   pr_reg[1] = regs->regs[9];  \
+   pr_reg[2] = regs->usp;  \
+   pr_reg[3] = regs->sr;   \
+   pr_reg[4] = regs->a0;   \
+   pr_reg[5] = regs->a1;   \
+   pr_reg[6] = regs->a2;   \
+   pr_reg[7] = regs->a3;   \
+   pr_reg[8] = regs->regs[0];  \
+   pr_reg[9] = regs->regs[1];  \
+   pr_reg[10] = regs->regs[2]; \
+   pr_reg[11] = regs->regs[3]; \
+   pr_reg[12] = regs->regs[4]; \
+   pr_reg[13] = regs->regs[5]; \
+   pr_reg[14] = regs->regs[6]; \
+   pr_reg[15] = regs->regs[7]; \
+   pr_reg[16] = regs->regs[8]; \
+   pr_reg[17] = regs->lr;  \
+} while (0);
+#endif /* __ABI_CSKY_ELF_H */
diff --git a/arch/csky/abiv2/inc/abi/elf.h b/arch/csky/abiv2/inc/abi/elf.h
new file mode 100644
index 000..290f49e
--- /dev/null
+++ b/arch/csky/abiv2/inc/abi/elf.h
@@ -0,0 +1,43 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef __ABI_CSKY_ELF_H
+#define __ABI_CSKY_ELF_H
+
+/* The member sort in array pr_reg[x] is defined by GDB. */
+#define ELF_CORE_COPY_REGS(pr_reg, regs) do {  \
+   pr_reg[0] = regs->pc;   \
+   pr_reg[1] = regs->a1;   \
+   pr_reg[2] = regs->a0;   \
+   pr_reg[3] = regs->sr;   \
+   pr_reg[4] = regs->a2;   \
+   pr_reg[5] = regs->a3;   \
+   pr_reg[6] = regs->regs[0];  \
+   pr_reg[7] = regs->regs[1];  \
+   pr_reg[8] = regs->regs[2];  \
+   pr_reg[9] = regs->regs[3];  \
+   pr_reg[10] = regs->regs[4]; \
+   pr_reg[11] = regs->regs[5]; \
+   pr_reg[12] = regs->regs[6]; \
+   pr_reg[13] = regs->regs[7]; \
+   pr_reg[14] = regs->regs[8]; \
+   pr_reg[15] = regs->regs[9]; \
+   pr_reg[16] = regs->usp; \
+   pr_reg[17] = regs->lr;  \
+   pr_reg[18] = regs->exregs[0];   \
+   pr_reg[19] = regs->exregs[1];   \
+   pr_reg[20] = regs->exregs[2];   \
+   pr_reg[21] = regs->exregs[3];   \
+   pr_reg[22] = regs->exregs[4];   \
+   pr_reg[23] = regs->exregs[5];   \
+   pr_reg[24] = regs->exregs[6];   \
+   pr_reg[25] = regs->exregs[7];   \
+   pr_reg[26] = regs->exregs[8];   \
+   pr_reg[27] = regs->exregs[9];   \
+   pr_reg[28] = regs->exregs[10];  \
+   pr_reg[29] = regs->exregs[11];  \
+   pr_reg[30] = regs->exregs[12];  \
+   pr_reg[31] = regs->exregs[13];  \
+   pr_reg[32] = regs->exregs[14];  \
+   pr_reg[33] = regs->tls; \
+} while (0);
+#endif /* __ABI_CSKY_ELF_H */
diff --git a/arch/csky/include/asm/elf.h b/arch/csky/include/asm/elf.h
new file mode 100644
index 000..773b133
--- /dev/null
+++ b/arch/csky/include/asm/elf.h
@@ -0,0 +1,85 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+
+#ifndef __ASM_CSKY_ELF_H
+#define __ASM_CSKY_ELF_H
+
+#include 
+#include 
+
+#define ELF_ARCH 252
+
+/* CSKY Relocations */
+#define R_CSKY_NONE   0
+#define R_CSKY_32 1
+#define R_CSKY_PCIMM8BY4  2
+#define R_CSKY_PCIMM11BY2 3
+#define R_CSKY_PCIMM4BY2  4
+#define R_CSKY_PC32   5
+#define R_CSKY_PCRELJSR_IMM11BY2  6
+#define R_CSKY_GNU_VTINHERIT  7
+#define R_CSKY_GNU_VTENTRY8
+#define R_CSKY_RELATIVE   9
+#define R_CSKY_COPY   10
+#define R_CSKY_GLOB_DAT   11
+#define R_CSKY_JUMP_SLOT  12
+#define R_CSKY_ADDR_HI16  24
+#define R_CSKY_ADDR_LO16  25
+#define