build: simplfy how extra build steps are specified

For various reasons its often necessary to generate certain
complex data structures at build-time by separate tools outside
of the C compiler. Data is populated to these tools by way of
special binary sections not intended to be included in the final
binary. We currently do this to generate interrupt tables, forthcoming
work will also use this to generate MMU page tables.

The way we have been doing this is to generatea "kernel_prebuilt.elf",
extract the metadata sections with objcopy, run the tool, and then
re-link the kernel with the extra data *and* use objcopy to pull
out the unwanted sections.

This doesn't scale well if multiple post-build steps are needed.
Now this is much simpler; in any Makefile, a special
GENERATED_KERNEL_OBJECT_FILES variable may be appended to containing
the filenames to the generated object files, which will be generated
by Make in the usual fashion.

Instead of using objcopy to pull out, we now create a linker-pass2.cmd
which additionally defines LINKER_PASS2. The source linker script
can #ifdef around this to use the special /DISCARD/ section target
to not include metadata sections in the final binary.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
Andrew Boie 2017-05-12 13:27:50 -07:00 committed by Anas Nashif
commit 174f301147
5 changed files with 59 additions and 61 deletions

View file

@ -34,12 +34,7 @@
* }
*/
/* We don't set NOLOAD here, as objcopy will not let us extract the intList
* section into a file if we do so; the resulting file is 0 bytes. We do so
* with objcopy in Makefile.gen_isr_tables after we have extracted the
* information we need.
*/
#ifndef LINKER_PASS2
SECTION_PROLOGUE(.intList,,)
{
KEEP(*(.irq_info))
@ -48,4 +43,10 @@ SECTION_PROLOGUE(.intList,,)
KEEP(*(.intList))
__INT_LIST_END__ = .;
} GROUP_LINK_IN(IDT_LIST)
#else
/DISCARD/ :
{
KEEP(*(.irq_info))
KEEP(*(.intList))
}
#endif