aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorMichal Simek2022-06-24 14:14:59 +0200
committerMichal Simek2022-06-24 14:14:59 +0200
commitfe9d049e1319b040c80634a0db8d6309b9e9b746 (patch)
treef76d22a82dd538e8a74a2f5a8117b613749fb243 /tools
parent686c2bbb4429088b21b7dc281e43f7ea0c3080d1 (diff)
tools: relocate-rela: Open binary u-boot file later
There is no value to open u-boot binary file so early. Better to check all values first and then open binary file. Signed-off-by: Michal Simek <michal.simek@amd.com> Link: https://lore.kernel.org/r/9c2b4ebadbe83497db28af02f6af2623793ffdb6.1655299267.git.michal.simek@amd.com
Diffstat (limited to 'tools')
-rw-r--r--tools/relocate-rela.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/tools/relocate-rela.c b/tools/relocate-rela.c
index f0bc548617a..88398711186 100644
--- a/tools/relocate-rela.c
+++ b/tools/relocate-rela.c
@@ -73,13 +73,6 @@ int main(int argc, char **argv)
return 1;
}
- f = fopen(argv[1], "r+b");
- if (!f) {
- fprintf(stderr, "%s: Cannot open %s: %s\n",
- argv[0], argv[1], strerror(errno));
- return 2;
- }
-
if (!read_num(argv[2], &text_base) ||
!read_num(argv[3], &rela_start) ||
!read_num(argv[4], &rela_end)) {
@@ -95,6 +88,13 @@ int main(int argc, char **argv)
rela_start -= text_base;
rela_end -= text_base;
+ f = fopen(argv[1], "r+b");
+ if (!f) {
+ fprintf(stderr, "%s: Cannot open %s: %s\n",
+ argv[0], argv[1], strerror(errno));
+ return 2;
+ }
+
fseek(f, 0, SEEK_END);
file_size = ftell(f);
rewind(f);