binfmt_elf: reduce stackusage in kunit test
Subsystems (2)
PATCH 1/1 binfmt_elf: reduce stackusage in kunit test
From: Arnd Bergmann <[email protected]>
Constructing arrays on the stack in the test case triggers a warning in some configurations:
fs/tests/binfmt_elf_kunit.c: In function 'total_mapping_size_test':fs/tests/binfmt_elf_kunit.c:52:1: error: the frame size of 1448 bytes is larger than 1408 bytes [-Werror=frame-larger-than=]
Change the arrays to 'static const' to not use any stack space at all. This is possible since the contents are never modified.
Fixes 9e1a3ce0a952 ("binfmt_elf: Introduce KUnit test")
Signed-off-by Arnd Bergmann <[email protected]>
--- fs/tests/binfmt_elf_kunit.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/tests/binfmt_elf_kunit.c +3 -3
@@ -3,7 +3,7 @@static void total_mapping_size_test (struct kunit *test) { -struct elf_phdr empty[] = { +static const struct elf_phdr empty[] = { { .p_type =PT_LOAD , .p_vaddr =0 , .p_memsz =0 , }, { .p_type =PT_INTERP , .p_vaddr =10 , .p_memsz =999999 , }, };
@@ -11,7 +11,7 @@ static void total_mapping_size_test(struct kunit *test)* readelf -lW /bin/mount | grep '^ .*0x0' | awk '{print "\t\t{ .p_type = PT_" \ * $1 ", .p_vaddr = " $3 ", .p_memsz = " $6 ", },"}' */ -struct elf_phdr mount[] = { +static const struct elf_phdr mount[] = { { .p_type =PT_PHDR , .p_vaddr =0x00000040 , .p_memsz =0x0002d8 , }, { .p_type =PT_INTERP , .p_vaddr =0x00000318 , .p_memsz =0x00001c , }, { .p_type =PT_LOAD , .p_vaddr =0x00000000 , .p_memsz =0x0033a8 , },
@@ -28,7 +28,7 @@ static void total_mapping_size_test(struct kunit *test) };size_t mount_size =0xE070 ;/* https://lore.kernel.org/linux-fsdevel/[email protected] */ -struct elf_phdr unordered[] = { +static const struct elf_phdr unordered[] = { { .p_type =PT_LOAD , .p_vaddr =0x00000000 , .p_memsz =0x0033a8 , }, { .p_type =PT_LOAD , .p_vaddr =0x0000d330 , .p_memsz =0x000d40 , }, { .p_type =PT_LOAD , .p_vaddr =0x00004000 , .p_memsz =0x005c91 , },
Signature · 1 line
2.39.5