From 46227e6763e29dd38f4e13a47018a60b7d86d5d9 Mon Sep 17 00:00:00 2001 From: TuxSH Date: Mon, 29 Aug 2016 17:51:03 +0200 Subject: [PATCH] Fix build issues on some environments. --- injector/Makefile | 7 ++++++- injector/source/CFWInfo.h | 19 +++++++++++++++++++ injector/source/CFWInfo.s | 9 +++++++++ injector/source/patcher.c | 6 +----- injector/source/patcher.h | 14 -------------- 5 files changed, 35 insertions(+), 20 deletions(-) create mode 100644 injector/source/CFWInfo.h create mode 100644 injector/source/CFWInfo.s diff --git a/injector/Makefile b/injector/Makefile index d568a73..1e96f56 100755 --- a/injector/Makefile +++ b/injector/Makefile @@ -28,7 +28,7 @@ CFLAGS := -Wall -Wextra -MMD -MP -marm $(ARCH) -fno-builtin -std=c11 -O2 -flto - LDFLAGS := -Xlinker --defsym="__start__=0x14000000" -specs=3dsx.specs $(ARCH) objects = $(patsubst $(dir_source)/%.c, $(dir_build)/%.o, \ - $(call rwildcard, $(dir_source), *.c)) + $(call rwildcard, $(dir_source), *.s *.c)) .PHONY: all all: ../$(dir_build)/$(name).cxi @@ -48,4 +48,9 @@ $(dir_build)/memory.o : CFLAGS += -O3 $(dir_build)/%.o: $(dir_source)/%.c @mkdir -p "$(@D)" $(COMPILE.c) $(OUTPUT_OPTION) $< + +$(dir_build)/%.o: $(dir_source)/%.s + @mkdir -p "$(@D)" + $(COMPILE.c) $(OUTPUT_OPTION) $< + include $(call rwildcard, $(dir_build), *.d) diff --git a/injector/source/CFWInfo.h b/injector/source/CFWInfo.h new file mode 100644 index 0000000..0e9d63f --- /dev/null +++ b/injector/source/CFWInfo.h @@ -0,0 +1,19 @@ +#pragma once + +#include <3ds.h> + +typedef struct __attribute__((packed)) +{ + char magic[4]; + + u8 versionMajor; + u8 versionMinor; + u8 versionBuild; + u8 flags; /* bit 0: dev branch; bit 1: is release */ + + u32 commitHash; + + u32 config; +} CFWInfo; + +int svcGetCFWInfo(CFWInfo *info); \ No newline at end of file diff --git a/injector/source/CFWInfo.s b/injector/source/CFWInfo.s new file mode 100644 index 0000000..8337620 --- /dev/null +++ b/injector/source/CFWInfo.s @@ -0,0 +1,9 @@ +.text +.arm +.align 4 + +.global svcGetCFWInfo +.type svcGetCFWInfo, %function +svcGetCFWInfo: + svc 0x2e + bx lr diff --git a/injector/source/patcher.c b/injector/source/patcher.c index 362230d..3e8af05 100644 --- a/injector/source/patcher.c +++ b/injector/source/patcher.c @@ -2,6 +2,7 @@ #include "memory.h" #include "patcher.h" #include "ifile.h" +#include "CFWInfo.h" static CFWInfo info; @@ -85,11 +86,6 @@ static int fileOpen(IFile *file, FS_ArchiveID archiveId, const char *path, int f return IFile_Open(file, archiveId, archivePath, filePath, flags); } -int __attribute__((naked)) svcGetCFWInfo(CFWInfo __attribute__((unused)) *out) -{ - __asm__ volatile("svc 0x2E; bx lr"); -} - static void loadCFWInfo(void) { static bool infoLoaded = false; diff --git a/injector/source/patcher.h b/injector/source/patcher.h index ea3ea5e..e67e9e6 100644 --- a/injector/source/patcher.h +++ b/injector/source/patcher.h @@ -8,18 +8,4 @@ #define MULTICONFIG(a) ((info.config >> (a * 2 + 6)) & 3) #define BOOTCONFIG(a, b) ((info.config >> a) & b) -typedef struct __attribute__((packed)) -{ - char magic[4]; - - u8 versionMajor; - u8 versionMinor; - u8 versionBuild; - u8 flags; /* bit 0: dev branch; bit 1: is release */ - - u32 commitHash; - - u32 config; -} CFWInfo; - void patchCode(u64 progId, u8 *code, u32 size); \ No newline at end of file