Skip to content

Commit ea16ade

Browse files
committed
Fix formatting
1 parent c741bc4 commit ea16ade

File tree

1 file changed

+84
-34
lines changed

1 file changed

+84
-34
lines changed

Linking.md

Lines changed: 84 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -790,33 +790,61 @@ Symbol kinds marked with `*` are considered *primary*.
790790
| `<labeluse>` | Byte offest to label | `method` is either `codeseg` or `*sec` |
791791

792792
- `symbol` describes the symbol against which to perform relocation.
793-
- For `funcsec` relocation method, this is the function id, so that if the addend is zero, the relocation points to the first instruction of that function.
794-
- For `datasec` relocation method, this is the data segment id, so that if the addend is zero, the relocation points to the first byte of data in that segment.
795-
- For `customsec` relocation method, this is the name of the custom section, so that if the addend is zero, the relocation points to the first byte of data in that segment.
796-
- For other relocation methods, this denotes the symbol in the scope of that symbol kind.
797-
798-
The relocation type is looked up from the combination of `format`, `method`, and `modifier`. If no relocation type exists, an error is raised.
799-
800-
If a component of a relocation is predetermined, it must be skipped in the annotation text.
801-
If a component of a relocation is defaulted, it may be skipped in the annotation text.
802-
For example, a relocation into the function table by the index of `$foo` with a predetermined `format` would look like following:
793+
- For `funcsec` relocation method, this is the function id, so that if the
794+
addend is zero, the relocation points to the first instruction of that
795+
function.
796+
- For `datasec` relocation method, this is the data segment id, so that if
797+
the addend is zero, the relocation points to the first byte of data in that
798+
segment.
799+
- For `customsec` relocation method, this is the name of the custom section,
800+
so that if the addend is zero, the relocation points to the first byte of
801+
data in that segment.
802+
- For other relocation methods, this denotes the symbol in the scope of that
803+
symbol kind.
804+
805+
The relocation type is looked up from the combination of `format`, `method`,
806+
and `modifier`. If no relocation type exists, an error is raised.
807+
808+
If a component of a relocation is predetermined, it must be skipped in the
809+
annotation text.
810+
811+
If a component of a relocation is defaulted, it may be skipped in the
812+
annotation text.
813+
814+
For example, a relocation into the function table by the index of `$foo` with a
815+
predetermined `format` would look like following:
803816
```wat
804817
(@reloc functable $foo)
805818
```
806-
If all components of a relocation annotation are skipped, the annotation may be omitted.
819+
If all components of a relocation annotation are skipped, the annotation may be
820+
omitted.
807821

808822
### Instruction relocations
809823

810-
For every usage of `typeidx`, `funcidx`, `globalidx`, `tagidx`, a relocation annotation is added afterwards, with `format` predefined as `leb`, `method` predefined as the *primary* method for that type, and `symbol` defaulted as the *primary* symbol of that `idx`
811-
812-
- For the `i32.const` instruction, a relocation annotation is added after the integer literal operand, with `format` predefined as `sleb`, and `method` is allowed to be either `data` or `functable`.
813-
- For the `i64.const` instruction, a relocation annotation is added after the integer literal operand, with `format` predefined as `sleb64`, and `method` is allowed to be either `data` or `functable`.
814-
- For the `i{32,64}.{load,store}*` instructions, a relocation annotation is added after the offset operand, with `format` predefined as `leb` if the *memory* being referenced is 32-bit, and `leb64` otherwise, and `method` predefined as `data`.
824+
For every usage of `typeidx`, `funcidx`, `globalidx`, `tagidx`, a relocation
825+
annotation is added afterwards, with `format` predefined as `leb`, `method`
826+
predefined as the *primary* method for that type, and `symbol` defaulted as the
827+
*primary* symbol of that `idx`
828+
829+
- For the `i32.const` instruction, a relocation annotation is added after the
830+
integer literal operand, with `format` predefined as `sleb`, and `method` is
831+
allowed to be either `data` or `functable`.
832+
- For the `i64.const` instruction, a relocation annotation is added after the
833+
integer literal operand, with `format` predefined as `sleb64`, and `method`
834+
is allowed to be either `data` or `functable`.
835+
- For the `i{32,64}.{load,store}*` instructions, a relocation annotation is
836+
added after the offset operand, with `format` predefined as `leb` if the
837+
*memory* being referenced is 32-bit, and `leb64` otherwise, and `method`
838+
predefined as `data`.
815839

816840
### Data relocations
817841

