gen_syscall_header: create dummy handler refs
gen_syscall_header: create dummy handler refs

The core kernel is built with the --no-whole-archive linker option.
For all the individual .o files which make up the kernel, if there
are no external references to symbols within these object files,
everything in the object file is dropped.

This has a subtle interaction with system call handlers. If an object
file has system call handlers inside it, and nothing else in the
object file is referenced, then the linker will prefer the weak
version of the handler in the generated syscall_dispatch.c. The
user will get an "unimplemented system call" error if the associated
system call for that handler is made.

Fix this by making a fake reference to the handler function at the
system call site. The address gets stored inside a special section
"hndlr_ref".  This is enough to prevent the handlers from being
dropped, and the hndlr_ref section is itself dropped from the binary
from gc-sections; these references will not consume space.

Handlers for system calls that are never invoked anywhere will still be
dropped if nothing else in their containing C files is used, which is
a good thing. A future enhancement could be to split out all handlers
into individual object files, such that we can guarantee that any system
call that is not made somewhere in the application will have its handler
dropped. This will need to be extended to driver subsystems as well.
This won't be pretty but will ensure the tightest binary size.

Fixes #5184.

Signed-off-by: Andrew Boie <aab045b28152628be6af0e556050d0381fd0a34d@intel.com>

aceofall/zephyr-iotos,zephyriot/zephyr,finikorg/zephyr,zephyrproject-rtos/zephyr,galak/zephyr,mbolivar/zephyr,GiulianoFranchetto/zephyr,explora26/zephyr,mbolivar/zephyr,punitvara/zephyr,ldts/zephyr,ldts/zephyr,zephyrproject-rtos/zephyr,galak/zephyr,kraj/zephyr,aceofall/zephyr-iotos,mbolivar/zephyr,galak/zephyr,mbolivar/zephyr,nashif/zephyr,zephyriot/zephyr,ldts/zephyr,kraj/zephyr,mbolivar/zephyr,finikorg/zephyr,finikorg/zephyr,nashif/zephyr,Vudentz/zephyr,galak/zephyr,zephyriot/zephyr,GiulianoFranchetto/zephyr,punitvara/zephyr,zephyriot/zephyr,Vudentz/zephyr,finikorg/zephyr,zephyriot/zephyr,nashif/zephyr,Vudentz/zephyr,kraj/zephyr,zephyrproject-rtos/zephyr,zephyrproject-rtos/zephyr,aceofall/zephyr-iotos,kraj/zephyr,GiulianoFranchetto/zephyr,explora26/zephyr,aceofall/zephyr-iotos,kraj/zephyr,finikorg/zephyr,Vudentz/zephyr,Vudentz/zephyr,GiulianoFranchetto/zephyr,ldts/zephyr,zephyrproject-rtos/zephyr,nashif/zephyr,aceofall/zephyr-iotos,punitvara/zephyr,Vudentz/zephyr,punitvara/zephyr,explora26/zephyr,galak/zephyr,GiulianoFranchetto/zephyr,nashif/zephyr,punitvara/zephyr,ldts/zephyr,explora26/zephyr,explora26/zephyr