Blame SOURCES/ltrace-0.7.91-emachine-init.patch

92319b
Patch to ensure e_machine is properly initialized in some cases where
92319b
we attach to a running multi-threaded process.
92319b
92319b
diff -rup a/proc.c b/proc.c
92319b
--- a/proc.c	2019-02-28 17:32:50.020734842 -0500
92319b
+++ b/proc.c	2019-02-28 21:04:31.179942091 -0500
92319b
@@ -38,6 +38,7 @@
92319b
 #include "breakpoint.h"
92319b
 #include "debug.h"
92319b
 #include "fetch.h"
92319b
+#include "ltrace-elf.h"
92319b
 #include "options.h"
92319b
 #include "proc.h"
92319b
 #include "value_dict.h"
92319b
@@ -218,6 +219,21 @@ process_init(struct process *proc, const
92319b
 		return -1;
92319b
 	}
92319b
 
92319b
+	{
92319b
+	       struct ltelf lte;
92319b
+
92319b
+	       if (ltelf_init(&lte, filename) < 0) {
92319b
+		       process_bare_destroy(proc, 0);
92319b
+		       goto fail;
92319b
+	       }
92319b
+
92319b
+	       proc->e_machine = lte.ehdr.e_machine;
92319b
+	       proc->e_class = lte.ehdr.e_ident[EI_CLASS];
92319b
+	       get_arch_dep(proc);
92319b
+
92319b
+	       ltelf_destroy(<e;;
92319b
+       }
92319b
+
92319b
 	if (os_process_init(proc) < 0) {
92319b
 		process_bare_destroy(proc, 0);
92319b
 		goto fail;
92319b
diff -rup a/sysdeps/linux-gnu/x86/fetch.c b/sysdeps/linux-gnu/x86/fetch.c
92319b
--- a/sysdeps/linux-gnu/x86/fetch.c	2019-02-28 17:32:50.168810377 -0500
92319b
+++ b/sysdeps/linux-gnu/x86/fetch.c	2019-02-28 20:57:32.162800555 -0500
92319b
@@ -275,6 +275,9 @@ allocate_integer(struct fetch_context *c
92319b
 #undef HANDLE32
92319b
 		}
92319b
 
92319b
+		assert(!"Unknown machine architecture");
92319b
+		abort();
92319b
+
92319b
 	case POOL_RETVAL:
92319b
 		switch (context->ireg) {
92319b
 #ifdef __x86_64__