818-
In data segments, relocation annotations can be interleaved into the data string sequence. When that happens, relocations are situated after the last byte of the value being relocated.
819-
For example, relocation of a 32-bit function pointer `$foo` into the data segment of size 4 would look like following:
842+
In data segments, relocation annotations can be interleaved into the data
843+
string sequence. When that happens, relocations are situated after the last
844+
byte of the value being relocated.
845+
846+
For example, relocation of a 32-bit function pointer `$foo` into the data
847+
segment of size 4 would look like following:
820848
```wat
821849
(data (i32.const 0) "\00\00\00\00" (@reloc i32 functbl $foo))
822850
```
@@ -832,11 +860,16 @@ Data imports represented as WebAssembly annotations of the form
832860
(@sym.import.data <name> <qualifier>*)
833861
```
834862

835-
- `name` is the symbol name written as WebAssembly `id`, it is the name by which relocation annotations reference the symbol. If it is not present, the symbol is considered *primary* symbol for that WebAssembly object, its name is taken from the related object
863+
- `name` is the symbol name written as WebAssembly `id`, it is the name by
864+
which relocation annotations reference the symbol. If it is not present, the
865+
symbol is considered *primary* symbol for that WebAssembly object, its name
866+
is taken from the related object
836867
- There may only be one primary symbol for each WebAssembly object.
837-
- If a symbol is not associated with an object, it may not be the primary symbol.
868+
- If a symbol is not associated with an object, it may not be the primary
869+
symbol.
838870

839-
- `qualifier` is one of the allowed qualifiers on a symbol declaration. Qualifiers may not repeat.
871+
- `qualifier` is one of the allowed qualifiers on a symbol declaration.
872+
Qualifiers may not repeat.
840873

841874
| `<qualifier>` | effect |
842875
|------------------|------------------------------------------------------------------------------------------------|
@@ -856,62 +889,77 @@ Data imports represented as WebAssembly annotations of the form
856889
- The `size` and `name` qualifiers must be applied to data symbols.
857890
- The `name` qualifier must be applied to data imports.
858891

859-
If all components of a symbol annotation are skipped, the annotation may be omitted.
892+
If all components of a symbol annotation are skipped, the annotation may be
893+
omitted.
860894

861895
### WebAssembly object symbols
862896

863-
For symbols related to WebAssembly objects, the symbol annotation sequence occurs after the optional `id` of the declaration.
897+
For symbols related to WebAssembly objects, the symbol annotation sequence
898+
occurs after the optional `id` of the declaration.
899+
864900
For example, the following code:
865901
```wat
866902
(import "env" "foo" (func (@sym $a retain name="a") (@sym $b hidden name="b") (param) (result)))
867903
```
868-
declares 3 symbols: one primary symbol with the name of the index of the function, one symbol with the name `$a`, and one symbol with the name `$b`.
904+
declares 3 symbols: one primary symbol with the name of the index of the
905+
function, one symbol with the name `$a`, and one symbol with the name `$b`.
869906

870907
### Data symbols
871908

872-
Data symbol annotations can be interleaved into the data string sequence. When that happens, relocations are situated before the first byte of the value being defined.
873-
For example, a declaration of a 32-bit global with the name `$foo` and linkage name "foo" would look like following:
909+
Data symbol annotations can be interleaved into the data string sequence.
910+
When that happens, relocations are situated before the first byte of the value
911+
being defined.
912+
913+
For example, a declaration of a 32-bit global with the name `$foo` and linkage
914+
name "foo" would look like following:
874915
```wat
875916
(data (i32.const 0) (@sym $foo name="foo" size=4) "\00\00\00\00")
876917
```
877918

878919
### Data imports
879920

880-
Data imports occur in the same place as module fields. Data imports are always situated before data symbols.
921+
Data imports occur in the same place as module fields. Data imports are always
922+
situated before data symbols.
881923

882924
## COMDATs
883925

884926
COMDATs are represented as WebAssembly annotations of the form
885927
```wat
886928
(@comdat <id> <string>)
887929
```
888-
where `id` is the WebAssembly name of the COMDAT, and `<string>` is `name_len` and `name_str` of the `comdat`.
930+
where `id` is the WebAssembly name of the COMDAT, and `<string>` is `name_len`
931+
and `name_str` of the `comdat`.
889932

890933
COMDAT declarations occur in the same place as module fields.
891934

892935
## Labels
893936

894-
For some relocation types, an offset into a section/function is necessary. For these cases, labels exsist.
937+
For some relocation types, an offset into a section/function is necessary. For
938+
these cases, labels exsist.
895939
Labels are represented as WebAssembly annotations of the form
896940
```wat
897941
(@sym.label <id>)
898942
```
899943

900944
### Function labels
901945
Function labels occur in the same place as instructions.
902-
A label always denotes the first byte of the next instruction, or the byte after the end of the function's instruction stream, if there isn't a next instruction.
946+
A label always denotes the first byte of the next instruction, or the byte
947+
after the end of the function's instruction stream, if there isn't a next
948+
instruction.
903949

904950
Function label names are local to the function in which they occur.
905951

906952
### Data labels
907953
Data labels can be interleaved into the data string sequence.
908-
When that happens, relocations are situated after the last byte of the value being relocated.
954+
When that happens, relocations are situated after the last byte of the value
955+
being relocated.
909956

910957
Data label names are local to the data segment in which they occur.
911958

912959
### Custom labels
913960
Custom labels can be interleaved into the data string sequence.
914-
When that happens, relocations are situated after the last byte of the value being relocated.
961+
When that happens, relocations are situated after the last byte of the value
962+
being relocated.
915963

916964
Custom label names are local to the custom section in which they occur.
917965

@@ -921,7 +969,8 @@ Data segment flags are represented as WebAssembly annotations of the form
921969
(@sym.segment <qualifier>*)
922970
```
923971

924-
- `qualifier` is one of the allowed qualifiers on a data segment declaration. Qualifiers may not repeat.
972+
- `qualifier` is one of the allowed qualifiers on a data segment declaration.
973+
Qualifiers may not repeat.
925974

926975
| `<qualifier>` | effect |
927976
|-----------------|------------------------------------------------------|
@@ -936,4 +985,5 @@ If `name` is not specified, it is given an empty default value.
936985

937986
If all components of segment flags are skipped, the annotation may be omitted.
938987

939-
Data segment annotation occurs after the optional `id` of the data segment declaration.
988+
Data segment annotation occurs after the optional `id` of the data segment
989+
declaration.

0 commit comments

Comments
 (0)