Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dsce with a makefile #2

Draft
wants to merge 22 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
BasedOnStyle: Google
IndentWidth: 4
ColumnLimit: 140
DerivePointerAlignment: false
PointerAlignment: Left
ExperimentalAutoDetectBinPacking: true
SpaceBeforeCpp11BracedList: true
---
Language: ObjC
# Force pointers to the type for C++.
AlignArrayOfStructures: None
SpacesInContainerLiterals: false
BreakStringLiterals: false
ObjCBreakBeforeNestedBlockParam: false
ObjCBlockIndentWidth: 4
16 changes: 16 additions & 0 deletions .clangd
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
CompileFlags:
Add:
[
-fmodules,
-fcxx-modules,
-Wno-unused-getter-return-value,
-mmacosx-version-min=12,
-I..,
-I../dyld/common,
-DDSCE_VERSION=6,
]
---
If:
PathMatch: [.*\.cpp, .*\.hpp, .*\.mm]
CompileFlags:
Add: [-std=c++17]
16 changes: 16 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Build

on:
push:
pull_request:
workflow_dispatch:

jobs:
format:
name: Build
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- run: make
63 changes: 63 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Check code style

on:
push:
pull_request:
workflow_dispatch:

env:
LLVM_VERSION: 16

jobs:
format:
name: Check code style
runs-on: ubuntu-latest
steps:
# We do not want to check submodules
- uses: actions/checkout@v3

- name: Set permissions
run: sudo chmod -R a+rwx /var/cache/apt/archives /etc/apt/keyrings /etc/apt/sources.list.d

- name: Get codename
run: |
source /etc/os-release
echo "UBUNTU_CODENAME=${UBUNTU_CODENAME}" >> $GITHUB_ENV

