[coreboot-gerrit] Change in ...coreboot[master]: util/cbfstool: Support AMD64 rmodules
Patrick Georgi (Code Review)
gerrit at coreboot.org
Wed Dec 19 07:05:53 CET 2018
Patrick Georgi has submitted this change and it was merged. ( https://review.coreboot.org/c/coreboot/+/29874 )
Change subject: util/cbfstool: Support AMD64 rmodules
......................................................................
util/cbfstool: Support AMD64 rmodules
Add support for 64bit rmodule, as required for relocatable
ramstage on x86_64.
Change-Id: I7fbb3b4c0f76ce82c090b5f16f67a728b6bf94a5
Signed-off-by: Patrick Rudolph <siro at das-labor.org>
Reviewed-on: https://review.coreboot.org/c/29874
Reviewed-by: Philipp Deppenwiese <zaolin.daisuki at gmail.com>
Tested-by: build bot (Jenkins) <no-reply at coreboot.org>
---
M util/cbfstool/elf.h
M util/cbfstool/elfheaders.c
M util/cbfstool/rmodule.c
3 files changed, 72 insertions(+), 0 deletions(-)
Approvals:
build bot (Jenkins): Verified
Philipp Deppenwiese: Looks good to me, approved
diff --git a/util/cbfstool/elf.h b/util/cbfstool/elf.h
index a0bb35d..43fd7f3 100644
--- a/util/cbfstool/elf.h
+++ b/util/cbfstool/elf.h
@@ -1148,6 +1148,43 @@
/* Keep this the last entry. */
#define R_386_NUM 38
+/* AMD64 specific definitions. */
+#define R_AMD64_NONE 0 /* relocation types */
+#define R_AMD64_64 1
+#define R_AMD64_PC32 2
+#define R_AMD64_GOT32 3
+#define R_AMD64_PLT32 4
+#define R_AMD64_COPY 5
+#define R_AMD64_GLOB_DAT 6
+#define R_AMD64_JUMP_SLOT 7
+#define R_AMD64_RELATIVE 8
+#define R_AMD64_GOTPCREL 9
+#define R_AMD64_32 10
+#define R_AMD64_32S 11
+#define R_AMD64_16 12
+#define R_AMD64_PC16 13
+#define R_AMD64_8 14
+#define R_AMD64_PC8 15
+#define R_AMD64_DTPMOD64 16
+#define R_AMD64_DTPOFF64 17
+#define R_AMD64_TPOFF64 18
+#define R_AMD64_TLSGD 19
+#define R_AMD64_TLSLD 20
+#define R_AMD64_DTPOFF32 21
+#define R_AMD64_GOTTPOFF 22
+#define R_AMD64_TPOFF32 23
+#define R_AMD64_PC64 24
+#define R_AMD64_GOTOFF64 25
+#define R_AMD64_GOTPC32 26
+#define R_AMD64_GOT64 27 /* reserved for future expansion */
+#define R_AMD64_GOTPCREL64 28 /* reserved for future expansion */
+#define R_AMD64_GOTPC64 29 /* reserved for future expansion */
+#define R_AMD64_GOTPLT64 30 /* reserved for future expansion */
+#define R_AMD64_PLTOFF64 31 /* reserved for future expansion */
+#define R_AMD64_SIZE32 32
+#define R_AMD64_SIZE64 33
+#define R_AMD64_NUM 34
+
/* SUN SPARC specific definitions. */
/* Legal values for ST_TYPE subfield of st_info (symbol type). */
diff --git a/util/cbfstool/elfheaders.c b/util/cbfstool/elfheaders.c
index 9d02c30..8da54d0 100644
--- a/util/cbfstool/elfheaders.c
+++ b/util/cbfstool/elfheaders.c
@@ -1072,6 +1072,9 @@
case EM_386:
type = R_386_32;
break;
+ case EM_X86_64:
+ type = R_AMD64_64;
+ break;
case EM_ARM:
type = R_ARM_ABS32;
break;
diff --git a/util/cbfstool/rmodule.c b/util/cbfstool/rmodule.c
index ff8f1cd..f270e3e 100644
--- a/util/cbfstool/rmodule.c
+++ b/util/cbfstool/rmodule.c
@@ -44,6 +44,33 @@
return (type == R_386_32);
}
+static int valid_reloc_amd64(Elf64_Rela *rel)
+{
+ int type;
+
+ type = ELF64_R_TYPE(rel->r_info);
+
+ /* Only these 5 relocations are expected to be found. */
+ return (type == R_AMD64_64 ||
+ type == R_AMD64_PC64 ||
+ type == R_AMD64_32S ||
+ type == R_AMD64_32 ||
+ type == R_AMD64_PC32);
+}
+
+static int should_emit_amd64(Elf64_Rela *rel)
+{
+ int type;
+
+ type = ELF64_R_TYPE(rel->r_info);
+
+ /* Only emit absolute relocations */
+ return (type == R_AMD64_64 ||
+ type == R_AMD64_PC64 ||
+ type == R_AMD64_32S ||
+ type == R_AMD64_32);
+}
+
static int valid_reloc_arm(Elf64_Rela *rel)
{
int type;
@@ -101,6 +128,11 @@
.should_emit = should_emit_386,
},
{
+ .arch = EM_X86_64,
+ .valid_type = valid_reloc_amd64,
+ .should_emit = should_emit_amd64,
+ },
+ {
.arch = EM_ARM,
.valid_type = valid_reloc_arm,
.should_emit = should_emit_arm,
--
To view, visit https://review.coreboot.org/c/coreboot/+/29874
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I7fbb3b4c0f76ce82c090b5f16f67a728b6bf94a5
Gerrit-Change-Number: 29874
Gerrit-PatchSet: 4
Gerrit-Owner: Patrick Rudolph <siro at das-labor.org>
Gerrit-Reviewer: Patrick Georgi <pgeorgi at google.com>
Gerrit-Reviewer: Philipp Deppenwiese <zaolin.daisuki at gmail.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply at coreboot.org>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20181219/972a807e/attachment.html>
More information about the coreboot-gerrit
mailing list