coreboot-kgpe-d16/src/lib/rmodule.ld
Aaron Durbin 9ef9d85976 bootstate: use structure pointers for scheduling callbacks
The GCC 4.9.2 update showed that the boot_state_init_entry
structures were being padded and assumed to be aligned in to an
increased size. The bootstate scheduler for static entries,
boot_state_schedule_static_entries(), was then calculating the
wrong values within the array. To fix this just use a pointer to
the boot_state_init_entry structure that needs to be scheduled.

In addition to the previous issue noted above, the .bs_init
section was sitting in the read only portion of the image while
the fields within it need to be writable. Also, the
boot_state_schedule_static_entries() was using symbol comparison
to terminate a loop which in C can lead the compiler to always
evaluate the loop at least once since the language spec indicates
no 2 symbols can be the same value.

Change-Id: I6dc5331c2979d508dde3cd5c3332903d40d8048b
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: http://review.coreboot.org/8699
Tested-by: build bot (Jenkins)
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
2015-03-18 16:41:43 +01:00

107 lines
2.3 KiB
Text

/*
* This linker script is used to link rmodules (relocatable modules). It
* links at zero so that relocation fixups are easy when placing the binaries
* anywhere in the address space.
*
* NOTE: The program's loadable sections (text, module_params, and data) are
* packed into the flat blob. The rmodule loader assumes the entire program
* resides in one contiguous address space. Therefore, alignment for a given
* section (if required) needs to be done at the end of the preceeding section.
* e.g. if the data section should be aligned to an 8 byte address the text
* section should have ALIGN(8) at the end of its section. Otherwise there
* won't be a consistent mapping between the flat blob and the loaded program.
*/
BASE_ADDRESS = 0x00000;
ENTRY(__rmodule_entry);
SECTIONS
{
. = BASE_ADDRESS;
.payload : {
/* C code of the module. */
_ram_seg = .;
*(.textfirst);
*(.text);
*(.text.*);
/* C read-only data. */
. = ALIGN(16);
__CTOR_LIST__ = .;
*(.ctors);
LONG(0);
LONG(0);
__CTOR_END__ = .;
/* The driver sections are to allow linking coreboot's
* ramstage with the rmodule linker. Any changes made in
* ramstage.ld should be made here as well. */
. = ALIGN(8);
pci_drivers = . ;
KEEP(*(.rodata.pci_driver));
epci_drivers = . ;
. = ALIGN(8);
cpu_drivers = . ;
KEEP(*(.rodata.cpu_driver));
ecpu_drivers = . ;
. = ALIGN(8);
_bs_init_begin = .;
KEEP(*(.bs_init));
LONG(0);
LONG(0);
_bs_init_end = .;
. = ALIGN(8);
*(.rodata);
*(.rodata.*);
. = ALIGN(8);
/* The parameters section can be used to pass parameters
* to a module, however there has to be an prior agreement
* on how to interpret the parameters. */
_module_params_begin = .;
KEEP(*(.module_parameters));
_module_params_end = .;
. = ALIGN(8);
/* Data section. */
_sdata = .;
*(.data);
*(.data.*);
. = ALIGN(8);
_edata = .;
. = ALIGN(8);
}
.bss (NOLOAD) : {
/* C uninitialized data of the module. */
_bss = .;
*(.bss);
*(.bss.*)
*(.sbss)
*(.sbss.*)
*(COMMON);
. = ALIGN(8);
_ebss = .;
/*
* Place the heap after BSS. The heap size is passed in by
* by way of ld --defsym=__heap_size=<>
*/
_heap = .;
. = . + __heap_size;
_eheap = .;
_eram_seg = .;
}
/DISCARD/ : {
/* Drop unnecessary sections. */
*(.eh_frame);
*(.note);
*(.note.*);
}
}