-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: uuids for ELF files * fix: make pkg compatible * chore: install @bugsplat/elfy
- Loading branch information
Showing
7 changed files
with
136 additions
and
51 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,9 @@ | ||
import { tryGetElfUUID } from "../src/elf"; | ||
|
||
describe('elf', () => { | ||
describe('tryGetElfUUID', () => { | ||
it('should return uuid for elf file', async () => { | ||
return expectAsync(tryGetElfUUID('spec/support/bugsplat.elf')).toBeResolvedTo('005f5f676d6f6e5f73746172745f5f006c696263'); | ||
}); | ||
}); | ||
}); |
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,34 @@ | ||
import { ElfFile } from '@bugsplat/elfy'; | ||
|
||
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(); | ||
} | ||
|
||
if (success) { | ||
return getUUID(section!); | ||
} | ||
|
||
elfFile = await ElfFile.create(path); | ||
try { | ||
({ success, section } = await elfFile.tryReadSection('.sce_special')); | ||
} finally { | ||
elfFile.dispose(); | ||
} | ||
|
||
if (success) { | ||
return getUUID(section!); | ||
} | ||
|
||
return ''; | ||
} | ||
|
||
function getUUID(section: Buffer) { | ||
return section.subarray(0, 20).toString('hex'); | ||
} |
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
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