aboutsummaryrefslogtreecommitdiff
path: root/linux-user/elfload.c
diff options
context:
space:
mode:
authorRichard Henderson <richard.henderson@linaro.org>2020-10-21 10:37:46 -0700
committerPeter Maydell <peter.maydell@linaro.org>2020-10-27 10:44:02 +0000
commit808f656318109dfcb1c662002b0ebcb77d08c35a (patch)
treeac33e26a2b0082da39bf7abc55523846f33687e9 /linux-user/elfload.c
parentc7f17e7bd744dceff5708346d7c28ea2a08b7c18 (diff)
downloadqemu-808f656318109dfcb1c662002b0ebcb77d08c35a.zip
qemu-808f656318109dfcb1c662002b0ebcb77d08c35a.tar.gz
qemu-808f656318109dfcb1c662002b0ebcb77d08c35a.tar.bz2
linux-user/elfload: Use Error for load_elf_interp
This is slightly clearer than just using strerror, though the different forms produced by error_setg_file_open and error_setg_errno isn't entirely convenient. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 20201021173749.111103-10-richard.henderson@linaro.org Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'linux-user/elfload.c')
-rw-r--r--linux-user/elfload.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 56fbda9..04c04bc 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -2675,26 +2675,27 @@ static void load_elf_interp(const char *filename, struct image_info *info,
char bprm_buf[BPRM_BUF_SIZE])
{
int fd, retval;
+ Error *err = NULL;
fd = open(path(filename), O_RDONLY);
if (fd < 0) {
- goto exit_perror;
+ error_setg_file_open(&err, errno, filename);
+ error_report_err(err);
+ exit(-1);
}
retval = read(fd, bprm_buf, BPRM_BUF_SIZE);
if (retval < 0) {
- goto exit_perror;
+ error_setg_errno(&err, errno, "Error reading file header");
+ error_reportf_err(err, "%s: ", filename);
+ exit(-1);
}
+
if (retval < BPRM_BUF_SIZE) {
memset(bprm_buf + retval, 0, BPRM_BUF_SIZE - retval);
}
load_elf_image(filename, fd, info, NULL, bprm_buf);
- return;
-
- exit_perror:
- fprintf(stderr, "%s: %s\n", filename, strerror(errno));
- exit(-1);
}
static int symfind(const void *s0, const void *s1)