3

The overflow_stack variable is used in the kernel_ventry macro in arch/arm64/kernel/entry.S

    /* Switch to the overflow stack */
    adr_this_cpu sp, overflow_stack + OVERFLOW_STACK_SIZE, x0

It seems to me to be declared in arch/arm64/include/asm/stacktrace.h

DECLARE_PER_CPU(unsigned long [OVERFLOW_STACK_SIZE/sizeof(long)], overflow_stack);

However, this header file is not included in entry.S, or in any other meaningful header that I can find. Is there another way it is being included?

JHM
  • 33
  • 3

1 Answers1

2

No, there is no other way; overflow_stack isn’t declared or defined in any header included by entry.S. But that’s not an error as far as the assembler is concerned; overflow_stack doesn’t have a local prefix, so it ends up as an undefined symbol in arch/arm64/kernel/entry.o, which is resolved when the kernel is linked.

Run

make arch/arm64/kernel/entry.o

(or make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 arch/arm64/kernel/entry.o on an architecture other than arm64); then

objdump -t arch/arm64/kernel/entry.o

will show (among others)

0000000000000000         *UND*  0000000000000000 overflow_stack

The relocation tables include an number of entries for overflow_stack+0x0000000000001000 (overflow_stack + OVERFLOW_STACK_SIZE); run objdump -r arch/arm64/kernel/entry.o to see them.

Stephen Kitt
  • 411,918
  • 54
  • 1,065
  • 1,164
  • I see - I can recreate simplified analogous scenarios with assembly, but not in C. GCC always complains about undeclared identifiers. Is there a special flag you know of that would allow for undeclared identifier in C? – JHM Sep 07 '20 at 22:17
  • 1
    I’ve added some more context. The assembler handles undeclared symbols as untyped symbols with no attributes; C on the other hand requires symbols to be typed, which means they must be declared. I’m not aware of a flag to change that. – Stephen Kitt Sep 08 '20 at 00:11