-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b426b93
commit 0a181b5
Showing
52 changed files
with
16,777 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
TOOLCHAIN := $(OO_PS4_TOOLCHAIN) | ||
PROJDIR := $(shell basename $(CURDIR)) | ||
INTDIR := $(PROJDIR)/x64/Debug | ||
|
||
# Libraries linked into the ELF. | ||
LIBS := -lSceLibcInternal -lkernel | ||
|
||
# Compiler options. You likely won't need to touch these. | ||
UNAME_S := $(shell uname -s) | ||
ifeq ($(UNAME_S),Linux) | ||
CC := clang | ||
LD := ld.lld | ||
CDIR := linux | ||
endif | ||
ifeq ($(UNAME_S),Darwin) | ||
CC := /usr/local/opt/llvm/bin/clang | ||
LD := /usr/local/opt/llvm/bin/ld.lld | ||
CDIR := macos | ||
endif | ||
ODIR := $(INTDIR) | ||
SDIR := $(PROJDIR) | ||
IDIRS := -I$(TOOLCHAIN)/include | ||
LDIRS := -L$(TOOLCHAIN)/lib | ||
CFLAGS := -cc1 -triple x86_64-scei-ps4-elf -munwind-tables $(IDIRS) -emit-obj | ||
LFLAGS := -m elf_x86_64 -pie --script $(TOOLCHAIN)/link.x --eh-frame-hdr $(LDIRS) $(LIBS) $(TOOLCHAIN)/lib/crtlib.o | ||
|
||
CFILES := $(wildcard $(SDIR)/*.c) | ||
CPPFILES := $(wildcard $(SDIR)/*.cpp) | ||
OBJS := $(patsubst $(SDIR)/%.c, $(ODIR)/%.o, $(CFILES)) $(patsubst $(SDIR)/%.cpp, $(ODIR)/%.o, $(CPPFILES)) | ||
STUBOBJS := $(patsubst $(SDIR)/%.c, $(ODIR)/%.o.stub, $(CFILES)) $(patsubst $(SDIR)/%.cpp, $(ODIR)/%.o.stub, $(CPPFILES)) | ||
|
||
TARGET = libExample.prx | ||
TARGETSTUB = libExample_stub.so | ||
|
||
# Create the intermediate directory incase it doesn't already exist. | ||
_unused := $(shell mkdir -p $(INTDIR)) | ||
|
||
# Make rules | ||
$(TARGET): $(ODIR) $(OBJS) | ||
$(LD) $(ODIR)/*.o -o $(ODIR)/$(PROJDIR).elf $(LFLAGS) | ||
$(TOOLCHAIN)/bin/$(CDIR)/create-lib -in=$(ODIR)/$(PROJDIR).elf -out=$(ODIR)/$(PROJDIR).oelf --paid 0x3800000000000011 | ||
mv $(ODIR)/$(PROJDIR).prx $(TARGET) | ||
|
||
$(TARGETSTUB): $(ODIR) $(STUBOBJS) | ||
$(CC) $(ODIR)/*.o.stub -o $(TARGETSTUB) -target x86_64-pc-linux-gnu -shared -fuse-ld=lld -ffreestanding -nostdlib -fno-builtin $(LDIRS) $(LIBS) | ||
|
||
$(ODIR)/%.o: $(SDIR)/%.c | ||
$(CC) $(CFLAGS) -o $@ $< | ||
|
||
$(ODIR)/%.o: $(SDIR)/%.cpp | ||
$(CC) $(CFLAGS) -o $@ $< | ||
|
||
$(ODIR)/%.o.stub: $(SDIR)/%.c | ||
$(CC) -target x86_64-pc-linux-gnu -ffreestanding -nostdlib -fno-builtin -fPIC -c $(IDIRS) -o $@ $< | ||
|
||
$(ODIR)/%.o.stub: $(SDIR)/%.cpp | ||
$(CC) -target x86_64-pc-linux-gnu -ffreestanding -nostdlib -fno-builtin -fPIC -c $(IDIRS) -o $@ $< | ||
|
||
$(ODIR): | ||
@mkdir $@ | ||
|
||
.PHONY: clean | ||
.DEFAULT_GOAL := all | ||
|
||
all: $(TARGET) $(TARGETSTUB) | ||
|
||
clean: | ||
rm -f $(TARGET) $(ODIR)/*.o | ||
rm -f $(TARGET) $(ODIR)/*.o.stub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Sample: library_example | ||
|
||
[![Version](https://img.shields.io/badge/Version-1.00-brightgreen.svg)](https://github.com/Cryptogenic/OpenOrbis-PS4-Toolchain) | ||
|
||
This project contains example code for creating a library with a dummy function. It will generate an output .prx (Playstation Relocatable Executable) for the PS4, as well as a stub .so shared object file for linking on the PC side. | ||
|
||
|
||
|
||
## Directory structure | ||
``` | ||
samples/library_example | ||
|-- library_example | ||
|-- x64 | ||
|-- Debug // Object files / intermediate directory | ||
|-- build.bat // Batch file for building on Windows | ||
|-- library_example.vcxproj // Visual studio project files | ||
|-- library_example.vcxproj.filters | ||
|-- library_example.cvxproj.user | ||
|-- lib.cpp // library source file | ||
|-- libExample.h // library header file | ||
|-- libExample.prx // final library file (not present until built) | ||
|-- libExample_stub.so // final library stub (not present until built) | ||
|-- library_example.sln // Visual studio solution file | ||
|-- Makefile // Make rules for building on Linux | ||
``` | ||
The ELF, Orbis ELF (OELF), and object files will all be stored in the intermediate directory `x64/Debug`. The final library prx and stub files will be found in the root directory. | ||
|
||
|
||
|
||
## Libraries used | ||
|
||
- libc | ||
- libkernel | ||
|
||
|
||
|
||
## Building | ||
|
||
A visual studio project has been included for building on Windows. On Linux, a makefile has been included. | ||
|
||
To build this project, the developer will need clang, which is provided in the toolchain. The `OO_PS4_TOOLCHAIN` environment variable will also need to be set to the root directory of the SDK installation. | ||
|
||
__Windows__ | ||
Open the Visual Studio project and build, or run the batch file from command prompt or powershell with the following command: | ||
``` | ||
.\build.bat .\x64\Debug "library_example" "%OO_PS4_TOOLCHAIN%\\samples\\library_example" | ||
``` | ||
|
||
__Linux__ | ||
Run the makefile. | ||
``` | ||
make | ||
``` | ||
|
||
|
||
|
||
## Author(s) | ||
|
||
- Specter |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 15 | ||
VisualStudioVersion = 15.0.28010.2016 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "library_example", "library_example\library_example.vcxproj", "{D0553AC4-8657-45B1-BB8F-6898EFAA7F9F}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|x64 = Debug|x64 | ||
Release|x64 = Release|x64 | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{D0553AC4-8657-45B1-BB8F-6898EFAA7F9F}.Debug|x64.ActiveCfg = Debug|x64 | ||
{D0553AC4-8657-45B1-BB8F-6898EFAA7F9F}.Debug|x64.Build.0 = Debug|x64 | ||
{D0553AC4-8657-45B1-BB8F-6898EFAA7F9F}.Release|x64.ActiveCfg = Release|x64 | ||
{D0553AC4-8657-45B1-BB8F-6898EFAA7F9F}.Release|x64.Build.0 = Release|x64 | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {7D67734D-94A5-4D77-BE01-0EBDF5BAB354} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
SETLOCAL EnableDelayedExpansion | ||
|
||
Rem Libraries to link in | ||
set libraries=-lSceLibcInternal -lkernel | ||
|
||
Rem Read the script arguments into local vars | ||
set intdir=%1 | ||
set targetname=%~2 | ||
set outputPath=%~3 | ||
|
||
set outputElf=%intdir%\%targetname%.elf | ||
set outputOelf=%intdir%\%targetname%.oelf | ||
set outputPrx=%intdir%\%targetname%.prx | ||
set outputStub=%intdir%\%targetname%_stub.so | ||
|
||
@mkdir %intdir% | ||
|
||
Rem Compile object files for all the source files | ||
for %%f in (*.cpp) do ( | ||
clang++ -cc1 -triple x86_64-scei-ps4-elf -munwind-tables -I"%OO_PS4_TOOLCHAIN%\include" -emit-obj -o %intdir%\%%~nf.o %%~nf.cpp | ||
) | ||
|
||
Rem Get a list of object files for linking | ||
set obj_files= | ||
for %%f in (%intdir%\\*.o) do set obj_files=!obj_files! .\%%f | ||
|
||
Rem Link the input ELF | ||
ld.lld -m elf_x86_64 -pie --script "%OO_PS4_TOOLCHAIN%\link.x" --eh-frame-hdr -o "%outputElf%" "-L%OO_PS4_TOOLCHAIN%\lib" -lSceLibcInternal -lkernel --verbose "%OO_PS4_TOOLCHAIN%\lib\crtlib.o" %obj_files% | ||
|
||
Rem Create stub shared libraries | ||
for %%f in (*.cpp) do ( | ||
clang++ -target x86_64-pc-linux-gnu -ffreestanding -nostdlib -fno-builtin -fPIC -c -I"%OO_PS4_TOOLCHAIN%\include" -o %intdir%\%%~nf.o.stub %%~nf.cpp | ||
) | ||
|
||
set stub_obj_files= | ||
for %%f in (%intdir%\\*.o.stub) do set stub_obj_files=!stub_obj_files! .\%%f | ||
|
||
clang++ -target x86_64-pc-linux-gnu -shared -fuse-ld=lld -ffreestanding -nostdlib -fno-builtin "-L%OO_PS4_TOOLCHAIN%\lib" %libraries% %stub_obj_files% -o "%outputStub%" | ||
|
||
Rem Create the prx | ||
%OO_PS4_TOOLCHAIN%\bin\windows\create-lib.exe -in "%outputElf%" --out "%outputOelf%" | ||
|
||
Rem Cleanup | ||
copy "%outputPrx%" "%outputPath%\%targetname%.prx" | ||
del "%outputPrx%" |
78 changes: 78 additions & 0 deletions
78
Store-Loader/Jailbreak PRX/library_example/library_example.vcxproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<ItemGroup Label="ProjectConfigurations"> | ||
<ProjectConfiguration Include="Debug|x64"> | ||
<Configuration>Debug</Configuration> | ||
<Platform>x64</Platform> | ||
</ProjectConfiguration> | ||
<ProjectConfiguration Include="Release|x64"> | ||
<Configuration>Release</Configuration> | ||
<Platform>x64</Platform> | ||
</ProjectConfiguration> | ||
</ItemGroup> | ||
<PropertyGroup Label="Globals"> | ||
<VCProjectVersion>15.0</VCProjectVersion> | ||
<ProjectGuid>{d0553ac4-8657-45b1-bb8f-6898efaa7f9f}</ProjectGuid> | ||
<Keyword>Win32Proj</Keyword> | ||
<ProjectName>libExample</ProjectName> | ||
</PropertyGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> | ||
<ConfigurationType>Makefile</ConfigurationType> | ||
<UseDebugLibraries>true</UseDebugLibraries> | ||
<PlatformToolset>v141</PlatformToolset> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> | ||
<ConfigurationType>Makefile</ConfigurationType> | ||
<UseDebugLibraries>false</UseDebugLibraries> | ||
<PlatformToolset>v141</PlatformToolset> | ||
</PropertyGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> | ||
<ImportGroup Label="ExtensionSettings"> | ||
</ImportGroup> | ||
<ImportGroup Label="Shared"> | ||
</ImportGroup> | ||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
</ImportGroup> | ||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
</ImportGroup> | ||
<PropertyGroup Label="UserMacros" /> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||
<NMakePreprocessorDefinitions>WIN32;_DEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||
<NMakePreprocessorDefinitions>_DEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions> | ||
<NMakeBuildCommandLine>call build.bat $(IntDir) "$(TargetName)" "$(SolutionDir)"</NMakeBuildCommandLine> | ||
<NMakeReBuildCommandLine>del /s /q /f $(IntDir)\*.o | ||
del /s /q /f $(IntDir)\*.elf | ||
del /s /q /f $(IntDir)\*.oelf | ||
call build.bat $(IntDir) "$(TargetName)" "$(SolutionDir)"</NMakeReBuildCommandLine> | ||
<NMakeCleanCommandLine>del /s /q /f $(IntDir)\*.o | ||
del /s /q /f $(IntDir)\*.elf | ||
del /s /q /f $(IntDir)\*.oelf</NMakeCleanCommandLine> | ||
<OutDir>$(SolutionDir)</OutDir> | ||
<NMakeIncludeSearchPath>$(OO_PS4_TOOLCHAIN)\include;$(NMakeIncludeSearchPath)</NMakeIncludeSearchPath> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||
<NMakePreprocessorDefinitions>WIN32;NDEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||
<NMakePreprocessorDefinitions>NDEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions> | ||
</PropertyGroup> | ||
<ItemDefinitionGroup> | ||
</ItemDefinitionGroup> | ||
<ItemGroup> | ||
<ClCompile Include="lib.cpp" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClInclude Include="libExample.h" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="build.bat" /> | ||
</ItemGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | ||
<ImportGroup Label="ExtensionTargets"> | ||
</ImportGroup> | ||
</Project> |
30 changes: 30 additions & 0 deletions
30
Store-Loader/Jailbreak PRX/library_example/library_example.vcxproj.filters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<ItemGroup> | ||
<Filter Include="Source Files"> | ||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> | ||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions> | ||
</Filter> | ||
<Filter Include="Header Files"> | ||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> | ||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions> | ||
</Filter> | ||
<Filter Include="Resource Files"> | ||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier> | ||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions> | ||
</Filter> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClCompile Include="lib.cpp"> | ||
<Filter>Source Files</Filter> | ||
</ClCompile> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClInclude Include="libExample.h"> | ||
<Filter>Header Files</Filter> | ||
</ClInclude> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="build.bat" /> | ||
</ItemGroup> | ||
</Project> |
Oops, something went wrong.