- name: Restore cache
uses: actions/cache@v3
id: cache
with:
key: ${{ env.UBUNTU_CODENAME }}-apt-${{ env.LLVM_VERSION }}
path: |
/var/cache/apt/archives/**.deb
!/var/cache/apt/archives/partial
!/var/cache/apt/archives/lock
/etc/apt/keyrings/apt.llvm.org.asc
/etc/apt/sources.list.d/llvm.list

- name: Add LLVM repo
if: steps.cache.outputs.cache-hit != 'true'
run: |
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/keyrings/apt.llvm.org.asc
echo "deb [signed-by=/etc/apt/keyrings/apt.llvm.org.asc] http://apt.llvm.org/${{ env.UBUNTU_CODENAME }}/ llvm-toolchain-${{ env.UBUNTU_CODENAME }}-${{ env.LLVM_VERSION}} main" | sudo tee /etc/apt/sources.list.d/llvm.list

- uses: cpp-linter/cpp-linter-action@v2
id: linter
with:
style: file
extensions: 'c,h,m,C,H,cpp,mm,hpp,cc,hh,c++,h++,cxx,hxx'
tidy-checks: '-*'
version: ${{ env.LLVM_VERSION }}
files-changed-only: ${{ github.event_name == 'pull_request' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Check for lint failure
if: steps.linter.outputs.checks-failed > 0 && false
run: |
echo "::error::Code style check failed."
exit 1

- name: Set permissions
run: sudo chmod -R a+rwx /var/cache/apt/archives /etc/apt/keyrings /etc/apt/sources.list.d
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "dyld"]
path = dyld
url = https://github.com/apple-oss-distributions/dyld.git
[submodule "objc4"]
path = objc4
url = https://github.com/apple-oss-distributions/objc4.git
2 changes: 2 additions & 0 deletions Address.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import Foundation;

Check notice on line 1 in Address.h

View workflow job for this annotation

GitHub Actions / Check code style

Run clang-format on Address.h

File Address.h does not conform to Custom style guidelines. (lines 8, 18, 19, 20, 21, 23, 24, 25, 26)

Check notice on line 1 in Address.h

View workflow job for this annotation

GitHub Actions / Check code style

Run clang-format on Address.h

File Address.h does not conform to Custom style guidelines. (lines 8, 18, 19, 20, 21, 23, 24, 25, 26)

#define ADDRESS_REBASE 1
#define ADDRESS_BIND 2
#define ADDRESS_EXPORT 3
Expand Down
61 changes: 0 additions & 61 deletions Address.m

This file was deleted.

55 changes: 55 additions & 0 deletions Address.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#import "Address.h"

@implementation Address

+ (instancetype)rebaseWithAddress:(long)address {
Address* result = Address.alloc.init.autorelease;
result.type = ADDRESS_REBASE;
result.address = address;
return result;
}

+ (instancetype)bindWithAddress:(long)address ordinal:(int)ordinal name:(NSString*)name addend:(int)addend {
Address* result = Address.alloc.init.autorelease;
result.type = ADDRESS_BIND;
result.address = address;
result.dylibOrdinal = ordinal;
result.name = name;
result.addend = addend;
return result;
}

+ (instancetype)exportWithAddress:(long)address name:(NSString*)name {
Address* result = Address.alloc.init.autorelease;
result.type = ADDRESS_EXPORT;
result.address = address;
result.name = name;
return result;
}

+ (instancetype)reexportWithName:(NSString*)name importName:(NSString*)importName importOrdinal:(int)ordinal {
Address* result = Address.alloc.init.autorelease;
result.type = ADDRESS_REEXPORT;
result.name = name;
result.importName = importName;
result.dylibOrdinal = ordinal;
return result;
}

- (BOOL)isRebase {
return self.type == ADDRESS_REBASE;
}

- (BOOL)isBind {
return self.type == ADDRESS_BIND;
}

- (BOOL)isExport {
return self.type == ADDRESS_EXPORT;
}

- (BOOL)isReexport {
return self.type == ADDRESS_REEXPORT;
}

@end
30 changes: 19 additions & 11 deletions CacheFile.h
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
// TODO: properly tune this

@import Foundation;

#import "Extern.h"
#import "LocationBase.h"

@class CacheImage;

#define FAST_CHUNK_SIZE 0x10000

@interface CacheFile:NSObject<LocationBase>
@interface CacheFile : NSObject <LocationBase>

@property(retain) NSMutableData* data;
@property(retain) NSArray<CacheImage*>* images;

@property(retain) NSDictionary<NSNumber*,NSArray<NSNumber*>*>* fastRebasesByChunk;
@property(retain) NSDictionary<NSNumber*,NSArray<CacheImage*>*>* fastImagesByChunk;
@property(retain) NSDictionary<NSString*,CacheImage*>* fastImagesByPath;
@property(retain) NSDictionary<NSNumber*, NSArray<NSNumber*>*>* fastRebasesByChunk;
@property(retain) NSDictionary<NSNumber*, NSArray<CacheImage*>*>* fastImagesByChunk;
@property(retain) NSDictionary<NSString*, CacheImage*>* fastImagesByPath;

-(instancetype)initWithPath:(NSString*)path;
- (instancetype)initWithPath:(NSString*)path;

-(long)maxConstDataMappingAddress;
-(long)maxConstDataSegmentAddress;
-(CacheImage*)imageWithPath:(NSString*)path;
-(NSArray<CacheImage*>*)imagesWithPathPrefix:(NSString*)path;
-(CacheImage*)imageWithAddress:(long)address;
-(NSArray<NSNumber*>*)rebasesWithStartAddress:(long)start endAddress:(long)end;
- (long)maxConstDataMappingAddress;
- (long)maxConstDataSegmentAddress;
- (CacheImage*)imageWithPath:(NSString*)path;
- (NSArray<CacheImage*>*)imagesWithPathPrefix:(NSString*)path;
- (CacheImage*)imageWithAddress:(long)address;
- (NSArray<NSNumber*>*)rebasesWithStartAddress:(long)start endAddress:(long)end;
- (struct dyld_cache_header*)header;

@end
Loading
Loading