makefile update, win32 fixes

This commit is contained in:
Kelvin Sherlock 2016-12-26 11:03:06 -05:00
parent 6d965d5442
commit f080c2c862
2 changed files with 41 additions and 11 deletions

View File

@ -1,14 +1,28 @@
CC=c++ -std=c++11 -g LINK.o = $(LINK.cc)
CXX=c++ -std=c++11 -g CXXFLAGS = -std=c++11 -g
OBJS = dumpobj.o disasm.o 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 disassembler.o : disassembler.cpp disassembler.h
dumpobj.o : dumpobj.cpp disassembler.h dumpobj.o : dumpobj.cpp disassembler.h
err.o : err.c err.h
.PHONY: .PHONY: clean
clean
clean: clean:
$(RM) dumpobj $(OBJS) $(RM) dumpobj $(OBJS)

View File

@ -15,6 +15,10 @@
#include "obj816.h" #include "obj816.h"
#include "disassembler.h" #include "disassembler.h"
#ifndef O_BINARY
#define O_BINARY 0
#endif
enum class endian { enum class endian {
little = __ORDER_LITTLE_ENDIAN__, little = __ORDER_LITTLE_ENDIAN__,
big = __ORDER_BIG_ENDIAN__, big = __ORDER_BIG_ENDIAN__,
@ -407,26 +411,38 @@ void dump_obj(const char *name, int fd)
break; break;
case D_C_FILE: { case D_C_FILE: {
std::string s = read_cstring(iter); std::string s = read_cstring(iter);
uint16_t line = read_16(iter); uint16_t line = read_16(iter);
printf("\t.file\t\"%s\",%d\n", s.c_str(), line); i += 2;
i += s.length() + 1;
printf("\t.file\t\"%s\", %d\n", s.c_str(), line);
break; break;
} }
case D_C_LINE: { case D_C_LINE: {
uint16_t line = read_16(iter); uint16_t line = read_16(iter);
printf("\t.line\t%d\n", line); printf("\t.line\t%d\n", line);
i += 2;
break; break;
} }
case D_C_BLOCK: { case D_C_BLOCK: {
uint16_t block = read_16(iter); uint16_t block = read_16(iter);
printf("\t.block\t%d\n", block); printf("\t.block\t%d\n", block);
i += 2;
break; 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: { case D_C_SYM: {
break; break;
} }
*/
default: default:
errx(EX_DATAERR, "%s: unknown debug opcode %02x", name, op); errx(EX_DATAERR, "%s: unknown debug opcode %02x (%d)", name, op, op);
break; break;
} }
@ -619,7 +635,7 @@ void dump(const char *name) {
int fd; int fd;
ssize_t ok; 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); if (fd < 0) err(EX_NOINPUT, "Unable to open %s", name);