1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 2010 "Wu Zhangjin" <wuzhangjin@gmail.com>
12 #include <linux/sizes.h>
14 int main(int argc
, char *argv
[])
16 unsigned long long vmlinux_size
, vmlinux_load_addr
, vmlinuz_load_addr
;
20 fprintf(stderr
, "Usage: %s <pathname> <vmlinux_load_addr>\n",
25 if (stat(argv
[1], &sb
) == -1) {
30 /* Convert hex characters to dec number */
32 if (sscanf(argv
[2], "%llx", &vmlinux_load_addr
) != 1) {
36 fprintf(stderr
, "No matching characters\n");
41 vmlinux_size
= (uint64_t)sb
.st_size
;
42 vmlinuz_load_addr
= vmlinux_load_addr
+ vmlinux_size
;
45 * Align with 64KB: KEXEC needs load sections to be aligned to PAGE_SIZE,
46 * which may be as large as 64KB depending on the kernel configuration.
49 vmlinuz_load_addr
+= (SZ_64K
- vmlinux_size
% SZ_64K
);
51 printf("0x%llx\n", vmlinuz_load_addr
);