Add build options to Makefile
For stuff like testing PASLR, *hax2x, khc3ds, etc. Also fix a corner-case bug when changing the 3dsx app from itself to itself, if its TID corresponds to the default.
This commit is contained in:
parent
da0b1a1389
commit
5cdbfab54b
13
Makefile
13
Makefile
@ -2,6 +2,19 @@ ifneq ($(strip $(shell firmtool -v 2>&1 | grep usage)),)
|
||||
$(error "Please install firmtool v1.1 or greater")
|
||||
endif
|
||||
|
||||
# Disable kext and firmlaunch patches, all custom sysmodules except Loader, enable PASLR.
|
||||
# Dangerous. Don't enable this unless you know what you're doing!
|
||||
export BUILD_FOR_EXPLOIT_DEV ?= 0
|
||||
|
||||
# Build with O0 & frame pointer information for use with GDB
|
||||
export BUILD_FOR_GDB ?= 0
|
||||
|
||||
# Default 3DSX TitleID for hb:ldr
|
||||
export HBLDR_DEFAULT_3DSX_TID ?= 000400000D921E00
|
||||
|
||||
# What to call the title corresponding to HBLDR_DEFAULT_3DSX_TID
|
||||
export HBLDR_DEFAULT_3DSX_TITLE_NAME ?= "hblauncher_loader"
|
||||
|
||||
NAME := $(notdir $(CURDIR))
|
||||
REVISION := $(shell git describe --tags --match v[0-9]* --abbrev=8 | sed 's/-[0-9]*-g/-/')
|
||||
|
||||
|
@ -26,7 +26,7 @@ INCLUDES := include include/svc
|
||||
# options for code generation
|
||||
#---------------------------------------------------------------------------------
|
||||
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
|
||||
DEFINES := -DARM11 -D_3DS
|
||||
DEFINES := -DARM11 -D__3DS__
|
||||
|
||||
CFLAGS := -g -std=gnu11 -Wall -Wextra -Werror -O2 -mword-relocations \
|
||||
-fomit-frame-pointer -ffunction-sections -fdata-sections \
|
||||
|
@ -35,6 +35,9 @@ ifeq ($(strip $(shell git describe --tags --match v[0-9]* | grep -)),)
|
||||
export IS_RELEASE := 1
|
||||
endif
|
||||
|
||||
# Default 3DSX TitleID for hb:ldr (note: also defined in top-level Makefile)
|
||||
export HBLDR_DEFAULT_3DSX_TID ?= 000400000D921E00
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# TARGET is the name of the output
|
||||
# BUILD is the directory where object files & intermediate files will be placed
|
||||
@ -53,7 +56,12 @@ INCLUDES := include
|
||||
# options for code generation
|
||||
#---------------------------------------------------------------------------------
|
||||
ARCH := -marm -march=armv5te -mtune=arm946e-s
|
||||
DEFINES := -DARM9 -D_3DS
|
||||
|
||||
ifeq ($(BUILD_FOR_EXPLOIT_DEV),1)
|
||||
DEFINES := -DARM9 -D__3DS__ -DHBLDR_DEFAULT_3DSX_TID="0x$(HBLDR_DEFAULT_3DSX_TID)ULL" -DBUILD_FOR_EXPLOIT_DEV=1
|
||||
else
|
||||
DEFINES := -DARM9 -D__3DS__ -DHBLDR_DEFAULT_3DSX_TID="0x$(HBLDR_DEFAULT_3DSX_TID)ULL"
|
||||
endif
|
||||
|
||||
FALSEPOSITIVES := -Wno-array-bounds -Wno-stringop-overflow -Wno-stringop-overread
|
||||
CFLAGS := -g -std=gnu11 -Wall -Wextra -Werror -O2 -mword-relocations \
|
||||
|
@ -28,7 +28,6 @@
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#define HBLDR_DEFAULT_3DSX_TID 0x000400000D921E00ull
|
||||
#define AUTOBOOT_DEFAULT_TWL_TID 0x0003000448424C41ull
|
||||
|
||||
#define CONFIG(a) (((configData.config >> (a)) & 1) != 0)
|
||||
|
@ -352,8 +352,7 @@ static inline void mergeSection0(FirmwareType firmType, u32 firmVersion, bool lo
|
||||
|
||||
u32 patchNativeFirm(u32 firmVersion, FirmwareSource nandType, bool loadFromStorage, bool isFirmProtEnabled, bool needToInitSd, bool doUnitinfoPatch)
|
||||
{
|
||||
u8 *arm9Section = (u8 *)firm + firm->section[2].offset,
|
||||
*arm11Section1 = (u8 *)firm + firm->section[1].offset;
|
||||
u8 *arm9Section = (u8 *)firm + firm->section[2].offset;
|
||||
|
||||
if(ISN3DS)
|
||||
{
|
||||
@ -367,22 +366,27 @@ u32 patchNativeFirm(u32 firmVersion, FirmwareSource nandType, bool loadFromStora
|
||||
process9MemAddr;
|
||||
u8 *process9Offset = getProcess9Info(arm9Section, firm->section[2].size, &process9Size, &process9MemAddr);
|
||||
|
||||
u32 kernel9Size = (u32)(process9Offset - arm9Section) - sizeof(Cxi) - 0x200,
|
||||
ret = 0;
|
||||
|
||||
#ifndef BUILD_FOR_EXPLOIT_DEV
|
||||
//Skip on FIRMs < 4.0
|
||||
if(ISN3DS || firmVersion >= 0x1D)
|
||||
{
|
||||
//Find the Kernel11 SVC table and handler, exceptions page and free space locations
|
||||
u8 *arm11Section1 = (u8 *)firm + firm->section[1].offset;
|
||||
u32 baseK11VA;
|
||||
u8 *freeK11Space;
|
||||
u32 *arm11SvcHandler,
|
||||
*arm11ExceptionsPage,
|
||||
*arm11SvcTable = getKernel11Info(arm11Section1, firm->section[1].size, &baseK11VA, &freeK11Space, &arm11SvcHandler, &arm11ExceptionsPage);
|
||||
|
||||
u32 kernel9Size = (u32)(process9Offset - arm9Section) - sizeof(Cxi) - 0x200,
|
||||
ret = 0;
|
||||
|
||||
//Skip on FIRMs < 4.0
|
||||
if(ISN3DS || firmVersion >= 0x1D)
|
||||
{
|
||||
ret += installK11Extension(arm11Section1, firm->section[1].size, needToInitSd, baseK11VA, arm11ExceptionsPage, &freeK11Space);
|
||||
ret += patchKernel11(arm11Section1, firm->section[1].size, baseK11VA, arm11SvcTable, arm11ExceptionsPage);
|
||||
}
|
||||
#else
|
||||
(void)needToInitSd;
|
||||
#endif
|
||||
|
||||
//Apply signature patches
|
||||
ret += patchSignatureChecks(process9Offset, process9Size);
|
||||
@ -393,8 +397,10 @@ u32 patchNativeFirm(u32 firmVersion, FirmwareSource nandType, bool loadFromStora
|
||||
//Apply FIRM0/1 writes patches on SysNAND to protect A9LH
|
||||
else if(isFirmProtEnabled) ret += patchFirmWrites(process9Offset, process9Size);
|
||||
|
||||
#ifndef BUILD_FOR_EXPLOIT_DEV
|
||||
//Apply firmlaunch patches
|
||||
ret += patchFirmlaunches(process9Offset, process9Size, process9MemAddr);
|
||||
#endif
|
||||
|
||||
//Apply dev unit check patches related to NCCH encryption
|
||||
if(!ISDEVUNIT)
|
||||
|
@ -27,7 +27,7 @@ INCLUDES := include include/svc
|
||||
#---------------------------------------------------------------------------------
|
||||
# -mgeneral-regs-only so that the C code is guaranteed not to use FPU regs
|
||||
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft -mgeneral-regs-only
|
||||
DEFINES := -DARM11 -D_3DS
|
||||
DEFINES := -DARM11 -D__3DS__
|
||||
|
||||
FALSEPOSITIVES := -Wno-array-bounds -Wno-stringop-overflow -Wno-stringop-overread
|
||||
CFLAGS := -g -std=gnu11 -Wall -Wextra -Werror -O2 -mword-relocations \
|
||||
|
@ -1,4 +1,10 @@
|
||||
SUBFOLDERS := loader sm pm pxi rosalina
|
||||
ifeq ($(BUILD_FOR_EXPLOIT_DEV),1)
|
||||
# Keep Loader so that we can execute 3DSX
|
||||
SUBFOLDERS := loader
|
||||
else
|
||||
SUBFOLDERS := loader sm pm pxi rosalina
|
||||
endif
|
||||
|
||||
CXIS := $(foreach dir, $(SUBFOLDERS), $(dir)/$(dir).cxi)
|
||||
|
||||
.PHONY: all clean $(SUBFOLDERS)
|
||||
|
@ -9,6 +9,9 @@ endif
|
||||
TOPDIR ?= $(CURDIR)
|
||||
include $(DEVKITARM)/3ds_rules
|
||||
|
||||
# Default 3DSX TitleID for hb:ldr (note: also defined in top-level Makefile)
|
||||
export HBLDR_DEFAULT_3DSX_TID ?= 000400000D921E00
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# TARGET is the name of the output
|
||||
# BUILD is the directory where object files & intermediate files will be placed
|
||||
@ -26,11 +29,33 @@ INCLUDES := include
|
||||
# options for code generation
|
||||
#---------------------------------------------------------------------------------
|
||||
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
|
||||
DEFINES := -D__3DS__
|
||||
|
||||
COMMON_FLAGS = -g -Wall -Wextra -Werror -O2 -mword-relocations \
|
||||
-fomit-frame-pointer -ffunction-sections -fdata-sections \
|
||||
$(ARCH) $(DEFINES) $(INCLUDE)
|
||||
ifeq ($(BUILD_FOR_EXPLOIT_DEV),1)
|
||||
DEFINES := -D__3DS__ -DHBLDR_DEFAULT_3DSX_TID="0x$(HBLDR_DEFAULT_3DSX_TID)ULL" -DBUILD_FOR_EXPLOIT_DEV=1
|
||||
else
|
||||
DEFINES := -D__3DS__ -DHBLDR_DEFAULT_3DSX_TID="0x$(HBLDR_DEFAULT_3DSX_TID)ULL"
|
||||
endif
|
||||
|
||||
ifeq ($(BUILD_FOR_GDB),1)
|
||||
OPTFLAGS := -O0
|
||||
LIBS := -lctrud
|
||||
else
|
||||
OPTFLAGS := -O2 -fomit-frame-pointer
|
||||
LIBS := -lctru
|
||||
endif
|
||||
|
||||
COMMON_FLAGS =\
|
||||
-g \
|
||||
-Wall \
|
||||
-Wextra \
|
||||
-Werror \
|
||||
-mword-relocations \
|
||||
-ffunction-sections \
|
||||
-fdata-sections \
|
||||
$(OPTFLAGS) \
|
||||
$(ARCH) \
|
||||
$(DEFINES) \
|
||||
$(INCLUDE)
|
||||
|
||||
CFLAGS := -std=gnu11 $(COMMON_FLAGS)
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
#include "ifile.h"
|
||||
#include "util.h"
|
||||
#include "hbldr.h"
|
||||
#include "luma_shared_config.h"
|
||||
|
||||
extern u32 config, multiConfig, bootConfig;
|
||||
extern bool isN3DS, isSdMode;
|
||||
|
@ -18,9 +18,6 @@
|
||||
|
||||
#include <3ds/types.h>
|
||||
|
||||
/// Default TitleID for 3DSX loading
|
||||
#define HBLDR_DEFAULT_3DSX_TID 0x000400000D921E00ULL
|
||||
|
||||
/// Luma shared config type.
|
||||
typedef struct LumaSharedConfig {
|
||||
u64 hbldr_3dsx_tid; ///< Title ID to use for 3DSX loading.
|
||||
|
@ -47,7 +47,7 @@ static bool needsPaslr(u32 *outRegion, const ExHeader_Info *exhi)
|
||||
|
||||
*outRegion = region;
|
||||
|
||||
#ifdef LOADER_ENABLE_PASLR
|
||||
#if defined(LOADER_ENABLE_PASLR) || defined(BUILD_FOR_EXPLOIT_DEV)
|
||||
// Only applications and system applets (HM, Internet Browser...) are eligible for PASLR
|
||||
if (region != MEMOP_REGION_APP && region != MEMOP_REGION_SYSTEM)
|
||||
return false;
|
||||
|
@ -28,19 +28,33 @@ INCLUDES := include
|
||||
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
|
||||
DEFINES := -D__3DS__
|
||||
|
||||
CFLAGS := -g -std=gnu11 -Wall -Wextra -Werror -Os -mword-relocations \
|
||||
-fomit-frame-pointer -ffunction-sections -fdata-sections \
|
||||
$(ARCH) $(DEFINES)
|
||||
ifeq ($(BUILD_FOR_GDB),1)
|
||||
OPTFLAGS := -O0
|
||||
LIBS := -lctrud
|
||||
else
|
||||
OPTFLAGS := -O2 -fomit-frame-pointer
|
||||
LIBS := -lctru
|
||||
endif
|
||||
|
||||
CFLAGS += $(INCLUDE)
|
||||
CFLAGS :=\
|
||||
-g \
|
||||
-std=gnu11 \
|
||||
-Wall \
|
||||
-Wextra \
|
||||
-Werror \
|
||||
-mword-relocations \
|
||||
-ffunction-sections \
|
||||
-fdata-sections \
|
||||
$(OPTFLAGS) \
|
||||
$(ARCH) \
|
||||
$(DEFINES) \
|
||||
$(INCLUDE)
|
||||
|
||||
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
|
||||
|
||||
ASFLAGS := -g $(ARCH)
|
||||
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map),-wrap,exit
|
||||
|
||||
LIBS := -lctru
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
|
@ -28,9 +28,27 @@ INCLUDES := include
|
||||
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
|
||||
DEFINES := -D__3DS__
|
||||
|
||||
CFLAGS := -g -std=gnu11 -Wall -Wextra -Werror -O2 -mword-relocations \
|
||||
-fomit-frame-pointer -ffunction-sections -fdata-sections \
|
||||
$(ARCH) $(DEFINES)
|
||||
ifeq ($(BUILD_FOR_GDB),1)
|
||||
OPTFLAGS := -O0
|
||||
LIBS := -lctrud
|
||||
else
|
||||
OPTFLAGS := -O2 -fomit-frame-pointer
|
||||
LIBS := -lctru
|
||||
endif
|
||||
|
||||
CFLAGS :=\
|
||||
-g \
|
||||
-std=gnu11 \
|
||||
-Wall \
|
||||
-Wextra \
|
||||
-Werror \
|
||||
-mword-relocations \
|
||||
-ffunction-sections \
|
||||
-fdata-sections \
|
||||
$(OPTFLAGS) \
|
||||
$(ARCH) \
|
||||
$(DEFINES) \
|
||||
$(INCLUDE)
|
||||
|
||||
CFLAGS += $(INCLUDE)
|
||||
|
||||
@ -39,8 +57,6 @@ CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
|
||||
ASFLAGS := -g $(ARCH)
|
||||
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map),-wrap,exit
|
||||
|
||||
LIBS := -lctru
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
|
@ -9,6 +9,12 @@ endif
|
||||
TOPDIR ?= $(CURDIR)
|
||||
include $(DEVKITARM)/3ds_rules
|
||||
|
||||
# Default 3DSX TitleID for hb:ldr (note: also defined in top-level Makefile)
|
||||
export HBLDR_DEFAULT_3DSX_TID ?= 000400000D921E00
|
||||
|
||||
# What to call the title corresponding to HBLDR_DEFAULT_3DSX_TID (note: also defined in top-level Makefile)
|
||||
export HBLDR_DEFAULT_3DSX_TITLE_NAME ?= "hblauncher_loader"
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# TARGET is the name of the output
|
||||
# BUILD is the directory where object files & intermediate files will be placed
|
||||
@ -26,7 +32,7 @@ INCLUDES := include include/gdb include/menus include/redshift
|
||||
# options for code generation
|
||||
#---------------------------------------------------------------------------------
|
||||
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
|
||||
DEFINES := -D__3DS__
|
||||
DEFINES := -D__3DS__ -DHBLDR_DEFAULT_3DSX_TID="0x$(HBLDR_DEFAULT_3DSX_TID)ULL" -DHBLDR_DEFAULT_3DSX_TITLE_NAME="\"$(HBLDR_DEFAULT_3DSX_TITLE_NAME)\""
|
||||
|
||||
FALSEPOSITIVES := -Wno-array-bounds -Wno-stringop-overflow -Wno-stringop-overread
|
||||
CFLAGS := -g -std=gnu11 -Wall -Wextra -Werror -Wno-unused-value -Os -mword-relocations \
|
||||
|
@ -18,9 +18,6 @@
|
||||
|
||||
#include <3ds/types.h>
|
||||
|
||||
/// Default TitleID for 3DSX loading
|
||||
#define HBLDR_DEFAULT_3DSX_TID 0x000400000D921E00ULL
|
||||
|
||||
/// Luma shared config type.
|
||||
typedef struct LumaSharedConfig {
|
||||
u64 hbldr_3dsx_tid; ///< Title ID to use for 3DSX loading.
|
||||
|
@ -120,12 +120,20 @@ Menu miscellaneousMenu = {
|
||||
};
|
||||
int lastNtpTzOffset = 0;
|
||||
|
||||
static inline bool compareTids(u64 tidA, u64 tidB)
|
||||
{
|
||||
// Just like p9 clears them, ignore platform/N3DS bits
|
||||
return ((tidA ^ tidB) & ~0xF0000000ull) == 0;
|
||||
}
|
||||
|
||||
void MiscellaneousMenu_SwitchBoot3dsxTargetTitle(void)
|
||||
{
|
||||
Result res;
|
||||
char failureReason[64];
|
||||
u64 currentTid = Luma_SharedConfig->hbldr_3dsx_tid;
|
||||
u64 newTid = currentTid;
|
||||
|
||||
if(Luma_SharedConfig->hbldr_3dsx_tid == HBLDR_DEFAULT_3DSX_TID)
|
||||
if(compareTids(currentTid, HBLDR_DEFAULT_3DSX_TID))
|
||||
{
|
||||
FS_ProgramInfo progInfo;
|
||||
u32 pid;
|
||||
@ -133,8 +141,8 @@ void MiscellaneousMenu_SwitchBoot3dsxTargetTitle(void)
|
||||
res = PMDBG_GetCurrentAppInfo(&progInfo, &pid, &launchFlags);
|
||||
if(R_SUCCEEDED(res))
|
||||
{
|
||||
newTid = progInfo.programId;
|
||||
Luma_SharedConfig->hbldr_3dsx_tid = progInfo.programId;
|
||||
miscellaneousMenu.items[0].title = "Switch the hb. title to hblauncher_loader";
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -145,10 +153,15 @@ void MiscellaneousMenu_SwitchBoot3dsxTargetTitle(void)
|
||||
else
|
||||
{
|
||||
res = 0;
|
||||
Luma_SharedConfig->hbldr_3dsx_tid = HBLDR_DEFAULT_3DSX_TID;
|
||||
miscellaneousMenu.items[0].title = "Switch the hb. title to the current app.";
|
||||
newTid = HBLDR_DEFAULT_3DSX_TID;
|
||||
}
|
||||
|
||||
Luma_SharedConfig->hbldr_3dsx_tid = newTid;
|
||||
if (compareTids(newTid, HBLDR_DEFAULT_3DSX_TID))
|
||||
miscellaneousMenu.items[0].title = "Switch the hb. title to the current app.";
|
||||
else
|
||||
miscellaneousMenu.items[0].title = "Switch the hb. title to " HBLDR_DEFAULT_3DSX_TITLE_NAME;
|
||||
|
||||
Draw_Lock();
|
||||
Draw_ClearFramebuffer();
|
||||
Draw_FlushFramebuffer();
|
||||
|
@ -28,9 +28,27 @@ INCLUDES := include
|
||||
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
|
||||
DEFINES := -D__3DS__
|
||||
|
||||
CFLAGS := -g -std=gnu11 -Wall -Wextra -Werror -Os -mword-relocations \
|
||||
-fomit-frame-pointer -ffunction-sections -fdata-sections \
|
||||
$(ARCH) $(DEFINES)
|
||||
ifeq ($(BUILD_FOR_GDB),1)
|
||||
OPTFLAGS := -O0
|
||||
LIBS := -lctrud
|
||||
else
|
||||
OPTFLAGS := -O2 -fomit-frame-pointer
|
||||
LIBS := -lctru
|
||||
endif
|
||||
|
||||
CFLAGS :=\
|
||||
-g \
|
||||
-std=gnu11 \
|
||||
-Wall \
|
||||
-Wextra \
|
||||
-Werror \
|
||||
-mword-relocations \
|
||||
-ffunction-sections \
|
||||
-fdata-sections \
|
||||
$(OPTFLAGS) \
|
||||
$(ARCH) \
|
||||
$(DEFINES) \
|
||||
$(INCLUDE)
|
||||
|
||||
CFLAGS += $(INCLUDE)
|
||||
|
||||
@ -39,8 +57,6 @@ CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
|
||||
ASFLAGS := -g $(ARCH)
|
||||
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map),-wrap,exit
|
||||
|
||||
LIBS := -lctru
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
|
Loading…
x
Reference in New Issue
Block a user