From 926c9063dc7929674f670b43eb6979e3f9677d91 Mon Sep 17 00:00:00 2001 From: Peter Maydell Date: Sun, 29 Nov 2020 20:39:22 +0000 Subject: elf_ops.h: Don't truncate name of the ROM blobs we create Currently the load_elf code assembles the ROM blob name into a local 128 byte fixed-size array. Use g_strdup_printf() instead so that we don't truncate the pathname if it happens to be long. (This matters mostly for monitor 'info roms' output and for the error messages if ROM blobs overlap.) Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20201129203923.10622-4-peter.maydell@linaro.org --- include/hw/elf_ops.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/hw/elf_ops.h') diff --git a/include/hw/elf_ops.h b/include/hw/elf_ops.h index 6fdff3dced..53e0152af5 100644 --- a/include/hw/elf_ops.h +++ b/include/hw/elf_ops.h @@ -330,7 +330,6 @@ static int glue(load_elf, SZ)(const char *name, int fd, uint64_t addr, low = (uint64_t)-1, high = 0; GMappedFile *mapped_file = NULL; uint8_t *data = NULL; - char label[128]; int ret = ELF_LOAD_FAILED; if (read(fd, &ehdr, sizeof(ehdr)) != sizeof(ehdr)) @@ -544,7 +543,8 @@ static int glue(load_elf, SZ)(const char *name, int fd, */ if (mem_size != 0) { if (load_rom) { - snprintf(label, sizeof(label), "phdr #%d: %s", i, name); + g_autofree char *label = + g_strdup_printf("phdr #%d: %s", i, name); /* * rom_add_elf_program() takes its own reference to -- cgit 1.4.1 From 311ca11e3879ba3743cc8ea8e42c12401c5098a9 Mon Sep 17 00:00:00 2001 From: Peter Maydell Date: Sun, 29 Nov 2020 20:39:23 +0000 Subject: elf_ops.h: Be more verbose with ROM blob names Instead of making the ROM blob name something like: phdr #0: /home/petmay01/linaro/qemu-misc-tests/ldmia-fault.axf make it a little more self-explanatory for people who don't know ELF format details: /home/petmay01/linaro/qemu-misc-tests/ldmia-fault.axf ELF program header segment 0 Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20201129203923.10622-5-peter.maydell@linaro.org --- include/hw/elf_ops.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include/hw/elf_ops.h') diff --git a/include/hw/elf_ops.h b/include/hw/elf_ops.h index 53e0152af5..8e8436831d 100644 --- a/include/hw/elf_ops.h +++ b/include/hw/elf_ops.h @@ -544,7 +544,8 @@ static int glue(load_elf, SZ)(const char *name, int fd, if (mem_size != 0) { if (load_rom) { g_autofree char *label = - g_strdup_printf("phdr #%d: %s", i, name); + g_strdup_printf("%s ELF program header segment %d", + name, i); /* * rom_add_elf_program() takes its own reference to -- cgit 1.4.1