lib: Remove heap from rmodules

No rmodule was using heap.

Change-Id: I0bc049a5231dabbec1c962a99ef875eddcc4ac6e
Signed-off-by: Arthur Heymans <arthur@aheymans.xyz>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/80733
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
diff --git a/src/cpu/x86/Makefile.mk b/src/cpu/x86/Makefile.mk
index 9e9b837..26e5d9c 100644
--- a/src/cpu/x86/Makefile.mk
+++ b/src/cpu/x86/Makefile.mk
@@ -59,7 +59,7 @@
 $(SIPI_DOTO): $(call src-to-obj,rmodules_$(ARCH-$(TARGET_STAGE)-y),src/cpu/x86/sipi_vector.S)
 	$(LD_rmodules_$(ARCH-$(TARGET_STAGE)-y)) -nostdlib -r -o $@ $^
 
-$(eval $(call rmodule_link,$(SIPI_ELF), $(SIPI_DOTO), 0,$(ARCH-$(TARGET_STAGE)-y)))
+$(eval $(call rmodule_link,$(SIPI_ELF), $(SIPI_DOTO),$(ARCH-$(TARGET_STAGE)-y)))
 
 $(SIPI_BIN): $(SIPI_RMOD)
 	$(OBJCOPY_$(TARGET_STAGE)) -O binary $< $@
diff --git a/src/cpu/x86/smm/Makefile.mk b/src/cpu/x86/smm/Makefile.mk
index dbe9c75..33b24a8 100644
--- a/src/cpu/x86/smm/Makefile.mk
+++ b/src/cpu/x86/smm/Makefile.mk
@@ -49,11 +49,10 @@
 $(obj)/smmstub/smmstub.o: $$(smmstub-objs) $(COMPILER_RT_smmstub)
 	$(LD_smmstub) -nostdlib -r -o $@ $(COMPILER_RT_FLAGS_smmstub) --whole-archive --start-group $(smmstub-objs) --no-whole-archive $(COMPILER_RT_smmstub) --end-group
 
-# Link the SMM stub module with a 0-byte heap.
 ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32),y)
-$(eval $(call rmodule_link,$(obj)/smmstub/smmstub.elf, $(obj)/smmstub/smmstub.o, 0,x86_32))
+$(eval $(call rmodule_link,$(obj)/smmstub/smmstub.elf, $(obj)/smmstub/smmstub.o,x86_32))
 else
-$(eval $(call rmodule_link,$(obj)/smmstub/smmstub.elf, $(obj)/smmstub/smmstub.o, 0,x86_64))
+$(eval $(call rmodule_link,$(obj)/smmstub/smmstub.elf, $(obj)/smmstub/smmstub.o,x86_64))
 endif
 
 $(obj)/smmstub/smmstub: $(obj)/smmstub/smmstub.elf.rmod
@@ -66,9 +65,9 @@
 # C-based SMM handler.
 
 ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32),y)
-$(eval $(call rmodule_link,$(obj)/smm/smm.elf, $(obj)/smm/smm.o, 0,x86_32))
+$(eval $(call rmodule_link,$(obj)/smm/smm.elf, $(obj)/smm/smm.o,x86_32))
 else
-$(eval $(call rmodule_link,$(obj)/smm/smm.elf, $(obj)/smm/smm.o, 0,x86_64))
+$(eval $(call rmodule_link,$(obj)/smm/smm.elf, $(obj)/smm/smm.o,x86_64))
 endif
 
 $(obj)/smm/smm: $(obj)/smm/smm.elf.rmod
diff --git a/src/include/rules.h b/src/include/rules.h
index 04b0a82..1005058 100644
--- a/src/include/rules.h
+++ b/src/include/rules.h
@@ -282,8 +282,8 @@
  * arch/x86/car.ld */
 #define ENV_SEPARATE_DATA_AND_BSS	(ENV_CACHE_AS_RAM && (ENV_BOOTBLOCK || !CONFIG(NO_XIP_EARLY_STAGES)))
 
-/* Currently rmodules and ramstage have heap. */
-#define ENV_HAS_HEAP_SECTION	(ENV_RMODULE || ENV_RAMSTAGE)
+/* Currently ramstage has heap. */
+#define ENV_HAS_HEAP_SECTION	ENV_RAMSTAGE
 
 /* Set USER_SPACE in the makefile for the rare code that runs in userspace */
 #if defined(__USER_SPACE__)
diff --git a/src/lib/Makefile.mk b/src/lib/Makefile.mk
index fe24156..e22fd08 100644
--- a/src/lib/Makefile.mk
+++ b/src/lib/Makefile.mk
@@ -310,14 +310,13 @@
 # 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
-# (4) arch for which the rmodules are to be linked
+# (3) arch for which the rmodules are to be linked
 # 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)) $$(COMPILER_RT_rmodules_$(4)) $(call src-to-obj,rmodules_$(4),src/lib/rmodule.ld) | $$(RMODTOOL)
-	$$(LD_rmodules_$(4)) $$(LDFLAGS_rmodules_$(4)) $(RMODULE_LDFLAGS) $($(1)-ldflags) -T $(call src-to-obj,rmodules_$(4),src/lib/rmodule.ld) --defsym=__heap_size=$(strip $(3)) -o $$@ --whole-archive --start-group $(filter-out %.ld,$(2)) --end-group
-	$$(NM_rmodules_$(4)) -n $$@ > $$(basename $$@).map
+$(strip $(1)): $(strip $(2)) $$(COMPILER_RT_rmodules_$(3)) $(call src-to-obj,rmodules_$(3),src/lib/rmodule.ld) | $$(RMODTOOL)
+	$$(LD_rmodules_$(3)) $$(LDFLAGS_rmodules_$(3)) $(RMODULE_LDFLAGS) $($(1)-ldflags) -T $(call src-to-obj,rmodules_$(3),src/lib/rmodule.ld) -o $$@ --whole-archive --start-group $(filter-out %.ld,$(2)) --end-group
+	$$(NM_rmodules_$(3)) -n $$@ > $$(basename $$@).map
 endef
 
 endif
diff --git a/src/lib/program.ld b/src/lib/program.ld
index 68bcab6..21f4be8 100644
--- a/src/lib/program.ld
+++ b/src/lib/program.ld
@@ -134,7 +134,7 @@
 .heap . : {
 	. = ALIGN(ARCH_POINTER_ALIGN_SIZE);
 	_heap = .;
-	. += (ENV_RMODULE ? __heap_size : CONFIG_HEAP_SIZE);
+	. += CONFIG_HEAP_SIZE;
 	. = ALIGN(ARCH_POINTER_ALIGN_SIZE);
 	_eheap = .;
 	RECORD_SIZE(heap)