Index: mainboard/adl/msm800sev/initram.c
===================================================================
--- mainboard/adl/msm800sev/initram.c	(revision 516)
+++ mainboard/adl/msm800sev/initram.c	(working copy)
@@ -18,6 +18,7 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
+#define _MAINOBJECT
 #include <types.h>
 #include <lib.h>
 #include <console.h>
Index: mainboard/adl/msm800sev/Makefile
===================================================================
--- mainboard/adl/msm800sev/Makefile	(revision 516)
+++ mainboard/adl/msm800sev/Makefile	(working copy)
@@ -32,24 +32,11 @@
 		$(obj)/southbridge/amd/cs5536/smbus_initram.o \
 		$(obj)/arch/x86/geodelx/geodelx.o
 
-# Next Quest: Make a single rule out of those:
-$(obj)/mainboard/$(MAINBOARDDIR)/initram.o: $(src)/mainboard/$(MAINBOARDDIR)/initram.c
-	$(Q)$(CC) $(INITCFLAGS) -D_SHARED -D_MAINOBJECT -fPIE -c $< -o $@
-$(obj)/northbridge/amd/geodelx/raminit.o: $(src)/northbridge/amd/geodelx/raminit.c
-	$(Q)mkdir -p $(dir $@)
-	$(Q)$(CC) $(INITCFLAGS) -D_SHARED -fPIE -c $< -o $@
-$(obj)/southbridge/amd/cs5536/smbus_initram.o: $(src)/southbridge/amd/cs5536/smbus_initram.c
-	$(Q)mkdir -p $(dir $@)
-	$(Q)$(CC) $(INITCFLAGS) -D_SHARED -fPIE -c $< -o $@
-$(obj)/arch/x86/geodelx/geodelx.o: $(src)/arch/x86/geodelx/geodelx.c
-	$(Q)mkdir -p $(dir $@)
-	$(Q)$(CC) $(INITCFLAGS) -D_SHARED -fPIE -c $< -o $@
-
-$(obj)/linuxbios.initram $(obj)/linuxbios.initram.map: $(obj)/stage0.init $(obj)/stage0-prefixed.o $(INITRAM_OBJ)
+$(obj)/linuxbios.initram $(obj)/linuxbios.initram.map: $(obj)/stage0.init $(obj)/stage0-prefixed.o $(patsubst %.o,%_xip.o,$(INITRAM_OBJ))
 	$(Q)# initram links against stage0
 	$(Q)printf "  LD      $(subst $(shell pwd)/,,$(@))\n"
 	$(Q)$(LD) --entry main -N -R $(obj)/stage0-prefixed.o \
-		$(INITRAM_OBJ) -o $(obj)/linuxbios.initram.o
+		$(patsubst %.o,%_xip.o,$(INITRAM_OBJ)) -o $(obj)/linuxbios.initram.o
 	$(Q)printf "  OBJCOPY $(subst $(shell pwd)/,,$(@))\n"
 	$(Q)$(OBJCOPY) -O binary $(obj)/linuxbios.initram.o \
 		$(obj)/linuxbios.initram
Index: mainboard/amd/norwich/initram.c
===================================================================
--- mainboard/amd/norwich/initram.c	(revision 516)
+++ mainboard/amd/norwich/initram.c	(working copy)
@@ -18,6 +18,8 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
+#define _MAINOBJECT
+
 #include <types.h>
 #include <lib.h>
 #include <console.h>
Index: mainboard/amd/norwich/Makefile
===================================================================
--- mainboard/amd/norwich/Makefile	(revision 516)
+++ mainboard/amd/norwich/Makefile	(working copy)
@@ -26,30 +26,17 @@
 		$(obj)/southbridge/amd/cs5536/smbus_initram.o \
 		$(obj)/arch/x86/geodelx/geodelx.o
 
