Skip to content

Commit

Permalink
Create mSizes
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderOMara committed Jan 18, 2025
1 parent 55b1351 commit 987661d
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions macho/universal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ export class Universal {
*/
private mLength = 0;

/**
* Length of slice at each offset.
*/
private mSizes: Map<number, number> = new Map();

/**
* Mach type.
*/
Expand Down Expand Up @@ -78,6 +83,7 @@ export class Universal {
this.mArchList = null;
this.mArchCount = 0;
this.mThinArch = null;
const mSizes = this.mSizes = new Map();

const hs = Math.max(FatHeader.BYTE_LENGTH, MachHeader.BYTE_LENGTH);
const hd = await reader.slice(offset, offset + hs).arrayBuffer();
Expand Down Expand Up @@ -124,6 +130,19 @@ export class Universal {
}
sortedList.sort((a, b) => a.offset - b.offset);

for (const { offset, size } of sortedList) {
if (mSizes.has(offset)) {
throw new RangeError(
`Two architectures have the same offset: ${offset}`,
);
}
mSizes.set(offset, size);

// TODO
}

// TODO

break;
}
case MH_CIGAM:
Expand Down

0 comments on commit 987661d

Please sign in to comment.