scc

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

commit 687d599c2efa92c1d8347d610be102fcb9a97c18
parent db020ae096075a5800c8179979ed45c33cb718ad
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