contrib/elf2dmp: Grow PDB URL buffer
The buffers used to construct a PDB URL overflow when the "age" property is greater than 0xf, so grow it. This also simplifies the logic of the URL construction to use one buffer instead of two to avoid the chore to synchronize the sizes of two buffers. Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Message-ID: <20260305-nvme-v4-1-b65b9de1839f@rsg.ci.i.u-tokyo.ac.jp> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Akihiko Odaki committed
Mar 5, 2026 at 15:16 UTC
2d23a976311ee7dbbd11518a48ab8e614338a143
1 file changed
+15
-17
contrib/elf2dmp/main.c
+15
-17
@@ -494,18 +494,6 @@ static bool pe_check_pdb_name(uint64_t base, void *start_addr,
494
return !strcmp(pdb_name, PDB_NAME);
495
}
496
497
-static void pe_get_pdb_symstore_hash(OMFSignatureRSDS *rsds, char *hash)
498
-{
499
- sprintf(hash, "%.08x%.04x%.04x%.02x%.02x", rsds->guid.a, rsds->guid.b,
500
- rsds->guid.c, rsds->guid.d[0], rsds->guid.d[1]);
501
- hash += 20;
502
- for (unsigned int i = 0; i < 6; i++, hash += 2) {
503
- sprintf(hash, "%.02x", rsds->guid.e[i]);
504
- }
505
-
506
- sprintf(hash, "%.01x", rsds->age);
507
-}
508
-
497
int main(int argc, char *argv[])
498
{
499
int err = 1;
@@ -517,9 +505,7 @@ int main(int argc, char *argv[])
505
uint64_t KernBase;
506
void *nt_start_addr = NULL;
507
WinDumpHeader64 header;
520
- char pdb_hash[34];
521
- char pdb_url[] = SYM_URL_BASE PDB_NAME
522
- "/0123456789ABCDEF0123456789ABCDEFx/" PDB_NAME;
508
+ g_autofree char *pdb_url = NULL;
509
struct pdb_reader pdb;
510
uint64_t KdDebuggerDataBlock;
511
KDDEBUGGER_DATA64 *kdbg;
@@ -583,9 +569,21 @@ int main(int argc, char *argv[])
569
printf("KernBase = 0x%016"PRIx64", signature is \'%.2s\'\n", KernBase,
570
(char *)nt_start_addr);
571
586
- pe_get_pdb_symstore_hash(&rsds, pdb_hash);
572
+ pdb_url = g_strdup_printf("%s"
573
+ "%.08x%.04x%.04x"
574
+ "%.02x%.02x"
575
+ "%.02x%.02x"
576
+ "%.02x%.02x"
577
+ "%.02x%.02x%.01x"
578
+ "%s",
579
+ SYM_URL_BASE PDB_NAME "/",
580
+ rsds.guid.a, rsds.guid.b, rsds.guid.c,
581
+ rsds.guid.d[0], rsds.guid.d[1],
582
+ rsds.guid.e[0], rsds.guid.e[1],
583
+ rsds.guid.e[2], rsds.guid.e[3],
584
+ rsds.guid.e[4], rsds.guid.e[5], rsds.age,
585
+ "/" PDB_NAME);
586
588
- sprintf(pdb_url, "%s%s/%s/%s", SYM_URL_BASE, PDB_NAME, pdb_hash, PDB_NAME);
587
printf("PDB URL is %s\n", pdb_url);
588
589
if (!download_url(PDB_NAME, pdb_url)) {