summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2019-01-10 15:10:32 -0800
committerH. Peter Anvin <hpa@zytor.com>2019-01-10 15:10:32 -0800
commit30153068ec64217828a615ae3ee46888cf2fc72c (patch)
tree5522135447e883f6895c5260d646f6f6a34d724b
parent200ab0a31dfa8382ebb9a4562a164662ce12fa56 (diff)
downloadabi-30153068ec64217828a615ae3ee46888cf2fc72c.tar.gz
abi-30153068ec64217828a615ae3ee46888cf2fc72c.tar.xz
abi-30153068ec64217828a615ae3ee46888cf2fc72c.zip
Simplify the ABI; remove groups, change naming
-rw-r--r--segelf.txt124
1 files changed, 60 insertions, 64 deletions
diff --git a/segelf.txt b/segelf.txt
index fa4defe..0050316 100644
--- a/segelf.txt
+++ b/segelf.txt
@@ -2,7 +2,7 @@ ABI for 16-bit real mode segmented code in ELF
----------------------------------------------
H. Peter Anvin
-Version: 2018-12-22
+Version: 2019-01-10
16-bit segmented code in ELF is implemented with a combination of
three new relocations and a set of software conventions. This document
@@ -71,36 +71,43 @@ A PRIVATE or HUGE segment is represented by a section without any
special attributes. A PRIVATE or HUGE segment section must have an
alignment of 16 or higher.
+NOTE: using PRIVATE segments means subsections cannot be used.
+
A PUBLIC segment is represented as a pair of sections:
- section~b
- section~p
+ section!
+ section$
-"section~b" will contain symbols but no data (see below). "section~p"
-carries the actual contents of the section. The "~b" section must
-have an alignment of 16 or higher, but the "~p" sections MAY have any
+"section!" will contain symbols but no data (see below). "section$"
+carries the actual contents of the section. The "!" section must
+have an alignment of 16 or higher, but the "$" sections MAY have any
alignment.
-Segment groups are simply represented by a "~b" section without a
-corresponding "~p" section.
+Segment groups are handled by bundling ! sections in the linker script.
These sections are named such that sorting the sections by name will
-put all the ~b sections immediately before all the ~p sections for
+put all the ! sections immediately before all the $ sections for
the same segment.
When using subsection variants intended to be merged into the same
-segment, e.g. for merged strings, any appended string should come
-*after* ~[bp] to guarantee the sorting will be done correctly; for
-example:
+segment, e.g. for merged strings, the compiler/assembler needs to EITHER:
+
+a. Combine all symbols into a single ! section, without a suffix.
+
+ _DATA!
+ _DATA$
+ _DATA$.strings
- _DATA~b.strings
- _DATA~p.strings
+b. Add any suffix *after* the ! symbol.
-In the interest of robustness compilers/assemblers should:
+ _DATA!
+ _DATA$
+ _DATA!.strings
+ _DATA$.strings
-a. Emit group ~b sections immediately before the first grouped ~b section;
-b. Emit ~b sections before the corresponding ~p sections, preferably
- immediately before.
+In the interest of robustness compilers/assemblers should emit !
+sections before the first associated $ section, preferably immediately
+before.
2. Symbols
@@ -114,25 +121,23 @@ fashion.
Each symbol is matched with an auxiliary symbol containing the
preferred segment base as a linear address. The name of the auxiliary
-symbol associated with the symbol "foo" is "foo~b". Accordingly, for
+symbol associated with the symbol "foo" is "foo!". Accordingly, for
the example above, with foo at 0x1234:0x5678, we would have:
foo = 0x179b8
- foo~b = 0x12340
+ foo! = 0x12340
For a PRIVATE segment, these auxiliary symbols are simply placed at
the beginning of the section by the compiler/assembler.
-For a PUBLIC segment, they are placed in the ~b section corresponding
-to the segment (however, the primary symbol is placed in the ~p
+For a PUBLIC segment, they are placed in the ! section corresponding
+to the segment (however, the primary symbol is placed in the $
section.)
-For a grouped segment, they are put in the ~b section for the group.
-
-For a HUGE segment, the compiler/assembler should generate the ~b
+For a HUGE segment, the compiler/assembler should generate the !
symbols so that:
- symbol~b = symbol & ~0xf
+ symbol! = symbol & ~0xf
Undefined (external) references to these auxiliary symbols should be
marked WEAK. If the auxiliary symbol would contain the absolute value
@@ -152,12 +157,12 @@ To access a symbol by its preferred segment base:
SEG symbol generates:
- R_386_SEG16 symbol~b
+ R_386_SEG16 symbol!
[symbol] generates:
R_386_16 symbol
- R_386_SUB16 symbol~b
+ R_386_SUB16 symbol!
To access a symbol relative to a different segment base:
@@ -165,14 +170,14 @@ To access a symbol relative to a different segment base:
mov ax,[symbol wrt DGROUP]
R_386_16 symbol
- R_386_SUB16 DGROUP~b
+ R_386_SUB16 section DGROUP! + 0
To access a symbol relative to the segment base of a different symbol:
mov ax,[symbol wrt seg othersymbol]
R_386_16 symbol
- R_386_SUB16 othersymbol~b
+ R_386_SUB16 othersymbol!
To access the absolute linear address of a symbol:
@@ -199,45 +204,36 @@ SECTIONS
{
. = 0;
- _TEXT_far : {
- *(SORT_BY_NAME(SORT_BY_ALIGNMENT(?*_TEXT ?*_TEXT[~.]*)))
+ far_TEXT : {
+ *(SORT_BY_NAME(SORT_BY_ALIGNMENT(?*_TEXT*)))
}
- _DATA_far : {
- *(SORT_BY_NAME(SORT_BY_ALIGNMENT(?*_DATA* ?*_DATA[~.]*)))
+ far_DATA : {
+ *(SORT_BY_NAME(SORT_BY_ALIGNMENT(?*_DATA*)))
}
_TEXT ALIGN(16) : {
- *(_START~b* _TEXT~b*)
- *(SORT_NONE(_START~p*))
- *(SORT_BY_ALIGNMENT(_TEXT~p*))
+ *(_START*!* _TEXT*!*)
+ *(SORT_NONE(_START*))
+ *(SORT_BY_ALIGNMENT(_TEXT*))
}
- /*
- * Note: to unconditionally force references to _DATA,
- * _BSS and _STACK to be relative to DGROUP, one can merge
- * the corresponding ~b sections into DGROUP instead of the
- * normal output sections.
- */
- DGROUP ALIGN(16) : {
- *(DGROUP~b)
- PROVIDE(___bss_start~b = .);
- PROVIDE(___bss_end~b = .);
- PROVIDE(___stack_base~b = .);
- PROVIDE(___stack_top~b = .);
+ DGROUP (NOLOAD) ALIGN(16) : {
+ *(DGROUP*!* _DATA*!* _BSS*!* _STACK*!*)
+ PROVIDE(___bss_start! = .);
+ PROVIDE(___bss_end! = .);
+ PROVIDE(___stack_base! = .);
+ PROVIDE(___stack_top! = .);
}
_DATA : {
- *(_DATA~b*)
- *(SORT_BY_ALIGNMENT(_DATA~p*))
+ *(SORT_BY_ALIGNMENT(_DATA*))
}
PROVIDE(___filesize = .);
_BSS : {
PROVIDE(___bss_start = .);
- *(_BSS~b*)
- *(SORT_BY_ALIGNMENT(_BSS~p*))
- *(COMMON)
+ *(SORT_BY_ALIGNMENT(_BSS*) (COMMON))
PROVIDE(___bss_end = .);
}
@@ -250,9 +246,9 @@ SECTIONS
PROVIDE(___stack_top = .);
}
- _BSS_far ALIGN(16) : {
+ far_BSS ALIGN(16) : {
PROVIDE(___farbss_start = .);
- *(SORT_BY_NAME(SORT_BY_ALIGNMENT(?*_BSS ?*_BSS[~.]*)))
+ *(SORT_BY_NAME(SORT_BY_ALIGNMENT(?*_BSS*)))
. = ALIGN(16);
PROVIDE(___farbss_end = .);
}
@@ -269,27 +265,27 @@ SECTIONS
. = 0;
DGROUP (NOLOAD) : {
- *(*~b*)
- PROVIDE(___bss_start~b = .);
- PROVIDE(___bss_end~b = .);
- PROVIDE(___end~b = .);
+ *(*!*)
+ PROVIDE(___bss_start! = .);
+ PROVIDE(___bss_end! = .);
+ PROVIDE(___end! = .);
}
. = 0x100;
_TEXT : {
- *(SORT_NONE(_START~p*))
- *(SORT_BY_ALIGNMENT(_TEXT~p*))
+ *(SORT_NONE(_START*))
+ *(SORT_BY_ALIGNMENT(_TEXT*))
}
_DATA : {
- *(SORT_BY_ALIGNMENT(_DATA~p*))
+ *(SORT_BY_ALIGNMENT(_DATA*))
}
PROVIDE(___filesize = .);
_BSS : {
PROVIDE(___bss_start = .);
- *(SORT_BY_ALIGNMENT(_BSS~p*))
+ *(SORT_BY_ALIGNMENT(_BSS*))
*(COMMON)
PROVIDE(___bss_end = .);
}