mirror of
https://github.com/Dasharo/coreboot.git
synced 2026-06-13 10:16:48 -07:00
rmodules: use rmodtool to create rmodules
Start using the rmodtool for generating rmodules. rmodule_link() has been changed to create 2 rules: one for the passed in <name>, the other for creating <name>.rmod which is an ELF file in the format of an rmodule. Since the header is not compiled and linked together with an rmodule there needs to be a way of marking which symbol is the entry point. __rmodule_entry is the symbol used for knowing the entry point. There was a little churn in SMM modules to ensure an rmodule entry point symbol takes a single argument. Change-Id: Ie452ed866f6596bf13f137f5b832faa39f48d26e Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: http://review.coreboot.org/5379 Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org> Tested-by: build bot (Jenkins)
This commit is contained in:
committed by
Stefan Reinauer
parent
4fde5a66b4
commit
3eb8eb7eba
+5
-1
@@ -252,10 +252,14 @@ build-dirs:
|
||||
#######################################################################
|
||||
# Build the tools
|
||||
CBFSTOOL:=$(obj)/cbfstool
|
||||
RMODTOOL:=$(obj)/rmodtool
|
||||
|
||||
$(CBFSTOOL): $(objutil)/cbfstool/cbfstool
|
||||
cp $< $@
|
||||
|
||||
$(RMODTOOL): $(objutil)/cbfstool/rmodtool
|
||||
cp $< $@
|
||||
|
||||
_WINCHECK=$(shell uname -o 2> /dev/null)
|
||||
STACK=
|
||||
ifeq ($(_WINCHECK),Msys)
|
||||
@@ -390,5 +394,5 @@ crosstools-arm: clean-for-update
|
||||
crossgcc-clean: clean-for-update
|
||||
$(MAKE) -C util/crossgcc clean
|
||||
|
||||
tools: $(objutil)/kconfig/conf $(objutil)/cbfstool/cbfstool $(objutil)/nvramtool/nvramtool $(objutil)/romcc/romcc $(objutil)/sconfig/sconfig
|
||||
tools: $(objutil)/kconfig/conf $(objutil)/cbfstool/cbfstool $(objutil)/cbfstool/rmodtool $(objutil)/nvramtool/nvramtool $(objutil)/romcc/romcc $(objutil)/sconfig/sconfig
|
||||
|
||||
|
||||
@@ -93,7 +93,13 @@ ifneq ($(strip $(call strip_quotes,$(CONFIG_LINUX_INITRD))),)
|
||||
endif
|
||||
endif
|
||||
|
||||
$(obj)/coreboot.rom: $(obj)/coreboot.pre $(objcbfs)/coreboot_ram.elf $(CBFSTOOL) $(call strip_quotes,$(COREBOOT_ROM_DEPENDENCIES)) $$(INTERMEDIATE) $$(VBOOT_STUB_ELF)
|
||||
ifeq ($(CONFIG_HAVE_REFCODE_BLOB),y)
|
||||
REFCODE_BLOB=$(obj)/refcode.rmod
|
||||
$(REFCODE_BLOB): $(RMODTOOL)
|
||||
$(RMODTOOL) -i $(CONFIG_REFCODE_BLOB_FILE) -o $@
|
||||
endif
|
||||
|
||||
$(obj)/coreboot.rom: $(obj)/coreboot.pre $(objcbfs)/coreboot_ram.elf $(CBFSTOOL) $(call strip_quotes,$(COREBOOT_ROM_DEPENDENCIES)) $$(INTERMEDIATE) $$(VBOOT_STUB) $(REFCODE_BLOB)
|
||||
@printf " CBFS $(subst $(obj)/,,$(@))\n"
|
||||
cp $(obj)/coreboot.pre $@.tmp
|
||||
$(CBFSTOOL) $@.tmp add-stage -f $(objcbfs)/coreboot_ram.elf -n $(CONFIG_CBFS_PREFIX)/coreboot_ram -c $(CBFS_COMPRESS_FLAG)
|
||||
@@ -140,7 +146,7 @@ ifeq ($(CONFIG_INCLUDE_CONFIG_FILE),y)
|
||||
$(CBFSTOOL) $@.tmp add -f $(obj)/config.tmp -n config -t raw; rm -f $(obj)/config.tmp ; fi
|
||||
endif
|
||||
ifeq ($(CONFIG_VBOOT_VERIFY_FIRMWARE),y)
|
||||
$(CBFSTOOL) $@.tmp add-stage -f $(VBOOT_STUB_ELF) -n $(CONFIG_CBFS_PREFIX)/vboot -c $(CBFS_COMPRESS_FLAG)
|
||||
$(CBFSTOOL) $@.tmp add-stage -f $(VBOOT_STUB) -n $(CONFIG_CBFS_PREFIX)/vboot -c $(CBFS_COMPRESS_FLAG)
|
||||
endif
|
||||
ifeq ($(CONFIG_HAVE_REFCODE_BLOB),y)
|
||||
$(CBFSTOOL) $@.tmp add-stage -f $(CONFIG_REFCODE_BLOB_FILE) -n $(CONFIG_CBFS_PREFIX)/refcode -c $(CBFS_COMPRESS_FLAG)
|
||||
@@ -205,6 +211,10 @@ ifeq ($(CONFIG_RELOCATABLE_RAMSTAGE),y)
|
||||
|
||||
$(eval $(call rmodule_link,$(objcbfs)/coreboot_ram.debug, $(objgenerated)/coreboot_ram.o, $(CONFIG_HEAP_SIZE)))
|
||||
|
||||
# The rmodule_link defintion creates an elf file with .rmod extension.
|
||||
$(objcbfs)/coreboot_ram.elf: $(objcbfs)/coreboot_ram.debug.rmod
|
||||
cp $< $@
|
||||
|
||||
else
|
||||
|
||||
$(objcbfs)/coreboot_ram.debug: $(objgenerated)/coreboot_ram.o $(src)/arch/x86/coreboot_ram.ld
|
||||
|
||||
@@ -11,7 +11,6 @@ ramstage-$(CONFIG_GENERATE_ACPI_TABLES) += acpi.c
|
||||
ramstage-$(CONFIG_GENERATE_SMBIOS_TABLES) += smbios.c
|
||||
ramstage-$(CONFIG_GENERATE_ACPI_TABLES) += acpigen.c
|
||||
ramstage-$(CONFIG_HAVE_ACPI_RESUME) += wakeup.S
|
||||
ramstage-$(CONFIG_RELOCATABLE_RAMSTAGE) += ramstage_module_header.c
|
||||
|
||||
$(obj)/arch/x86/boot/smbios.ramstage.o: $(obj)/build.h
|
||||
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
/*
|
||||
* This file is part of the coreboot project.
|
||||
*
|
||||
* Copyright (C) 2013 ChromeOS Authors
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <rmodule.h>
|
||||
|
||||
extern char _start[];
|
||||
|
||||
DEFINE_RMODULE_HEADER(ramstage_module, _start, RMODULE_TYPE_STAGE);
|
||||
@@ -19,6 +19,8 @@ thread_stacks:
|
||||
.section ".textfirst", "ax", @progbits
|
||||
.code32
|
||||
.globl _start
|
||||
.globl __rmodule_entry
|
||||
__rmodule_entry:
|
||||
_start:
|
||||
cli
|
||||
lgdt %cs:gdtaddr
|
||||
|
||||
@@ -25,12 +25,12 @@ ramstage-srcs += $(SIPI_BIN)
|
||||
rmodules-y += sipi_vector.S
|
||||
rmodules-y += sipi_header.c
|
||||
|
||||
$(SIPI_DOTO): $(dir $(SIPI_ELF))sipi_vector.rmodules.o $(dir $(SIPI_ELF))sipi_header.rmodules.o
|
||||
$(SIPI_DOTO): $(dir $(SIPI_ELF))sipi_vector.rmodules.o
|
||||
$(CC) $(LDFLAGS) -nostdlib -r -o $@ $^
|
||||
|
||||
$(eval $(call rmodule_link,$(SIPI_ELF), $(SIPI_ELF:.elf=.o), 0))
|
||||
$(eval $(call rmodule_link,$(SIPI_ELF), $(SIPI_DOTO), 0))
|
||||
|
||||
$(SIPI_BIN): $(SIPI_ELF)
|
||||
$(SIPI_BIN): $(SIPI_ELF).rmod
|
||||
$(OBJCOPY) -O binary $< $@
|
||||
|
||||
$(SIPI_BIN).ramstage.o: $(SIPI_BIN)
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
#include <rmodule.h>
|
||||
|
||||
|
||||
extern void *ap_start;
|
||||
|
||||
DEFINE_RMODULE_HEADER(sipi_vector_header, ap_start, RMODULE_TYPE_SIPI_VECTOR);
|
||||
@@ -58,6 +58,8 @@ apic_to_cpu_num:
|
||||
.text
|
||||
.code16
|
||||
.global ap_start
|
||||
.global __rmodule_entry
|
||||
__rmodule_entry:
|
||||
ap_start:
|
||||
cli
|
||||
xorl %eax, %eax
|
||||
|
||||
@@ -164,11 +164,18 @@ static int bsp_setup_msr_save_state(struct smm_relocation_params *relo_params)
|
||||
/* The relocation work is actually performed in SMM context, but the code
|
||||
* resides in the ramstage module. This occurs by trampolining from the default
|
||||
* SMRAM entry point to here. */
|
||||
static void asmlinkage
|
||||
cpu_smm_do_relocation(void *arg, int cpu, const struct smm_runtime *runtime)
|
||||
static void asmlinkage cpu_smm_do_relocation(void *arg)
|
||||
{
|
||||
msr_t mtrr_cap;
|
||||
struct smm_relocation_params *relo_params = arg;
|
||||
struct smm_relocation_params *relo_params;
|
||||
const struct smm_module_params *p;
|
||||
const struct smm_runtime *runtime;
|
||||
int cpu;
|
||||
|
||||
p = arg;
|
||||
runtime = p->runtime;
|
||||
relo_params = p->arg;
|
||||
cpu = p->cpu;
|
||||
|
||||
if (cpu >= CONFIG_MAX_CPUS) {
|
||||
printk(BIOS_CRIT,
|
||||
|
||||
@@ -6,6 +6,7 @@ ramstage-$(CONFIG_PARALLEL_MP) += mp_init.c
|
||||
ramstage-$(CONFIG_MIRROR_PAYLOAD_TO_RAM_BEFORE_LOADING) += mirror_payload.c
|
||||
|
||||
SIPI_ELF=$(obj)/cpu/x86/sipi_vector.elf
|
||||
SIPI_RMOD=$(SIPI_ELF).rmod
|
||||
SIPI_BIN=$(SIPI_ELF:.elf=)
|
||||
SIPI_DOTO=$(SIPI_ELF:.elf=.o)
|
||||
|
||||
@@ -13,14 +14,13 @@ ifeq ($(CONFIG_PARALLEL_MP),y)
|
||||
ramstage-srcs += $(SIPI_BIN)
|
||||
endif
|
||||
rmodules-$(CONFIG_PARALLEL_MP) += sipi_vector.S
|
||||
rmodules-$(CONFIG_PARALLEL_MP) += sipi_header.c
|
||||
|
||||
$(SIPI_DOTO): $(dir $(SIPI_ELF))sipi_vector.rmodules.o $(dir $(SIPI_ELF))sipi_header.rmodules.o
|
||||
$(SIPI_DOTO): $(dir $(SIPI_ELF))sipi_vector.rmodules.o
|
||||
$(CC) $(LDFLAGS) -nostdlib -r -o $@ $^
|
||||
|
||||
$(eval $(call rmodule_link,$(SIPI_ELF), $(SIPI_ELF:.elf=.o), 0))
|
||||
|
||||
$(SIPI_BIN): $(SIPI_ELF)
|
||||
$(SIPI_BIN): $(SIPI_RMOD)
|
||||
$(OBJCOPY) -O binary $< $@
|
||||
|
||||
$(SIPI_BIN).ramstage.o: $(SIPI_BIN)
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
#include <rmodule.h>
|
||||
|
||||
|
||||
extern void *ap_start;
|
||||
|
||||
DEFINE_RMODULE_HEADER(sipi_vector_header, ap_start, RMODULE_TYPE_SIPI_VECTOR);
|
||||
@@ -58,6 +58,8 @@ ap_count:
|
||||
.text
|
||||
.code16
|
||||
.global ap_start
|
||||
.global __rmodule_entry
|
||||
__rmodule_entry:
|
||||
ap_start:
|
||||
cli
|
||||
xorl %eax, %eax
|
||||
|
||||
@@ -21,10 +21,8 @@ ramstage-$(CONFIG_BACKUP_DEFAULT_SMM_REGION) += backup_default_smm.c
|
||||
|
||||
ifeq ($(CONFIG_SMM_MODULES),y)
|
||||
smmstub-y += smm_stub.S
|
||||
smmstub-y += smm_module_header.c
|
||||
|
||||
smm-y += smiutil.c
|
||||
smm-y += smm_module_header.c
|
||||
smm-y += smm_module_handler.c
|
||||
|
||||
ramstage-y += smm_module_loader.c
|
||||
@@ -40,7 +38,7 @@ $(obj)/cpu/x86/smm/smmstub.o: $$(smmstub-objs)
|
||||
# Link the SMM stub module with a 0-byte heap.
|
||||
$(eval $(call rmodule_link,$(obj)/cpu/x86/smm/smmstub.elf, $(obj)/cpu/x86/smm/smmstub.o, 0))
|
||||
|
||||
$(obj)/cpu/x86/smm/smmstub: $(obj)/cpu/x86/smm/smmstub.elf
|
||||
$(obj)/cpu/x86/smm/smmstub: $(obj)/cpu/x86/smm/smmstub.elf.rmod
|
||||
$(OBJCOPY) -O binary $< $@
|
||||
|
||||
$(obj)/cpu/x86/smm/smmstub.ramstage.o: $(obj)/cpu/x86/smm/smmstub
|
||||
@@ -55,7 +53,7 @@ $(obj)/cpu/x86/smm/smm.o: $$(smm-objs) $(LIBGCC_FILE_NAME)
|
||||
|
||||
$(eval $(call rmodule_link,$(obj)/cpu/x86/smm/smm.elf, $(obj)/cpu/x86/smm/smm.o, $(CONFIG_SMM_MODULE_HEAP_SIZE)))
|
||||
|
||||
$(obj)/cpu/x86/smm/smm: $(obj)/cpu/x86/smm/smm.elf
|
||||
$(obj)/cpu/x86/smm/smm: $(obj)/cpu/x86/smm/smm.elf.rmod
|
||||
$(OBJCOPY) -O binary $< $@
|
||||
|
||||
$(obj)/cpu/x86/smm/smm.ramstage.o: $(obj)/cpu/x86/smm/smm
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <arch/io.h>
|
||||
#include <console/console.h>
|
||||
#include <cpu/x86/smm.h>
|
||||
#include <rmodule.h>
|
||||
|
||||
typedef enum { SMI_LOCKED, SMI_UNLOCKED } smi_semaphore;
|
||||
|
||||
@@ -113,8 +114,16 @@ void *smm_get_save_state(int cpu)
|
||||
return base;
|
||||
}
|
||||
|
||||
void smm_handler_start(void *arg, int cpu, const struct smm_runtime *runtime)
|
||||
void asmlinkage smm_handler_start(void *arg)
|
||||
{
|
||||
const struct smm_module_params *p;
|
||||
const struct smm_runtime *runtime;
|
||||
int cpu;
|
||||
|
||||
p = arg;
|
||||
runtime = p->runtime;
|
||||
cpu = p->cpu;
|
||||
|
||||
/* Make sure to set the global runtime. It's OK to race as the value
|
||||
* will be the same across CPUs as well as multiple SMIs. */
|
||||
if (smm_runtime == NULL)
|
||||
@@ -157,6 +166,8 @@ void smm_handler_start(void *arg, int cpu, const struct smm_runtime *runtime)
|
||||
smi_set_eos();
|
||||
}
|
||||
|
||||
RMODULE_ENTRY(smm_handler_start);
|
||||
|
||||
/* Provide a default implementation for all weak handlers so that relocation
|
||||
* entries in the modules make sense. Without default implementations the
|
||||
* weak relocations w/o a symbol have a 0 address which is where the modules
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
/*
|
||||
* This file is part of the coreboot project.
|
||||
*
|
||||
* Copyright (C) 2013 ChromeOS Authors
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <rmodule.h>
|
||||
|
||||
extern char smm_handler_start[];
|
||||
|
||||
DEFINE_RMODULE_HEADER(smm_module, smm_handler_start, RMODULE_TYPE_SMM);
|
||||
@@ -61,6 +61,8 @@ fallback_stack_top:
|
||||
.text
|
||||
.code16
|
||||
.global smm_handler_start
|
||||
.global __rmodule_entry
|
||||
__rmodule_entry:
|
||||
smm_handler_start:
|
||||
movl $(smm_relocate_gdt), %ebx
|
||||
data32 lgdt (%ebx)
|
||||
@@ -132,11 +134,13 @@ smm_trampoline32:
|
||||
2:
|
||||
/* Call into the c-based SMM relocation function with the platform
|
||||
* parameters. Equivalent to:
|
||||
* c_handler(c_handler_params, cpu_num, smm_runtime);
|
||||
* struct arg = { c_handler_params, cpu_num, smm_runtime {;
|
||||
* c_handler(&arg)
|
||||
*/
|
||||
push $(smm_runtime)
|
||||
push %ecx
|
||||
push c_handler_arg
|
||||
push %esp
|
||||
mov c_handler, %eax
|
||||
call *%eax
|
||||
|
||||
|
||||
@@ -517,14 +517,20 @@ struct smm_runtime {
|
||||
u8 apic_id_to_cpu[CONFIG_MAX_CPUS];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
typedef void asmlinkage (*smm_handler_t)(void *arg, int cpu,
|
||||
const struct smm_runtime *runtime);
|
||||
struct smm_module_params {
|
||||
void *arg;
|
||||
int cpu;
|
||||
const struct smm_runtime *runtime;
|
||||
};
|
||||
|
||||
/* smm_handler_t is called with arg of smm_module_params pointer. */
|
||||
typedef void asmlinkage (*smm_handler_t)(void *);
|
||||
|
||||
#ifdef __SMM__
|
||||
/* SMM Runtime helpers. */
|
||||
|
||||
/* Entry point for SMM modules. */
|
||||
void smm_handler_start(void *arg, int cpu, const struct smm_runtime *runtime);
|
||||
void asmlinkage smm_handler_start(void *params);
|
||||
|
||||
/* Retrieve SMM save state for a given CPU. WARNING: This does not take into
|
||||
* account CPUs which are configured to not save their state to RAM. */
|
||||
|
||||
@@ -25,30 +25,6 @@
|
||||
#define RMODULE_MAGIC 0xf8fe
|
||||
#define RMODULE_VERSION_1 1
|
||||
|
||||
#define FIELD_ENTRY(x_) ((uint32_t)&x_)
|
||||
#define RMODULE_HEADER(entry_, type_) \
|
||||
{ \
|
||||
.magic = RMODULE_MAGIC, \
|
||||
.version = RMODULE_VERSION_1, \
|
||||
.type = type_, \
|
||||
.payload_begin_offset = FIELD_ENTRY(_payload_begin_offset), \
|
||||
.payload_end_offset = FIELD_ENTRY(_payload_end_offset), \
|
||||
.relocations_begin_offset = \
|
||||
FIELD_ENTRY(_relocations_begin_offset), \
|
||||
.relocations_end_offset = \
|
||||
FIELD_ENTRY(_relocations_end_offset), \
|
||||
.module_link_start_address = \
|
||||
FIELD_ENTRY(_module_link_start_addr), \
|
||||
.module_program_size = FIELD_ENTRY(_module_program_size), \
|
||||
.module_entry_point = FIELD_ENTRY(entry_), \
|
||||
.parameters_begin = FIELD_ENTRY(_module_params_begin), \
|
||||
.parameters_end = FIELD_ENTRY(_module_params_end), \
|
||||
.bss_begin = FIELD_ENTRY(_bss), \
|
||||
.bss_end = FIELD_ENTRY(_ebss), \
|
||||
}
|
||||
|
||||
/* Private data structures below should not be used directly. */
|
||||
|
||||
/* All fields with '_offset' in the name are byte offsets into the flat blob.
|
||||
* The linker and the linker script takes are of assigning the values. */
|
||||
struct rmodule_header {
|
||||
|
||||
+8
-17
@@ -21,6 +21,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <rmodule-defs.h>
|
||||
|
||||
enum {
|
||||
@@ -50,11 +51,6 @@ int rmodule_load_alignment(const struct rmodule *m);
|
||||
int rmodule_calc_region(unsigned int region_alignment, size_t rmodule_size,
|
||||
size_t *region_size, int *load_offset);
|
||||
|
||||
#define DEFINE_RMODULE_HEADER(name_, entry_, type_) \
|
||||
struct rmodule_header name_ \
|
||||
__attribute__ ((section (".module_header"))) = \
|
||||
RMODULE_HEADER(entry_, type_)
|
||||
|
||||
/* Support for loading rmodule stages. This API is only available when
|
||||
* using dynamic cbmem because it uses the dynamic cbmem API to obtain
|
||||
* the backing store region for the stage. */
|
||||
@@ -84,17 +80,12 @@ struct rmodule {
|
||||
void *relocations;
|
||||
};
|
||||
|
||||
/* These are the symbols assumed that every module contains. The linker script
|
||||
* provides these symbols. */
|
||||
extern char _relocations_begin_offset[];
|
||||
extern char _relocations_end_offset[];
|
||||
extern char _payload_end_offset[];
|
||||
extern char _payload_begin_offset[];
|
||||
extern char _bss[];
|
||||
extern char _ebss[];
|
||||
extern char _module_program_size[];
|
||||
extern char _module_link_start_addr[];
|
||||
extern char _module_params_begin[];
|
||||
extern char _module_params_end[];
|
||||
#if IS_ENABLED(CONFIG_RELOCATABLE_MODULES)
|
||||
/* Rmodules have an entry point of named __rmodule_entry. */
|
||||
#define RMODULE_ENTRY(entry_) \
|
||||
void __rmodule_entry(void *) __attribute__((alias (STRINGIFY(entry_))))
|
||||
#else
|
||||
#define RMODULE_ENTRY(entry_)
|
||||
#endif
|
||||
|
||||
#endif /* RMODULE_H */
|
||||
|
||||
@@ -133,17 +133,21 @@ ramstage-y += rmodule.c
|
||||
romstage-$(CONFIG_RELOCATABLE_RAMSTAGE) += rmodule.c
|
||||
|
||||
RMODULE_LDSCRIPT := $(src)/lib/rmodule.ld
|
||||
RMODULE_LDFLAGS := -nostartfiles -shared -z defs -nostdlib -Bsymbolic -T $(RMODULE_LDSCRIPT)
|
||||
RMODULE_LDFLAGS := -nostartfiles -Wl,--emit-relocs -Wl,-z,defs -Wl,-Bsymbolic -Wl,-T,$(RMODULE_LDSCRIPT)
|
||||
|
||||
# rmodule_link_rules is a function that should be called with:
|
||||
# (1) the object name to link
|
||||
# (2) the dependencies
|
||||
# (3) heap size of the relocatable module
|
||||
# It will create the necessary Make rules.
|
||||
# It will create the necessary Make rules to create a rmodule. The resulting
|
||||
# rmdoule is named $(1).rmod
|
||||
define rmodule_link
|
||||
$(strip $(1)): $(strip $(2)) $$(RMODULE_LDSCRIPT) $$(obj)/ldoptions
|
||||
$$(LD) $$(RMODULE_LDFLAGS) --defsym=__heap_size=$(strip $(3)) -o $$@ $(strip $(2))
|
||||
$(strip $(1)): $(strip $(2)) $$(RMODULE_LDSCRIPT) $$(obj)/ldoptions $$(RMODTOOL)
|
||||
$$(CC) $$(CFLAGS) $$(RMODULE_LDFLAGS) -Wl,--defsym=__heap_size=$(strip $(3)) -o $$@ -Wl,--start-group $(strip $(2)) $$(LIBGCC_FILE_NAME) -Wl,--end-group
|
||||
$$(NM) -n $$@ > $$(basename $$@).map
|
||||
|
||||
$(strip $(1)).rmod: $(strip $(1))
|
||||
$$(RMODTOOL) -i $$^ -o $$@
|
||||
endef
|
||||
|
||||
endif
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user