Skip to content

Commit

Permalink
sh: machvec: Use char[] for section boundaries
Browse files Browse the repository at this point in the history
[ Upstream commit c5783af ]

As done for other sections, define the extern as a character array,
which relaxes many of the compiler-time object size checks, which would
otherwise assume it's a single long. Solves the following build error:

arch/sh/kernel/machvec.c: error: array subscript 'struct sh_machine_vector[0]' is partly outside array bounds of 'long int[1]' [-Werror=array-bounds]:  => 105:33

Cc: Yoshinori Sato <[email protected]>
Cc: Rich Felker <[email protected]>
Cc: [email protected]
Reported-by: Geert Uytterhoeven <[email protected]>
Link: https://lore.kernel.org/lkml/[email protected]/
Fixes: 9655ad0 ("sh: Fixup machvec support.")
Reviewed-by: Geert Uytterhoeven <[email protected]>
Reviewed-by: Gustavo A. R. Silva <[email protected]>
Acked-by: Rich Felker <[email protected]>
Signed-off-by: Kees Cook <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
  • Loading branch information
kees authored and codewalkerster committed Jun 13, 2023
1 parent 437c339 commit ff77966
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion arch/sh/include/asm/sections.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <asm-generic/sections.h>

extern long __machvec_start, __machvec_end;
extern char __machvec_start[], __machvec_end[];
extern char __uncached_start, __uncached_end;
extern char __start_eh_frame[], __stop_eh_frame[];

Expand Down
10 changes: 5 additions & 5 deletions arch/sh/kernel/machvec.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
#define MV_NAME_SIZE 32

#define for_each_mv(mv) \
for ((mv) = (struct sh_machine_vector *)&__machvec_start; \
(mv) && (unsigned long)(mv) < (unsigned long)&__machvec_end; \
for ((mv) = (struct sh_machine_vector *)__machvec_start; \
(mv) && (unsigned long)(mv) < (unsigned long)__machvec_end; \
(mv)++)

static struct sh_machine_vector * __init get_mv_byname(const char *name)
Expand Down Expand Up @@ -89,8 +89,8 @@ void __init sh_mv_setup(void)
if (!machvec_selected) {
unsigned long machvec_size;

machvec_size = ((unsigned long)&__machvec_end -
(unsigned long)&__machvec_start);
machvec_size = ((unsigned long)__machvec_end -
(unsigned long)__machvec_start);

/*
* Sanity check for machvec section alignment. Ensure
Expand All @@ -104,7 +104,7 @@ void __init sh_mv_setup(void)
* vector (usually the only one) from .machvec.init.
*/
if (machvec_size >= sizeof(struct sh_machine_vector))
sh_mv = *(struct sh_machine_vector *)&__machvec_start;
sh_mv = *(struct sh_machine_vector *)__machvec_start;
}

printk(KERN_NOTICE "Booting machvec: %s\n", get_system_type());
Expand Down

0 comments on commit ff77966

Please sign in to comment.