shithub: scc

Download patch

ref: 3979c0fcf50f1ac9df42a871f8627b0fec59ef0d
parent: ebb4a027004359227d10093ff1ef4e57e44d6250
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Thu Sep 19 15:31:46 EDT 2019

[objdump] Ad a dummy version for as tests

This version is needed only to be able to run the as tests. At this moment
the assembler programs are generating raw files with the text segment data.
This version only dumps the full file in the format that is expected by the
as test shell scripts.

--- a/src/cmd/objdump.c
+++ b/src/cmd/objdump.c
@@ -25,10 +25,31 @@
 	status = EXIT_FAILURE;
 }
 
+/*
+ * TODO: Dummy implementation used only in the assembler tests
+ */
 static void
 dump(char *fname)
 {
-	/* TODO */
+	int c, n;
+	FILE *fp;
+
+	filename = fname;
+	if ((fp = fopen(fname, "rb")) == NULL) {
+		error("%s", strerror(errno));
+		return;
+	}
+
+	puts("data:");
+	for (n = 1; (c = getc(fp)) != EOF; n++)
+		printf("%02X%c", c, (n%16 == 0) ? '\n' : ' ');
+	if (n%16 != 0)
+		putchar('\n');
+
+	if (ferror(fp))
+		error("%s", strerror(errno));
+
+	fclose(fp);
 }
 
 static void