-# Next Quest: Make a single rule out of those:
-$(obj)/mainboard/$(MAINBOARDDIR)/initram.o: $(src)/mainboard/$(MAINBOARDDIR)/initram.c
-	$(Q)$(CC) $(INITCFLAGS) -D_SHARED -D_MAINOBJECT -fPIE -c $< -o $@
-$(obj)/northbridge/amd/geodelx/raminit.o: $(src)/northbridge/amd/geodelx/raminit.c
-	$(Q)mkdir -p $(dir $@)
-	$(Q)$(CC) $(INITCFLAGS) -D_SHARED -fPIE -c $< -o $@
-$(obj)/southbridge/amd/cs5536/smbus_initram.o: $(src)/southbridge/amd/cs5536/smbus_initram.c
-	$(Q)mkdir -p $(dir $@)
-	$(Q)$(CC) $(INITCFLAGS) -D_SHARED -fPIE -c $< -o $@
-$(obj)/arch/x86/geodelx/geodelx.o: $(src)/arch/x86/geodelx/geodelx.c
-	$(Q)mkdir -p $(dir $@)
-	$(Q)$(CC) $(INITCFLAGS) -D_SHARED -fPIE -c $< -o $@
-
 STAGE2_MAINBOARD_OBJ = 
 
 $(obj)/linuxbios.vpd:
 	$(Q)printf "  BUILD   DUMMY VPD\n"
 	$(Q)dd if=/dev/zero of=$(obj)/linuxbios.vpd bs=256 count=1 $(SILENT)
 
-$(obj)/linuxbios.initram $(obj)/linuxbios.initram.map: $(obj)/stage0.init $(obj)/stage0-prefixed.o $(INITRAM_OBJ)
+$(obj)/linuxbios.initram $(obj)/linuxbios.initram.map: $(obj)/stage0.init $(obj)/stage0-prefixed.o $(patsubst %.o,%_xip.o,$(INITRAM_OBJ))
 	$(Q)# initram links against stage0
 	$(Q)printf "  LD      $(subst $(shell pwd)/,,$(@))\n"
 	$(Q)$(LD) --entry main -N -R $(obj)/stage0-prefixed.o \
-		$(INITRAM_OBJ) -o $(obj)/linuxbios.initram.o
+		$(patsubst %.o,%_xip.o,$(INITRAM_OBJ)) -o $(obj)/linuxbios.initram.o
 	$(Q)printf "  OBJCOPY $(subst $(shell pwd)/,,$(@))\n"
 	$(Q)$(OBJCOPY) -O binary $(obj)/linuxbios.initram.o \
 		$(obj)/linuxbios.initram
Index: mainboard/artecgroup/dbe61/initram.c
===================================================================
--- mainboard/artecgroup/dbe61/initram.c	(revision 516)
+++ mainboard/artecgroup/dbe61/initram.c	(working copy)
@@ -18,6 +18,7 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
+#define _MAINOBJECT
 #include <types.h>
 #include <lib.h>
 #include <console.h>
Index: mainboard/artecgroup/dbe61/Makefile
===================================================================
--- mainboard/artecgroup/dbe61/Makefile	(revision 516)
+++ mainboard/artecgroup/dbe61/Makefile	(working copy)
@@ -30,24 +30,11 @@
 INITRAM_OBJ =   $(obj)/mainboard/$(MAINBOARDDIR)/initram.o \
 		$(obj)/arch/x86/geodelx/geodelx.o
 
-# Next Quest: Make a single rule out of those:
-$(obj)/mainboard/$(MAINBOARDDIR)/initram.o: $(src)/mainboard/$(MAINBOARDDIR)/initram.c
-	$(Q)$(CC) $(INITCFLAGS) -D_SHARED -D_MAINOBJECT -fPIE -c $< -o $@
-$(obj)/northbridge/amd/geodelx/raminit.o: $(src)/northbridge/amd/geodelx/raminit.c
-	$(Q)mkdir -p $(dir $@)
-	$(Q)$(CC) $(INITCFLAGS) -D_SHARED -fPIE -c $< -o $@
-$(obj)/southbridge/amd/cs5536/smbus_initram.o: $(src)/southbridge/amd/cs5536/smbus_initram.c
-	$(Q)mkdir -p $(dir $@)
-	$(Q)$(CC) $(INITCFLAGS) -D_SHARED -fPIE -c $< -o $@
-$(obj)/arch/x86/geodelx/geodelx.o: $(src)/arch/x86/geodelx/geodelx.c
-	$(Q)mkdir -p $(dir $@)
-	$(Q)$(CC) $(INITCFLAGS) -D_SHARED -fPIE -c $< -o $@
-
-$(obj)/linuxbios.initram $(obj)/linuxbios.initram.map: $(obj)/stage0.init $(obj)/stage0-prefixed.o $(INITRAM_OBJ)
+$(obj)/linuxbios.initram $(obj)/linuxbios.initram.map: $(obj)/stage0.init $(obj)/stage0-prefixed.o $(patsubst %.o,%_xip.o,$(INITRAM_OBJ))
 	$(Q)# initram links against stage0
 	$(Q)printf "  LD      $(subst $(shell pwd)/,,$(@))\n"
 	$(Q)$(LD) --entry main -N -R $(obj)/stage0-prefixed.o \
