summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2019-07-27 13:41:57 -0700
committerH. Peter Anvin <hpa@zytor.com>2019-07-27 13:41:57 -0700
commitca1a40fe03a578c6c403240afefde71cc003b13f (patch)
tree7e36474cd26bd156faa271fa90f8623b1444825f
parent94163d75874506496da636153fefc672e2f7b75f (diff)
downloadsamples-ca1a40fe03a578c6c403240afefde71cc003b13f.tar.gz
samples-ca1a40fe03a578c6c403240afefde71cc003b13f.tar.xz
samples-ca1a40fe03a578c6c403240afefde71cc003b13f.zip
Add size checks, explain the nature of ___stack_size in .com
-rw-r--r--com.ld19
-rw-r--r--exe.ld4
2 files changed, 12 insertions, 11 deletions
diff --git a/com.ld b/com.ld
index 19c7bb2..069ab41 100644
--- a/com.ld
+++ b/com.ld
@@ -43,6 +43,11 @@ SECTIONS
PROVIDE(___bss_end = .);
}
+ /*
+ * This reflects a maximum possible/needed stack size; note that
+ * the OS may end up providing less than this. The runtime startup
+ * code should check this before clearing _BSS.
+ */
PROVIDE(___stack_size = 65536 + ADDR(DGROUP) - .);
_STACK (NOLOAD) : {
PROVIDE(___stack_base = .);
@@ -51,17 +56,9 @@ SECTIONS
}
PROVIDE(___end = .);
-
- /* For PIE linking */
- .dynamic : AT(___.filesize) {
- PROVIDE(___DYNAMIC = .);
- *(.dynamic)
- }
- .dynsym : { *(.dynsym) }
- .dynstr : { *(.dynstr) }
- .hash : { *(.hash) }
- .gnu.hash : { *(.gnu.hash) }
- .rel.dyn : { *(.rel*) }
+ HIDDEN(.com.size.check =
+ ASSERT(. - ADDR(DGROUP) <= 0x10000,
+ "Error: .com file too large"));
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
diff --git a/exe.ld b/exe.ld
index 9fa387e..f0f950f 100644
--- a/exe.ld
+++ b/exe.ld
@@ -76,6 +76,10 @@ SECTIONS
PROVIDE(___stack_end = .);
}
+ HIDDEN(.dgroup.size.check =
+ ASSERT(. - ADDR(DGROUP) <= 0x10000,
+ "Error: DGROUP too large"));
+
far_BSS ALIGN(16) : {
PROVIDE(___farbss_start = .);
*(SORT_BY_NAME(SORT_BY_ALIGNMENT(?*_BSS*)))