-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLinkPatch.js
More file actions
21 lines (17 loc) · 785 Bytes
/
Copy pathLinkPatch.js
File metadata and controls
21 lines (17 loc) · 785 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/* back-annotate the preboot code so that "unique_id_pnt" points to "unique_id" in pico2-debug */
function LinkPatch(filename)
{
/* determine symbol location of "unique_id" in pico2-debug */
ElfFile.load("pico2-debug THUMB Release/pico2-debug.elf");
uid = ElfFile.symbolValue("unique_id");
/* create a backup duplicate of the original ELF */
backupFilename = filename + ".prepatch";
CWSys.removeFile(backupFilename);
CWSys.renameFile(filename, backupFilename);
ElfFile.load(backupFilename);
/* overwrite the now-known location into the right place in the preboot code */
uid_pnt = ElfFile.symbolValue("unique_id_pnt");
ElfFile.pokeUint32(uid_pnt, uid);
/* write the modified data to the original filename */
ElfFile.save(filename);
}