sections.h: add generic section declaration

Quite a few generalizations between section tables
and ranges:

o Replace the *SECTION_TBL*() macros with generic
  *SECTION_TYPE*() macros. This lets us be more agnostic
  between the linker tables and section ranges and also
  lets us add other possible section types in the future
  in a more generic fashion.

o Generalize the arbitrary order of "any" as SECTION_ORDER_ANY,
  any special section type not needing order can use this. The
  section ranges are an example.

o Keep sort for section ranges on, otherwise
  the start and end declaration will not work. By keeping the
  sort and using "any" for in between items we're able to extend
  section ranges without modifying the linker script.

o Rename the special section for tables from .tbl to .tables
o Use    the special section for ranges as           .ranges.

o Require SECTION_TYPE_* name declarations for each new type
  of special section type. We start off with two:

  - SECTION_TYPE_RANGES	this is for .tables
  - SECTION_TYPE_TABLES	this is for .ranges

  These are postfixes for each special section type. By
  using these we can easily modify the special section
  postfix in header files in one place.

o Due to the very explicit divide between section ranges and
  section tables we now need a separate entry for each in
  but we accept this for now as it helps with semantics in separation.
  Technically we could also just shove both section ranges and
  section tables under its own special section prefix, perhaps
  .types and then we can move both section ranges and section tables
  underneath, so we'd have, for example for .text:


  While this saves us the need to add a new special section type
  under we may loose the ability to sort tables.* and/or
  we are forcing a sort for *all* special section types, thereby slowing
  down link time.

o Since we modified tons of section stufff, we needed to fix the
  'make clean' as otherwise we are left with old objects using
   the old .tbl section names.

Tons of bike shedding opportunities here! We let the fun bike shedding
discussions happen openly with the community.

Run time tested:

Initializing x86 bare metal world
x86-init: Number of init entries: 7
Initializing kasan ...
Early init for Kasan...
Completed initializing kasan !
Initializing memory ...
Completed initializing memory !
Initializing kprobes ...
== OK: test_kprobe_0001 within range!
== OK: test_kprobe_0002 not in range as expected!
Completed initializing kprobes !
Initializing pci ...
PCI fixup size: 1
Completed initializing pci !
Initializing beta ...
Completed initializing beta !
Initializing alpha ...
Completed initializing alpha !
Booting bare metal
Calling start_kernel()...
ACME: Initializing ...
ACME: Finished init ... !
ACME: Running scheduled work

Signed-off-by: Luis R. Rodriguez <>
6 files changed