|
1 | | -# openkal Specification, version 0.22 |
| 1 | +# openkal Specification, version 0.23 |
2 | 2 |
|
3 | 3 | ## 1. Scope |
4 | 4 |
|
@@ -92,7 +92,7 @@ provides an interface in whole or not at all. |
92 | 92 |
|
93 | 93 | Version 0.15 specifies the core and optional interfaces, version 0.18 adds |
94 | 94 | `openkal.map` (clause 11, entry 40), and version 0.20 adds `openkal.region`, |
95 | | -`openkal.prof` and `openkal.debug` (entries 44 and 45); versions 0.21 and 0.22 add no interface. The reserved row is not specified, and its |
| 95 | +`openkal.prof` and `openkal.debug` (entries 44 and 45); versions 0.21 to 0.23 add no interface. The reserved row is not specified, and its |
96 | 96 | name shall not be used for other purposes. |
97 | 97 |
|
98 | 98 | The S, L and X columns state which boundaries an interface's declarations can |
@@ -1920,6 +1920,35 @@ The following are recorded so that they are not mistaken for oversights. |
1920 | 1920 | writes the device itself is served by its C library without the |
1921 | 1921 | environment. It is a position and not required, because an environment |
1922 | 1922 | that starts no programs has nothing to give it to. |
| 1923 | +48. **An image placed at its base.** **Specified in 0.23**, as |
| 1924 | + `kal_exec_alloc_at` and `KAL_EXEC_PROP_PLACE` in `openkal.exec` |
| 1925 | + (`exec.h`), with the placement note (clause 12.4, version 1.1) and its use |
| 1926 | + by a loader (clause 12.3). An image is position-independent (12.2), so a |
| 1927 | + loader wrote, on every start, each address its relative relocations |
| 1928 | + compute: measured for a language server's image, 164 000 relocations over |
| 1929 | + two mebibytes of read-only-after-relocation data, made resident in each of |
| 1930 | + the 176 programs a build of its modules starts --- about 900 page faults a |
| 1931 | + program more than the same server built for its environment at one |
| 1932 | + address, which on a virtual machine of a continuous-integration service |
| 1933 | + cost a fifth of the build's processor time. An image computed once for one |
| 1934 | + base and placed there is the file's pages, as such a program is. The |
| 1935 | + reservation at an address is an operation and not a hint to |
| 1936 | + `kal_exec_alloc`, because a loader that is refused must know it before it |
| 1937 | + writes anything; it is a position, because an environment may decide where |
| 1938 | + every program's memory lies; and the address is the image's, chosen when it |
| 1939 | + is sealed, not the environment's. |
| 1940 | +49. **A name with every link followed.** **Specified in 0.23**, as |
| 1941 | + `kal_fs_resolved_name` and `KAL_FS_PROP_RESOLVED_NAME` in `openkal.fs` |
| 1942 | + (`fs.h`). A C library's `realpath` asked about each component of a name in |
| 1943 | + turn whether it is a link: measured in a language server's session run as |
| 1944 | + an image, half a million enquiries, where the program of its environment |
| 1945 | + asked the environment once for each file it opened (`/proc/self/fd` on one |
| 1946 | + system, `F_GETPATH` on another). Every environment that keeps links answers |
| 1947 | + the question for a name it has resolved, and nothing above it can compose |
| 1948 | + the enquiries into one. The name is absolute and in the environment's |
| 1949 | + spelling, as `kal_env_image` states one: a C library maps it onto its own |
| 1950 | + names as it maps that one. It is a position of the volume, as the other |
| 1951 | + operations of names are. |
1923 | 1952 |
|
1924 | 1953 | ## 12. Images |
1925 | 1954 |
|
@@ -2000,6 +2029,19 @@ zero, where the image's bytes are not a file's at a multiple of |
2000 | 2029 | `KAL_MAP_ALIGNMENT` (an image a program carries in its own bytes), and where a |
2001 | 2030 | relocation writes the segment. |
2002 | 2031 |
|
| 2032 | +Where the implementation sets `KAL_EXEC_PROP_PLACE` (version 0.23) and the image |
| 2033 | +carries a placement note (12.4), a loader asks for the image's span at the |
| 2034 | +note's base (`kal_exec_alloc_at`). Given it, the loader takes each stored |
| 2035 | +segment's bytes instead of the file's and applies only the relocations that |
| 2036 | +name a symbol: a part of a stored segment that is read-only after relocation |
| 2037 | +(the image's `PT_GNU_RELRO`) and that no such relocation writes is the file's |
| 2038 | +bytes (`kal_exec_map_part`) where `KAL_EXEC_PROP_FILE` is set, and the rest is |
| 2039 | +copied. Refused, or where the position is zero, the loader reserves the span |
| 2040 | +anywhere and relocates the file's segments as before. The program observes the |
| 2041 | +same memory either way; what differs is that a program placed at its base writes |
| 2042 | +no address its relative relocations compute, as a program of its environment |
| 2043 | +linked for one address does not. |
| 2044 | + |
2003 | 2045 | Where an environment's own convention differs from the image's --- on x86-64, |
2004 | 2046 | one environment passes arguments in other registers --- the loader presents each |
2005 | 2047 | entry in the image's convention, and a function the image passes to the |
@@ -2030,8 +2072,11 @@ An image carries notes whose owner is `OPENKAL`, in a section `.note.openkal`: |
2030 | 2072 | | --- | --- | |
2031 | 2073 | | 1, requirements | `kal_u32` major and `kal_u32` minor version of this clause (1 and 0), then a `kal_u64` of `KAL_IFACE_*` positions: **the interfaces the image requires**, derived from the names it imports other than weakly | |
2032 | 2074 | | 2, signature | 32 bytes of an Ed25519 public key, then 64 bytes of the signature, over the whole file with these 96 bytes read as zero | |
| 2075 | +| 3, placement | a `kal_u64` base, a multiple of 65536; a `kal_u32` count and a `kal_u32` zero; then, for each of `count` writable loadable segments that have bytes in the file, in ascending order of address, three `kal_u64`: the segment's address in the image, the file offset of its stored bytes, congruent to that address modulo 65536, and their length, the segment's size in the file. The stored bytes are the segment's file bytes with each relative relocation, and each of the packed relative form, applied for `base`; a relocation that names a symbol is not applied. Version 1.1 of this clause | |
2033 | 2076 |
|
2034 | | -The first is required and the second is not. A loader compares the required interfaces with `kal_interfaces` and |
| 2077 | +The first is required and the others are not. A count of zero states no |
| 2078 | +placement, and a loader reads a placement note only after the requirements note |
| 2079 | +states version 1.1 or higher. A loader compares the required interfaces with `kal_interfaces` and |
2035 | 2080 | refuses to load an image that requires one the implementation does not provide, |
2036 | 2081 | naming the interface. That is clause 6.1 in this arrangement: the loader binds |
2037 | 2082 | at load what a linker binds at link, so it reports at load what a linker reports |
|
0 commit comments