summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorAaron Durbin <adurbin@chromium.org>2015-09-05 12:59:26 -0500
committerAaron Durbin <adurbin@chromium.org>2015-09-09 19:35:30 +0000
commitdde7629e9cccf7b3a9b2e468ac8439f91d13cf97 (patch)
treef855ce91134e77665b4019efbaaee019dc36c774 /src/lib
parente5bad5cd3d828eba06f1db66f43948f966e7b0e0 (diff)
downloadcoreboot-dde7629e9cccf7b3a9b2e468ac8439f91d13cf97.tar.xz
rmodule: use program.ld for linking
Bring rmodule linking into the common linking method. The __rmodule_entry symbol was removed while using a more common _start symbol. The rmodtool will honor the entry point found within the ELF header. Add ENV_RMODULE so that one can distinguish the environment when generating linker scripts for rmodules. Lastly, directly use program.ld for the rmodule.ld linker script. BUG=chrome-os-partner:44827 BRANCH=None TEST=Built rambi and analyzed the relocatable ramstage, sipi_vector, and smm rmodules. Change-Id: Iaa499eb229d8171272add9ee6d27cff75e7534ac Signed-off-by: Aaron Durbin <adubin@chromium.org> Reviewed-on: http://review.coreboot.org/11517 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi <pgeorgi@google.com>
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/program.ld15
-rw-r--r--src/lib/rmodule.ld101
2 files changed, 17 insertions, 99 deletions
diff --git a/src/lib/program.ld b/src/lib/program.ld
index cf011e9b08..d6e3e54c09 100644
--- a/src/lib/program.ld
+++ b/src/lib/program.ld
@@ -38,14 +38,14 @@
*(.text);
*(.text.*);
-#if ENV_RAMSTAGE || ENV_ROMSTAGE
+#if ENV_RAMSTAGE || ENV_ROMSTAGE || ENV_RMODULE
. = ALIGN(ARCH_POINTER_ALIGN_SIZE);
_cbmem_init_hooks = .;
KEEP(*(.rodata.cbmem_init_hooks));
_ecbmem_init_hooks = .;
#endif
-#if ENV_RAMSTAGE
+#if ENV_RAMSTAGE || ENV_RMODULE
. = ALIGN(ARCH_POINTER_ALIGN_SIZE);
_pci_drivers = .;
KEEP(*(.rodata.pci_driver));
@@ -79,13 +79,20 @@
.data : {
. = ALIGN(ARCH_CACHELINE_ALIGN_SIZE);
_data = .;
+
+#if ENV_RMODULE
+ _rmodule_params = .;
+ KEEP(*(.module_parameters));
+ _ermodule_params = .;
+#endif
+
*(.data);
*(.data.*);
#ifdef __PRE_RAM__
PROVIDE(_preram_cbmem_console = .);
PROVIDE(_epreram_cbmem_console = _preram_cbmem_console);
-#elif ENV_RAMSTAGE
+#elif ENV_RAMSTAGE || ENV_RMODULE
. = ALIGN(ARCH_POINTER_ALIGN_SIZE);
_bs_init_begin = .;
KEEP(*(.bs_init));
@@ -116,7 +123,7 @@
.heap : {
. = ALIGN(ARCH_POINTER_ALIGN_SIZE);
_heap = .;
- . += CONFIG_HEAP_SIZE;
+ . += (ENV_RMODULE ? __heap_size : CONFIG_HEAP_SIZE);
. = ALIGN(ARCH_POINTER_ALIGN_SIZE);
_eheap = .;
}
diff --git a/src/lib/rmodule.ld b/src/lib/rmodule.ld
index f5d5f061e5..340fe7ae13 100644
--- a/src/lib/rmodule.ld
+++ b/src/lib/rmodule.ld
@@ -12,103 +12,14 @@
* won't be a consistent mapping between the flat blob and the loaded program.
*/
-BASE_ADDRESS = 0x00000;
-
-ENTRY(__rmodule_entry);
+#include <memlayout.h>
+#include <arch/header.ld>
SECTIONS
{
- . = BASE_ADDRESS;
-
- .payload : {
- /* C code of the module. */
- _program = .;
- *(.text._start);
- *(.text.stage_entry);
- *(.text);
- *(.text.*);
- /* C read-only data. */
- . = ALIGN(16);
-
-#if IS_ENABLED(CONFIG_COVERAGE)
- __CTOR_LIST__ = .;
- *(.ctors);
- LONG(0);
- LONG(0);
- __CTOR_END__ = .;
-#endif
-
- /* 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 = .;
- _cbmem_init_hooks = .;
- KEEP(*(.rodata.cbmem_init_hooks));
- _ecbmem_init_hooks = .;
-
- . = 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. */
- . = ALIGN(64); /* Mirror cache line alignment from ramstage. */
- _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 = .;
- _eprogram = .;
- }
+ SET_COUNTER(rmodule, 0x00000000)
- /DISCARD/ : {
- /* Drop unnecessary sections. */
- *(.eh_frame);
- *(.note);
- *(.note.*);
- }
+ /* program.ld is directly included because there's no one particular
+ * class that rmodule is used on. */
+ #include <lib/program.ld>
}