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

feat: allow nss uploads for Nintendo #117

Merged
merged 3 commits into from
Sep 12, 2024
Merged
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
33 changes: 16 additions & 17 deletions src/elf.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@
import { ElfFile } from '@bugsplat/elfy';
import { extname } from 'node:path';

export async function tryGetElfUUID(path: string) {
let success: boolean, section: Buffer | undefined;

// TODO BG use a using statement here when we move away from pkg and can use node 20+
let elfFile = await ElfFile.create(path);
try {
({ success, section } = await elfFile.tryReadSection('.note.gnu.build-id'));
} finally {
elfFile.dispose();
}
using elfFile = await ElfFile.create(path);
({ success, section } = await elfFile.tryReadSection('.note.gnu.build-id'));

if (success) {
return getUUID(section!, 16);
return getUUID(section!, path, 16);
}

elfFile = await ElfFile.create(path);
try {
({ success, section } = await elfFile.tryReadSection('.sce_special'));
} finally {
elfFile.dispose();
}
({ success, section } = await elfFile.tryReadSection('.sce_special'));

if (success) {
return getUUID(section!);
return getUUID(section!, path);
}

return '';
}

function getUUID(section: Buffer, offset = 0) {
return section.subarray(offset, offset + 20).toString('hex');
function getUUID(section: Buffer, path: string, offset = 0) {
let uuid = section.subarray(offset, offset + 20).toString('hex');

// Nintendo GUIDs seem to be 32 or 40 hex chars 0 padded to 64 hex chars
// Until we know more, pad it ourselves with this hacky workaround
if (extname(path)?.toLowerCase() === '.nss') {
uuid = uuid.padEnd(64, '0');
}

return uuid;
}
2 changes: 1 addition & 1 deletion src/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,4 @@ async function createSymbolFileInfos(symbolFilePath: string): Promise<SymbolFile
} as SymbolFileInfo];
}

const elfExtensions = ['.elf', '.self', '.prx', '.sprx'];
const elfExtensions = ['.elf', '.self', '.prx', '.sprx', '.nss'];
Loading