diff --git a/client/gen_resource_header.py b/client/gen_resource_header.py index 1d372ee1..7012b321 100644 --- a/client/gen_resource_header.py +++ b/client/gen_resource_header.py @@ -18,9 +18,20 @@ if __name__=="__main__": compressed = int(sys.argv[3]) - attribute = '\n'.join([ - '__attribute__(({}))'.format(x) for x in sys.argv[4:] - ]) + attribute = '' + pragma = '' + + if len(sys.argv) > 5: + compiler = sys.argv[4] + + if compiler == 'cl': + print "USING MSVC pragmas, const_seg: {}".format(sys.argv[5]) + attribute = '\n#pragma const_seg(push, stack1, "{}")\n'.format(sys.argv[5]) + pragma = '\n#pragma const_seg(pop, stack1)' + else: + attribute = '\n'.join([ + '__attribute__(({}))'.format(x) for x in sys.argv[5:] + ]) payload_len = len(file_bytes) payload = struct.pack('>I', payload_len) + ( @@ -42,6 +53,7 @@ if __name__=="__main__": h_file+="\n" h_file += "'\\x00' };\n" + h_file += pragma with open(sys.argv[2],'w') as w: w.write(h_file) diff --git a/client/sources-linux/Makefile b/client/sources-linux/Makefile index 18be95b5..f32d2322 100644 --- a/client/sources-linux/Makefile +++ b/client/sources-linux/Makefile @@ -14,7 +14,7 @@ LIBPYTHON ?= $(shell /sbin/ldconfig -p | awk '/libpython2.7.so/{print $$4}' | h LIBCRYPTO ?= $(shell /sbin/ldconfig -p | awk '/libcrypto.so.1.0.0/{print $$4}' | head -n 1) LIBSSL ?= $(shell /sbin/ldconfig -p | awk '/libssl.so.1.0.0/{print $$4}' | head -n 1) -XZARGS ?= "aligned(0x1000)" 'section(".xzrodata")' +XZARGS ?= "gcc" "aligned(0x1000)" 'section(".xzrodata")' ARCH ?= $(shell file $(LIBPYTHON) | grep 32-bit >/dev/null && echo 32 || echo 64) ifeq ($(ARCH),64) diff --git a/client/sources/Makefile b/client/sources/Makefile index 62f4d9e8..12efaac4 100644 --- a/client/sources/Makefile +++ b/client/sources/Makefile @@ -19,12 +19,14 @@ CFLAGS:=$(CFLAGS) /DWIN_X86 /nologo PPARCH := x86 endif -CFLAGS += /Iresources\\$(ARCH) /Iresources +CFLAGS += /Iresources\\$(ARCH) /Iresources /DHAVE_WINDOW +# CFLAGS += /Iresources\\$(ARCH) /Iresources ifdef DEBUG DEBUG_ADD := -debug CFLAGS := $(CFLAGS) /DDEBUG /DVERBOSE LINKER_OPTS := /link /NXCOMPAT:NO /subsystem:windows /ENTRY:WinMainCRTStartup user32.lib +# LINKER_OPTS := /link /NXCOMPAT:NO /subsystem:console PPARCH := $(PPARCH)d else DEBUG_ADD := @@ -33,6 +35,8 @@ PPARCH := $(PPARCH) CFLAGS := $(CFLAGS) /O1 /GL /GS- endif +SECARGS := "cl" ".xzdata" + CFLAGS := $(CFLAGS) /I..\\lzma PYOBJS := \ @@ -78,13 +82,13 @@ resources/$(ARCH)/library.zip: ../build_library_zip.py $(PYTHON) ../build_library_zip.py $@ resources/$(ARCH)/library.c: ../gen_resource_header.py resources/$(ARCH)/library.txt resources/$(ARCH)/library.zip - $(HOST_PYTHON) ../gen_resource_header.py resources/$(ARCH)/library.txt $@ $(COMPRESSED) + $(HOST_PYTHON) ../gen_resource_header.py resources/$(ARCH)/library.txt $@ $(COMPRESSED) $(SECARGS) resources/bootloader.pyc: ../../pupy/packages/all/pupyimporter.py ../../pupy/pp.py ../gen_python_bootloader.py $(PYTHON) ../gen_python_bootloader.py $(DEBUG_ADD) resources/bootloader.c: resources/bootloader.pyc ../gen_resource_header.py - $(HOST_PYTHON) ../gen_resource_header.py $< $@ $(COMPRESSED) + $(HOST_PYTHON) ../gen_resource_header.py $< $@ $(COMPRESSED) $(SECARGS) resources/$(ARCH)/python27.dll: $(BUILDENV)/$(ARCH)/drive_c/Python27/python27.dll @mkdir -p resources/$(ARCH) @@ -95,10 +99,10 @@ resources/$(ARCH)/msvcr90.dll: $(BUILDENV)/$(ARCH)/drive_c/Python27/msvcr90.dll cp $< $@ resources/$(ARCH)/python27.c: resources/$(ARCH)/python27.dll ../gen_resource_header.py - $(HOST_PYTHON) ../gen_resource_header.py $< $@ $(COMPRESSED) + $(HOST_PYTHON) ../gen_resource_header.py $< $@ $(COMPRESSED) $(SECARGS) resources/$(ARCH)/msvcr90.c: resources/$(ARCH)/msvcr90.dll ../gen_resource_header.py - $(HOST_PYTHON) ../gen_resource_header.py $< $@ $(COMPRESSED) + $(HOST_PYTHON) ../gen_resource_header.py $< $@ $(COMPRESSED) $(SECARGS) $(PYOBJS): %.obj: %.c $(CC) /c $(CFLAGS) /I$(PYTHONPATH)\\include $<