scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

commit 3979c0fcf50f1ac9df42a871f8627b0fec59ef0d
parent ebb4a027004359227d10093ff1ef4e57e44d6250
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu, 19 Sep 2019 19:31:46 +0200

[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.

Diffstat:
Msrc/cmd/objdump.c | 23++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/src/cmd/objdump.c b/src/cmd/objdump.c @@ -25,10 +25,31 @@ error(char *fmt, ...) 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