shell: reorganize parsing using .cmd ELF section
This commit creates a .cmd section, so there is no global list of
commands in shell.c any more, and no ifdef in the code for conditional
commands. Also, (unrelated) makes shell errors slightly more friendly.
The technique is widely used, in the Linux kernel and all boot
loaders, as well as a lot of my own personal code, so this is safe
(and tested).
As a side effect, this allows (in later commits) to move the "verbose"
ppsi-specific command back to ppsi/arch-wrpc/ where it really belongs.
It allows new commands to be easily added by just adding their
respective file to the build.
Even though this increases code size by around 50 lines, it makes it
more modular and only costs 8 bytes in the final executable (in my
configuration: 128 bytes less of text and 136 bytes more of data).
Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
Showing
Please
register
or
sign in
to comment