You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Linking.md
+84-34Lines changed: 84 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -790,33 +790,61 @@ Symbol kinds marked with `*` are considered *primary*.
790
790
|`<labeluse>`| Byte offest to label |`method` is either `codeseg` or `*sec`|
791
791
792
792
-`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:
803
816
```wat
804
817
(@reloc functable $foo)
805
818
```
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.
807
821
808
822
### Instruction relocations
809
823
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`.
815
839
816
840
### Data relocations
817
841
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
@@ -832,11 +860,16 @@ Data imports represented as WebAssembly annotations of the form
832
860
(@sym.import.data <name> <qualifier>*)
833
861
```
834
862
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
836
867
- 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.
838
870
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.
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`.
869
906
870
907
### Data symbols
871
908
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
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.
881
923
882
924
## COMDATs
883
925
884
926
COMDATs are represented as WebAssembly annotations of the form
885
927
```wat
886
928
(@comdat <id> <string>)
887
929
```
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`.
889
932
890
933
COMDAT declarations occur in the same place as module fields.
891
934
892
935
## Labels
893
936
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.
895
939
Labels are represented as WebAssembly annotations of the form
896
940
```wat
897
941
(@sym.label <id>)
898
942
```
899
943
900
944
### Function labels
901
945
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.
903
949
904
950
Function label names are local to the function in which they occur.
905
951
906
952
### Data labels
907
953
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.
909
956
910
957
Data label names are local to the data segment in which they occur.
911
958
912
959
### Custom labels
913
960
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.
915
963
916
964
Custom label names are local to the custom section in which they occur.
917
965
@@ -921,7 +969,8 @@ Data segment flags are represented as WebAssembly annotations of the form
921
969
(@sym.segment <qualifier>*)
922
970
```
923
971
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.
0 commit comments