File crash-s390-kaslr-minimal-patchset.patch of Package crash.11845

Add --kaslr support for s390x kernels configured with
CONFIG_RANDOMIZE_BASE. Only kdumps or ELF dumps with
vmcoreinfo are supported.

Suggested-by: Gerald Schaefer <gerald.schaefer@de.ibm.com>
Signed-off-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
---
 help.c    | 2 +-
 main.c    | 3 ++-
 symbols.c | 9 +++++----
 3 files changed, 8 insertions(+), 6 deletions(-)

Index: b/help.c
===================================================================
--- a/help.c
+++ b/help.c
@@ -333,7 +333,7 @@ char *program_usage_info[] = {
     "    and verification.  The default count is 32768.",
     "",
     "  --kaslr offset | auto",
-    "    If an x86 or x86_64 kernel was configured with CONFIG_RANDOMIZE_BASE,",
+    "    If x86, x86_64 or s390x kernel was configured with CONFIG_RANDOMIZE_BASE,",
     "    the offset value is equal to the difference between the symbol values ",
     "    compiled into the vmlinux file and their relocated KASLR value.  If", 
     "    set to auto, the KASLR offset value will be automatically calculated.",
Index: b/main.c
===================================================================
--- a/main.c
+++ b/main.c
@@ -228,7 +228,8 @@ main(int argc, char **argv)
 				}
 			} else if (STREQ(long_options[option_index].name, "kaslr")) {
 				if (!machine_type("X86_64") &&
-				    !machine_type("ARM64") && !machine_type("X86"))
+				    !machine_type("ARM64") && !machine_type("X86") &&
+				    !machine_type("S390X"))
 					error(INFO, "--kaslr not valid "
 						"with this machine type.\n");
 				else if (STREQ(optarg, "auto"))
Index: b/symbols.c
===================================================================
--- a/symbols.c
+++ b/symbols.c
@@ -597,8 +597,8 @@ kaslr_init(void)
 {
 	char *string;
 
-	if ((!machine_type("X86_64") && !machine_type("ARM64") && !machine_type("X86")) ||
-	    (kt->flags & RELOC_SET))
+	if ((!machine_type("X86_64") && !machine_type("ARM64") && !machine_type("X86") &&
+	    !machine_type("S390X")) || (kt->flags & RELOC_SET))
 		return;
 
 	/*
@@ -737,7 +737,8 @@ store_symbols(bfd *abfd, int dynamic, vo
 					fromend, size, store);
 		} else if (!(kt->flags & RELOC_SET))
 			kt->flags |= RELOC_FORCE;
-	} else if (machine_type("X86_64") || machine_type("ARM64")) {
+	} else if (machine_type("X86_64") || machine_type("ARM64") ||
+		   machine_type("S390X")) {
 		if ((kt->flags2 & RELOC_AUTO) && !(kt->flags & RELOC_SET))
 			derive_kaslr_offset(abfd, dynamic, from,
 				fromend, size, store);
@@ -809,7 +810,7 @@ store_sysmap_symbols(void)
                         strerror(errno));
 
 	if (!machine_type("X86") && !machine_type("X86_64") &&
-	    !machine_type("ARM64"))
+	    !machine_type("ARM64") && !machine_type("S390X"))
 		kt->flags &= ~RELOC_SET;
 
 	first = 0;
openSUSE Build Service is sponsored by