[coreboot-gerrit] New patch to review for coreboot: 018c00c RISCV: add this architecture to cbfstool
Ronald G. Minnich (rminnich@gmail.com)
gerrit at coreboot.org
Thu Oct 16 12:56:03 CEST 2014
Ronald G. Minnich (rminnich at gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/7067
-gerrit
commit 018c00cbe8f3c571239dbf3e5fd31582004e93bc
Author: Ronald G. Minnich <rminnich at gmail.com>
Date: Thu Oct 16 10:55:39 2014 +0000
RISCV: add this architecture to cbfstool
Change-Id: I6d972e595f12585cda08e1a6d2b94b4bf4f212f5
Signed-off-by: Ronald G. Minnich <rminnich at gmail.com>
---
util/cbfstool/cbfs.h | 1 +
util/cbfstool/common.c | 1 +
util/cbfstool/elf.h | 44 ++++++++++++++++++++++++++++++++++++++++++++
util/cbfstool/elfheaders.c | 1 +
4 files changed, 47 insertions(+)
diff --git a/util/cbfstool/cbfs.h b/util/cbfstool/cbfs.h
index 348a4da..9af801c 100644
--- a/util/cbfstool/cbfs.h
+++ b/util/cbfstool/cbfs.h
@@ -53,6 +53,7 @@ struct cbfs_header {
#define CBFS_ARCHITECTURE_X86 0x00000001
#define CBFS_ARCHITECTURE_ARM 0x00000010
#define CBFS_ARCHITECTURE_AARCH64 0x0000aa64
+#define CBFS_ARCHITECTURE_RISCV 0xc001d0de
#define CBFS_FILE_MAGIC "LARCHIVE"
diff --git a/util/cbfstool/common.c b/util/cbfstool/common.c
index 7347fcb..d990ddd 100644
--- a/util/cbfstool/common.c
+++ b/util/cbfstool/common.c
@@ -132,6 +132,7 @@ static struct {
} arch_names[] = {
{ CBFS_ARCHITECTURE_AARCH64, "arm64" },
{ CBFS_ARCHITECTURE_ARM, "arm" },
+ { CBFS_ARCHITECTURE_RISCV, "riscv" },
{ CBFS_ARCHITECTURE_X86, "x86" },
{ CBFS_ARCHITECTURE_UNKNOWN, "unknown" }
};
diff --git a/util/cbfstool/elf.h b/util/cbfstool/elf.h
index 0795815..d07bb53 100644
--- a/util/cbfstool/elf.h
+++ b/util/cbfstool/elf.h
@@ -2688,4 +2688,48 @@ typedef Elf32_Addr Elf32_Conflict;
#define R_M32R_NUM 256 /* Keep this the last entry. */
+/* RISC-V relocation types */
+#define R_RISCV_NONE 0
+#define R_RISCV_32 2
+#define R_RISCV_REL32 3
+#define R_RISCV_JAL 4
+#define R_RISCV_HI20 5
+#define R_RISCV_LO12_I 6
+#define R_RISCV_LO12_S 7
+#define R_RISCV_PCREL_LO12_I 8
+#define R_RISCV_PCREL_LO12_S 9
+#define R_RISCV_BRANCH 10
+#define R_RISCV_CALL 11
+#define R_RISCV_PCREL_HI20 12
+#define R_RISCV_CALL_PLT 13
+#define R_RISCV_64 18
+#define R_RISCV_GOT_HI20 22
+#define R_RISCV_GOT_LO12 23
+#define R_RISCV_COPY 24
+#define R_RISCV_JUMP_SLOT 25
+/* TLS relocations */
+#define R_RISCV_TPREL_HI20 30
+#define R_RISCV_TPREL_LO12_I 31
+#define R_RISCV_TPREL_LO12_S 32
+#define R_RISCV_TLS_DTPMOD32 38
+#define R_RISCV_TLS_DTPREL32 39
+#define R_RISCV_TLS_DTPMOD64 40
+#define R_RISCV_TLS_DTPREL64 41
+#define R_RISCV_TLS_GD 42
+#define R_RISCV_TLS_DTPREL_HI16 44
+#define R_RISCV_TLS_DTPREL_LO16 45
+#define R_RISCV_TLS_GOTTPREL 46
+#define R_RISCV_TLS_TPREL32 47
+#define R_RISCV_TLS_TPREL64 48
+#define R_RISCV_TLS_GOT_HI20 51
+#define R_RISCV_TLS_GOT_LO12 52
+#define R_RISCV_TLS_GD_HI20 53
+#define R_RISCV_TLS_GD_LO12 54
+#define R_RISCV_GLOB_DAT 57
+#define R_RISCV_ADD32 58
+#define R_RISCV_ADD64 59
+#define R_RISCV_SUB32 60
+#define R_RISCV_SUB64 61
+
+#define EM_RISCV 0xF3
#endif /* elf.h */
diff --git a/util/cbfstool/elfheaders.c b/util/cbfstool/elfheaders.c
index 4c0de89..634e76a 100644
--- a/util/cbfstool/elfheaders.c
+++ b/util/cbfstool/elfheaders.c
@@ -611,6 +611,7 @@ elf_headers(const struct buffer *pinput,
// The tool may work in architecture-independent way.
if (arch != CBFS_ARCHITECTURE_UNKNOWN &&
!((ehdr->e_machine == EM_ARM) && (arch == CBFS_ARCHITECTURE_ARM)) &&
+ !((ehdr->e_machine == EM_RISCV) && (arch == CBFS_ARCHITECTURE_RISCV)) &&
!((ehdr->e_machine == EM_386) && (arch == CBFS_ARCHITECTURE_X86))) {
ERROR("The stage file has the wrong architecture\n");
return -1;
More information about the coreboot-gerrit
mailing list