From f080c2c86245660b2233095b1318f465991b3174 Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Mon, 26 Dec 2016 11:03:06 -0500 Subject: [PATCH] makefile update, win32 fixes --- Makefile | 28 +++++++++++++++++++++------- dumpobj.cpp | 24 ++++++++++++++++++++---- 2 files changed, 41 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 399813a..f8a9da8 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,28 @@ -CC=c++ -std=c++11 -g -CXX=c++ -std=c++11 -g -OBJS = dumpobj.o disasm.o +LINK.o = $(LINK.cc) +CXXFLAGS = -std=c++11 -g +CCFLAGS = -g +CPPFLAGS = -I . + +UNAME_S := $(shell uname -s) +OBJS = dumpobj.o disassembler.o + +#ifeq ($(UNAME_S),MINGW64_NT-10.0) +ifeq ($(MSYSTEM),MINGW64) + OBJS += err.o +endif + +.PHONY: variables +variables : + $(foreach v, $(.VARIABLES), $(info $(v) = $($(v)))) + @echo + +dumpobj : $(OBJS) -dumpobj : dumpobj.o disassembler.o disassembler.o : disassembler.cpp disassembler.h dumpobj.o : dumpobj.cpp disassembler.h +err.o : err.c err.h -.PHONY: - clean - +.PHONY: clean clean: $(RM) dumpobj $(OBJS) \ No newline at end of file diff --git a/dumpobj.cpp b/dumpobj.cpp index ed259ce..d01d663 100644 --- a/dumpobj.cpp +++ b/dumpobj.cpp @@ -15,6 +15,10 @@ #include "obj816.h" #include "disassembler.h" +#ifndef O_BINARY +#define O_BINARY 0 +#endif + enum class endian { little = __ORDER_LITTLE_ENDIAN__, big = __ORDER_BIG_ENDIAN__, @@ -407,26 +411,38 @@ void dump_obj(const char *name, int fd) break; case D_C_FILE: { std::string s = read_cstring(iter); - uint16_t line = read_16(iter); - printf("\t.file\t\"%s\",%d\n", s.c_str(), line); + uint16_t line = read_16(iter); + i += 2; + i += s.length() + 1; + printf("\t.file\t\"%s\", %d\n", s.c_str(), line); break; } case D_C_LINE: { uint16_t line = read_16(iter); printf("\t.line\t%d\n", line); + i += 2; break; } case D_C_BLOCK: { uint16_t block = read_16(iter); printf("\t.block\t%d\n", block); + i += 2; break; } + case D_C_FUNC: { + uint16_t arg = read_16(iter); + printf("\t.function\t%d\n", arg); + i += 2; + break; + } + /* case D_C_SYM: { break; } + */ default: - errx(EX_DATAERR, "%s: unknown debug opcode %02x", name, op); + errx(EX_DATAERR, "%s: unknown debug opcode %02x (%d)", name, op, op); break; } @@ -619,7 +635,7 @@ void dump(const char *name) { int fd; ssize_t ok; - fd = open(name, O_RDONLY); + fd = open(name, O_RDONLY | O_BINARY); if (fd < 0) err(EX_NOINPUT, "Unable to open %s", name);