-		$(INITRAM_OBJ) -o $(obj)/linuxbios.initram.o
+		$(patsubst %.o,%_xip.o,$(INITRAM_OBJ)) -o $(obj)/linuxbios.initram.o
 	$(Q)printf "  OBJCOPY $(subst $(shell pwd)/,,$(@))\n"
 	$(Q)$(OBJCOPY) -O binary $(obj)/linuxbios.initram.o \
 		$(obj)/linuxbios.initram
Index: mainboard/emulation/qemu-x86/initram.c
===================================================================
--- mainboard/emulation/qemu-x86/initram.c	(revision 516)
+++ mainboard/emulation/qemu-x86/initram.c	(working copy)
@@ -17,6 +17,7 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
+#define _MAINOBJECT
 #include <console.h>
 
 int main(void)
Index: mainboard/emulation/qemu-x86/Makefile
===================================================================
--- mainboard/emulation/qemu-x86/Makefile	(revision 516)
+++ mainboard/emulation/qemu-x86/Makefile	(working copy)
@@ -42,14 +42,11 @@
 
 INITRAM_OBJ = $(obj)/mainboard/$(MAINBOARDDIR)/initram.o
 
-$(obj)/mainboard/$(MAINBOARDDIR)/initram.o: $(src)/mainboard/$(MAINBOARDDIR)/initram.c
-	$(Q)$(CC) $(INITCFLAGS) -D_SHARED -D_MAINOBJECT -fPIE -c $< -o $@
-
-$(obj)/linuxbios.initram $(obj)/linuxbios.initram.map: $(obj)/stage0.init $(obj)/stage0-prefixed.o $(INITRAM_OBJ)
+$(obj)/linuxbios.initram $(obj)/linuxbios.initram.map: $(obj)/stage0.init $(obj)/stage0-prefixed.o $(patsubst %.o,%_xip.o,$(INITRAM_OBJ))
 	$(Q)# initram links against stage0
 	$(Q)printf "  LD      $(subst $(shell pwd)/,,$(@))\n"
 	$(Q)$(LD) --entry main -N -R $(obj)/stage0-prefixed.o \
-		$(INITRAM_OBJ) -o $(obj)/linuxbios.initram.o
+		$(patsubst %.o,%_xip.o,$(INITRAM_OBJ)) -o $(obj)/linuxbios.initram.o
 	$(Q)printf "  OBJCOPY $(subst $(shell pwd)/,,$(@))\n"
 	$(Q)$(OBJCOPY) -O binary $(obj)/linuxbios.initram.o \
 		$(obj)/linuxbios.initram
Index: Rules.make
===================================================================
--- Rules.make	(revision 516)
+++ Rules.make	(working copy)
@@ -78,3 +78,13 @@
 	$(Q)printf "  CC      $(subst $(shell pwd)/,,$(@))\n"
 	$(Q)$(CC) $(INITCFLAGS) -c $< -o $@
 
+#
+# ram initialization code can not be linked at a specific address,
+# hence it has to be executed in place position independently.
+#
+
+$(obj)/%_xip.o: $(src)/%.c
+	$(Q)mkdir -p $(dir $@)
+	$(Q)printf "  CC      $(subst $(shell pwd)/,,$(@)) (XIP)\n"
+	$(Q)$(CC) $(INITCFLAGS) -D_SHARED -fPIE -c $< -o $@
+
