linking: lay the groundwork for a unified linking approach

Though coreboot started as x86 only, the current approach to x86
linking is out of the norm with respect to other architectures.
To start alleviating that the way ramstage is linked is partially
unified. A new file, program.ld, was added to provide a common way
to link stages by deferring to per-stage architectural overrides.
The previous ramstage.ld is no longer required.

Note that this change doesn't handle RELOCATABLE_RAMSTAGE
because that is handled by rmodule.ld. Future convergence
can be achieved, but for the time being that's being left out.

BUG=chrome-os-partner:44827
BRANCH=None
TEST=Built a myriad of boards.

Change-Id: I5d689bfa7e0e9aff3a148178515ef241b5f70661
Signed-off-by: Aaron Durbin <adubin@chromium.org>
Reviewed-on: http://review.coreboot.org/11507
Tested-by: build bot (Jenkins)
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
Tested-by: Raptor Engineering Automated Test Stand <noreply@raptorengineeringinc.com>
Reviewed-by: Julius Werner <jwerner@chromium.org>
diff --git a/src/include/memlayout.h b/src/include/memlayout.h
index a529628..f0ee3d3 100644
--- a/src/include/memlayout.h
+++ b/src/include/memlayout.h
@@ -22,10 +22,37 @@
 #ifndef __MEMLAYOUT_H
 #define __MEMLAYOUT_H
 
+#include <rules.h>
 #include <arch/memlayout.h>
 
+/* Macros that the architecture can override. */
+#ifndef ARCH_POINTER_ALIGN_SIZE
+#define ARCH_POINTER_ALIGN_SIZE 8
+#endif
+
+#ifndef ARCH_CACHELINE_ALIGN_SIZE
+#define ARCH_CACHELINE_ALIGN_SIZE 64
+#endif
+
+/* Default to data as well as bss. */
+#ifndef ARCH_STAGE_HAS_DATA_SECTION
+#define ARCH_STAGE_HAS_DATA_SECTION 1
+#endif
+
+#ifndef ARCH_STAGE_HAS_BSS_SECTION
+#define ARCH_STAGE_HAS_BSS_SECTION 1
+#endif
+
+/* Default is that currently ramstage and smm only has a heap. */
+#ifndef ARCH_STAGE_HAS_HEAP_SECTION
+#define ARCH_STAGE_HAS_HEAP_SECTION (ENV_RAMSTAGE || ENV_SMM)
+#endif
+
 #define STR(x) #x
 
+#define ALIGN_COUNTER(align) \
+	. = ALIGN(align);
+
 #define SET_COUNTER(name, addr) \
 	_ = ASSERT(. <= addr, STR(name overlaps the previous region!)); \
 	. = addr;
@@ -58,7 +85,7 @@
 
 /* TODO: This only works if you never access CBFS in romstage before RAM is up!
  * If you need to change that assumption, you have some work ahead of you... */
-#if defined(__PRE_RAM__) && !defined(__ROMSTAGE__)
+#if defined(__PRE_RAM__) && !ENV_ROMSTAGE
 	#define PRERAM_CBFS_CACHE(addr, size) CBFS_CACHE(addr, size)
 	#define POSTRAM_CBFS_CACHE(addr, size) \
 		REGION(unused_cbfs_cache, addr, size, 4)
@@ -93,12 +120,12 @@
 		. += sz;
 #endif
 
-#ifdef __RAMSTAGE__
+#if ENV_RAMSTAGE
 	#define RAMSTAGE(addr, sz) \
 		SET_COUNTER(ramstage, addr) \
-		_ = ASSERT(_eramstage - _ramstage <= sz, \
+		_ = ASSERT(_eprogram - _program <= sz, \
 			STR(Ramstage exceeded its allotted size! (sz))); \
-		INCLUDE "lib/ramstage.ramstage.ld"
+		INCLUDE "lib/program.ramstage.ld"
 #else
 	#define RAMSTAGE(addr, sz) \
 		SET_COUNTER(ramstage, addr) \