summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2019-08-02 16:09:13 -0700
committerH. Peter Anvin <hpa@zytor.com>2019-08-02 16:28:26 -0700
commit75dd2af89ee60d2e45032b6243d25fbb00992aa0 (patch)
treea2468b0cb0a0f01e7fb36979a3914ed6ae62a66c
parent29a193f82e522eded47c64f4bdbb11878084727f (diff)
downloadsamples-75dd2af89ee60d2e45032b6243d25fbb00992aa0.tar.gz
samples-75dd2af89ee60d2e45032b6243d25fbb00992aa0.tar.xz
samples-75dd2af89ee60d2e45032b6243d25fbb00992aa0.zip
macros.s: handle HUGE sections
Support HUGE sections, via a s.huge declaration macro (like s.group). Add a directive s.huge which declares an upcoming section as HUGE.
-rw-r--r--exe.ld3
-rw-r--r--macros.s83
2 files changed, 69 insertions, 17 deletions
diff --git a/exe.ld b/exe.ld
index 6042606..ad92ce0 100644
--- a/exe.ld
+++ b/exe.ld
@@ -26,6 +26,9 @@ SECTIONS
PROVIDE(___load_addr = .);
}
+ huge_DATA : {
+ *(SORT_BY_NAME(SORT_BY_ALIGNMENT([^.]*_*HUGEDATA*)))
+ }
far_TEXT : {
*(SORT_BY_NAME(SORT_BY_ALIGNMENT([^.]*_TEXT*)))
}
diff --git a/macros.s b/macros.s
index 0f04595..b40ccbc 100644
--- a/macros.s
+++ b/macros.s
@@ -2,28 +2,53 @@
.code16
.macro s.group group, sections:vararg
- .pushsection "!\group", "a"
- .balign 16
+ .ifndef ".L.SEG.!\group"
+ .pushsection "!\group", "a"
+ .balign 16
+ .eqv ".L.SEG.!\group", "!\group"
+ .popsection
+ .endif
.irp sec,\sections
- ".L.SEG.\sec" :
+ .eqv ".L.SEG.\sec", "!\group"
.endr
- .popsection
.endm
+.macro s.huge secs:vararg
+ .irp sec, \secs
+ ".L.HUGE.\sec" = 1
+ .endr
+.endm
+
.macro s.section name:req, subname, opts:vararg
- .ifndef ".L.SEG.\name"
- .section "\name\()!", "a"
- .balign 16
- ".L.SEG.\name" :
+ .ifdef ".L.HUGE.\name"
+ .section "\name\subname", \opts
+ .ifndef ".L.SEG.\name\subname"
+ .balign 16
+ ".L.SEG.\name\subname" :
+ .endif
+ .L.SEG = ".L.SEG.\name\subname"
+ .L.HUGE = 1
+ .else
+ .section "\name\()$\subname", \opts
+ .ifndef ".L.SEG.\name"
+ .pushsection "\name\()!", "a"
+ .balign 16
+ .eqv ".L.SEG.\name", "\name\()!"
+ .popsection
+ .endif
+ .L.SEG = ".L.SEG.\name"
+ .L.HUGE = 0
.endif
- .L.SEG = ".L.SEG.\name"
- .section "\name\()$\subname", \opts
.endm
.macro s.def syms:vararg
.irp sym,\syms
\sym :
- .set "\sym\()!", .L.SEG
+ .if .L.HUGE
+ "\sym\()!" = . - (. - .L.SEG) & 15
+ .else
+ "\sym\()!" = .L.SEG
+ .endif
.endr
.endm
@@ -51,8 +76,7 @@ s.def ___start
/* gas doesn't handle lcall with symbols */
.byte 0x9a
- .word _farfunc
- .reloc .-2, R_386_SUB16, "_farfunc!"
+ .word _farfunc - "_farfunc!"
.word "_farfunc!"@SEG
nop
@@ -82,8 +106,8 @@ s.def ___start
*/
s.globl _get_foo
s.def _get_foo
- mov _foo,%ax /* foo is in our own data segment */
- .reloc .-2, R_386_SUB16, .L.SEG
+ mov _foo - "_foo!",%ax /* foo is in our own data segment */
+ mov "_foo!"@SEG,%ax
mov $_foo,%edx /* linear address */
ret
@@ -95,8 +119,7 @@ s.def _get_foo
s.def _get_cmdline
mov $"__psp!"@SEG,%ax
mov %ax,%es
- mov $__psp + 127,%dx
- .reloc .-2, R_386_SUB16, "__psp!"
+ mov $(__psp - "__psp!") + 127,%dx
ret
s.section _DATA,,"aw"
@@ -118,3 +141,29 @@ s.def _foo2
s.globl _nasa
s.def _nasa
.space 512
+
+ .if 1
+
+ s.huge testme_HUGEDATA
+
+ s.section testme_HUGEDATA,,"aw"
+
+ .globl "_alpha","_alpha!"
+s.def _alpha
+ .fill 0xaaaa,2,0xaaaa
+
+ s.section _BSS,,"aw",@nobits
+ s.globl _esa
+s.def _esa
+ .space 512
+
+ s.section testme_HUGEDATA,,"aw"
+
+s.def _beta
+ .fill 0xbbbb,2,0xbbbb
+
+ .globl "_gamma","_gamma!"
+s.def _gamma
+ .fill 0xcccc,2,0xcccc
+
+ .endif