summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2019-07-29 17:41:28 -0700
committerH. Peter Anvin <hpa@zytor.com>2019-07-29 17:41:28 -0700
commit29a193f82e522eded47c64f4bdbb11878084727f (patch)
tree537cd0e9fee2f2a9cedc4e37418b6a383165cc78
parentf6cd2be083fa6bc254009a3f67bd93a6e9b40390 (diff)
downloadsamples-29a193f82e522eded47c64f4bdbb11878084727f.tar.gz
samples-29a193f82e522eded47c64f4bdbb11878084727f.tar.xz
samples-29a193f82e522eded47c64f4bdbb11878084727f.zip
With my most recent patch, gas can now generate SEG16 relocations
Switch to @SEG syntax, removing the first set of .reloc hacks.
-rw-r--r--com.ld16
-rw-r--r--exe.ld13
-rw-r--r--macros.s12
3 files changed, 29 insertions, 12 deletions
diff --git a/com.ld b/com.ld
index 129a060..f56f8ad 100644
--- a/com.ld
+++ b/com.ld
@@ -7,18 +7,28 @@ SECTIONS
DGROUP (NOLOAD) : {
*(*!*)
+ PROVIDE(___load_addr! = .);
PROVIDE(___start! = .);
- PROVIDE(__psp! = .);
+ PROVIDE(___psp! = .);
PROVIDE(___bss_start! = .);
PROVIDE(___bss_end! = .);
PROVIDE(___end! = .);
}
_PSP (NOLOAD) : {
- PROVIDE(__psp = .);
+ PROVIDE(___psp = .);
/* May have additional symbols provided by the runtime */
KEEP(*(_PSP));
- . = __psp + 256;
+ }
+
+ . = 256;
+
+ /*
+ * Dummy section just to provide convenience symbols for the
+ * initial load address
+ */
+ _BEGIN (NOLOAD) : {
+ PROVIDE(___load_addr = .);
}
_TEXT : {
diff --git a/exe.ld b/exe.ld
index 90e76da..6042606 100644
--- a/exe.ld
+++ b/exe.ld
@@ -9,14 +9,23 @@ SECTIONS
* PSP is functionally at a negative offset.
*/
_PSP -256 (NOLOAD) : {
- PROVIDE(__psp! = .);
- PROVIDE(__psp = .);
+ PROVIDE(___psp! = .);
+ PROVIDE(___psp = .);
/* The runtime may provide a better definition of the PSP */
KEEP(*(_PSP));
}
. = 0;
+ /*
+ * Dummy section just to provide convenience symbols for the
+ * initial load address
+ */
+ _BEGIN (NOLOAD) : {
+ PROVIDE(___load_addr! = .);
+ PROVIDE(___load_addr = .);
+ }
+
far_TEXT : {
*(SORT_BY_NAME(SORT_BY_ALIGNMENT([^.]*_TEXT*)))
}
diff --git a/macros.s b/macros.s
index 869701d..0f04595 100644
--- a/macros.s
+++ b/macros.s
@@ -1,3 +1,4 @@
+/* -*- asm -*- */
.code16
.macro s.group group, sections:vararg
@@ -45,16 +46,14 @@ s.def _farfunc /* Far function */
s.globl ___start
s.def ___start
- mov $0,%ax
- .reloc .-2, R_386_SEG16, .L.SEG
+ mov $"___load_addr!"@SEG, %ax
mov %ax,%ds
/* gas doesn't handle lcall with symbols */
.byte 0x9a
.word _farfunc
.reloc .-2, R_386_SUB16, "_farfunc!"
- .word 0
- .reloc .-2, R_386_SEG16, "_farfunc!"
+ .word "_farfunc!"@SEG
nop
nop
@@ -85,7 +84,7 @@ s.def ___start
s.def _get_foo
mov _foo,%ax /* foo is in our own data segment */
.reloc .-2, R_386_SUB16, .L.SEG
- mov $_foo,%edx
+ mov $_foo,%edx /* linear address */
ret
/*
@@ -94,8 +93,7 @@ s.def _get_foo
*/
s.globl _get_cmdline
s.def _get_cmdline
- mov $0,%ax
- .reloc .-2, R_386_SEG16, "__psp!"
+ mov $"__psp!"@SEG,%ax
mov %ax,%es
mov $__psp + 127,%dx
.reloc .-2, R_386_SUB16, "__psp!"