llvm.org GIT mirror llvm / 29aeb33
[WebAssembly] Store section alignment as a power of 2 This change bumps for version number of the wasm object file metadata. See https://github.com/WebAssembly/tool-conventions/pull/92 Differential Revision: https://reviews.llvm.org/D56758 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@351285 91177308-0d34-0410-b5e6-96231b3b80d8 Sam Clegg 7 months ago
26 changed file(s) with 39 addition(s) and 39 deletion(s). Raw diff Collapse all Expand all
2525 // Wasm binary format version
2626 const uint32_t WasmVersion = 0x1;
2727 // Wasm linking metadata version
28 const uint32_t WasmMetadataVersion = 0x1;
28 const uint32_t WasmMetadataVersion = 0x2;
2929 // Wasm uses a 64k page size
3030 const uint32_t WasmPageSize = 65536;
3131
12551255 Segment.Offset = DataSize;
12561256 Segment.Section = &Section;
12571257 addData(Segment.Data, Section);
1258 Segment.Alignment = Section.getAlignment();
1258 Segment.Alignment = Log2_32(Section.getAlignment());
12591259 Segment.Flags = 0;
12601260 DataSize += Segment.Data.size();
12611261 Section.setSegmentIndex(SegmentIndex);
2121 ; CHECK-NEXT: SegmentInfo:
2222 ; CHECK-NEXT: - Index: 0
2323 ; CHECK-NEXT: Name: .data
24 ; CHECK-NEXT: Alignment: 1
24 ; CHECK-NEXT: Alignment: 0
2525 ; CHECK-NEXT: Flags: [ ]
2626 ; CHECK-NEXT: ...
7676 ; CHECK-NEXT: Body: 1080808080000B
7777 ; CHECK-NEXT: - Type: CUSTOM
7878 ; CHECK-NEXT: Name: linking
79 ; CHECK-NEXT: Version: 1
79 ; CHECK-NEXT: Version: 2
8080 ; CHECK-NEXT: SymbolTable:
8181 ; CHECK-NEXT: - Index: 0
8282 ; CHECK-NEXT: Kind: FUNCTION
6363 ; CHECK-NEXT: SegmentInfo:
6464 ; CHECK-NEXT: - Index: 0
6565 ; CHECK-NEXT: Name: .bss.g0
66 ; CHECK-NEXT: Alignment: 4
66 ; CHECK-NEXT: Alignment: 2
6767 ; CHECK-NEXT: Flags: [ ]
6868 ; CHECK-NEXT: - Index: 1
6969 ; CHECK-NEXT: Name: .bss.g1
70 ; CHECK-NEXT: Alignment: 4
70 ; CHECK-NEXT: Alignment: 2
7171 ; CHECK-NEXT: Flags: [ ]
7272 ; CHECK-NEXT: - Index: 2
7373 ; CHECK-NEXT: Name: .bss.foo
74 ; CHECK-NEXT: Alignment: 1
74 ; CHECK-NEXT: Alignment: 0
7575 ; CHECK-NEXT: Flags: [ ]
7676 ; CHECK-NEXT: - Index: 3
7777 ; CHECK-NEXT: Name: .bss.bar
78 ; CHECK-NEXT: Alignment: 1
78 ; CHECK-NEXT: Alignment: 0
7979 ; CHECK-NEXT: Flags: [ ]
8080 ; CHECK-NEXT: ...
7474 ; CHECK-NEXT: Content: '616263'
7575 ; CHECK-NEXT: - Type: CUSTOM
7676 ; CHECK-NEXT: Name: linking
77 ; CHECK-NEXT: Version: 1
77 ; CHECK-NEXT: Version: 2
7878 ; CHECK-NEXT: SymbolTable:
7979 ; CHECK-NEXT: - Index: 0
8080 ; CHECK-NEXT: Kind: FUNCTION
105105 ; CHECK-NEXT: SegmentInfo:
106106 ; CHECK-NEXT: - Index: 0
107107 ; CHECK-NEXT: Name: .rodata.constantData
108 ; CHECK-NEXT: Alignment: 1
108 ; CHECK-NEXT: Alignment: 0
109109 ; CHECK-NEXT: Flags: [ ]
110110 ; CHECK-NEXT: Comdats:
111111 ; CHECK-NEXT: Name: basicInlineFn
4343
4444 ; CHECK: - Type: CUSTOM
4545 ; CHECK-NEXT: Name: linking
46 ; CHECK-NEXT: Version: 1
46 ; CHECK-NEXT: Version: 2
4747 ; CHECK-NEXT: SymbolTable:
4848
4949 ; CHECK: - Index: 1
5959 ; CHECK-NEXT: SegmentInfo:
6060 ; CHECK-NEXT: - Index: 0
6161 ; CHECK-NEXT: Name: .data.global0
62 ; CHECK-NEXT: Alignment: 8
62 ; CHECK-NEXT: Alignment: 3
6363 ; CHECK-NEXT: Flags: [ ]
6464 ; CHECK-NEXT: - Index: 1
6565 ; CHECK-NEXT: Name: .sec1
66 ; CHECK-NEXT: Alignment: 8
66 ; CHECK-NEXT: Alignment: 3
6767 ; CHECK-NEXT: Flags: [ ]
6868 ; CHECK-NEXT: - Index: 2
6969 ; CHECK-NEXT: Name: .sec2
70 ; CHECK-NEXT: Alignment: 8
70 ; CHECK-NEXT: Alignment: 3
7171 ; CHECK-NEXT: Flags: [ ]
7272 ; CHECK-NEXT: ...
1313
1414 ; CHECK: - Type: CUSTOM
1515 ; CHECK-NEXT: Name: linking
16 ; CHECK-NEXT: Version: 1
16 ; CHECK-NEXT: Version: 2
1717 ; CHECK-NEXT: SymbolTable:
1818 ; CHECK-NEXT: - Index: 0
1919 ; CHECK-NEXT: Kind: FUNCTION
109109 ; CHECK-NEXT: Content: '01040000'
110110 ; CHECK-NEXT: - Type: CUSTOM
111111 ; CHECK-NEXT: Name: linking
112 ; CHECK-NEXT: Version: 1
112 ; CHECK-NEXT: Version: 2
113113 ; CHECK-NEXT: SymbolTable:
114114 ; CHECK-NEXT: - Index: 0
115115 ; CHECK-NEXT: Kind: FUNCTION
169169 ; CHECK-NEXT: SegmentInfo:
170170 ; CHECK-NEXT: - Index: 0
171171 ; CHECK-NEXT: Name: .data.global1
172 ; CHECK-NEXT: Alignment: 8
172 ; CHECK-NEXT: Alignment: 3
173173 ; CHECK-NEXT: Flags: [ ]
174174 ; CHECK-NEXT: InitFunctions:
175175 ; CHECK-NEXT: - Priority: 42
4343 ; CHECK-NEXT: Content: '06000000'
4444 ; CHECK-NEXT: - Type: CUSTOM
4545 ; CHECK-NEXT: Name: linking
46 ; CHECK-NEXT: Version: 1
46 ; CHECK-NEXT: Version: 2
4747 ; CHECK-NEXT: SymbolTable:
4848 ; CHECK-NEXT: - Index: 0
4949 ; CHECK-NEXT: Kind: DATA
7272 ; CHECK-NEXT: SegmentInfo:
7373 ; CHECK-NEXT: - Index: 0
7474 ; CHECK-NEXT: Name: .rodata..L.str1
75 ; CHECK-NEXT: Alignment: 1
75 ; CHECK-NEXT: Alignment: 0
7676 ; CHECK-NEXT: Flags: [ ]
7777 ; CHECK-NEXT: - Index: 1
7878 ; CHECK-NEXT: Name: .rodata..L.str2
79 ; CHECK-NEXT: Alignment: 1
79 ; CHECK-NEXT: Alignment: 0
8080 ; CHECK-NEXT: Flags: [ ]
8181 ; CHECK-NEXT: - Index: 2
8282 ; CHECK-NEXT: Name: .data.a
83 ; CHECK-NEXT: Alignment: 8
83 ; CHECK-NEXT: Alignment: 3
8484 ; CHECK-NEXT: Flags: [ ]
8585 ; CHECK-NEXT: - Index: 3
8686 ; CHECK-NEXT: Name: .data.b
87 ; CHECK-NEXT: Alignment: 8
87 ; CHECK-NEXT: Alignment: 3
8888 ; CHECK-NEXT: Flags: [ ]
8989 ; CHECK_NEXT: ...
137137 ; CHECK-NEXT: Content: '01000000'
138138 ; CHECK-NEXT: - Type: CUSTOM
139139 ; CHECK-NEXT: Name: linking
140 ; CHECK-NEXT: Version: 1
140 ; CHECK-NEXT: Version: 2
141141 ; CHECK-NEXT: SymbolTable:
142142 ; CHECK-NEXT: - Index: 0
143143 ; CHECK-NEXT: Kind: FUNCTION
196196 ; CHECK-NEXT: SegmentInfo:
197197 ; CHECK-NEXT: - Index: 0
198198 ; CHECK-NEXT: Name: .data.bar
199 ; CHECK-NEXT: Alignment: 8
199 ; CHECK-NEXT: Alignment: 3
200200 ; CHECK-NEXT: Flags: [ ]
201201 ; CHECK-NEXT: - Index: 1
202202 ; CHECK-NEXT: Name: .data.direct_address
203 ; CHECK-NEXT: Alignment: 8
203 ; CHECK-NEXT: Alignment: 3
204204 ; CHECK-NEXT: Flags: [ ]
205205 ; CHECK-NEXT: - Index: 2
206206 ; CHECK-NEXT: Name: .data.alias_address
207 ; CHECK-NEXT: Alignment: 8
207 ; CHECK-NEXT: Alignment: 3
208208 ; CHECK-NEXT: Flags: [ ]
209209 ; CHECK-NEXT: ...
210210
650650 WASM-NEXT: Version: 0x00000001
651651 WASM: - Type: CUSTOM
652652 WASM-NEXT: Name: linking
653 WASM-NEXT: Version: 1
653 WASM-NEXT: Version: 2
654654 WASM-NEXT: SymbolTable:
655655 WASM-NEXT: - Index: 0
656656 WASM-NEXT: Kind: FUNCTION
674674 WASM: SegmentInfo:
675675 WASM-NEXT: - Index: 0
676676 WASM-NEXT: Name: .rodata..L.str
677 WASM-NEXT: Alignment: 1
677 WASM-NEXT: Alignment: 0
678678 WASM-NEXT: Flags: [ ]
679679 WASM-NEXT: - Index: 1
680680 WASM: ...
77 Name: linking
88 Version: 0
99
10 # CHECK: {{.*}}: Unexpected metadata version: 0 (Expected: 1)
10 # CHECK: {{.*}}: Unexpected metadata version: 0 (Expected: 2)
3838 Body: 108180808000210020000F0B
3939 - Type: CUSTOM
4040 Name: linking
41 Version: 1
41 Version: 2
4242 SymbolTable:
4343 - Index: 0
4444 Kind: FUNCTION
2323 Addend: -6
2424 - Type: CUSTOM
2525 Name: linking
26 Version: 1
26 Version: 2
2727 SymbolTable:
2828 - Index: 0
2929 Kind: DATA
3131 Body: 200008808080800041000B
3232 - Type: CUSTOM
3333 Name: linking
34 Version: 1
34 Version: 2
3535 SymbolTable:
3636 - Index: 0
3737 Kind: FUNCTION
7777 # CHECK-NEXT: Body: 200008808080800041000B
7878 # CHECK-NEXT: - Type: CUSTOM
7979 # CHECK-NEXT: Name: linking
80 # CHECK-NEXT: Version: 1
80 # CHECK-NEXT: Version: 2
8181 # CHECK-NEXT: SymbolTable:
8282 # CHECK-NEXT: - Index: 0
8383 # CHECK-NEXT: Kind: FUNCTION
1212 GlobalMutable: false
1313 - Type: CUSTOM
1414 Name: linking
15 Version: 1
15 Version: 2
1616 SymbolTable:
1717 - Index: 0
1818 Kind: GLOBAL
2828 Content: '11110000'
2929 - Type: CUSTOM
3030 Name: linking
31 Version: 1
31 Version: 2
3232 SymbolTable:
3333 - Index: 0
3434 Kind: FUNCTION
3535 Body: 00
3636 - Type: CUSTOM
3737 Name: linking
38 Version: 1
38 Version: 2
3939 SymbolTable:
4040 - Index: 0
4141 Kind: FUNCTION
3636 Content: '616263'
3737 - Type: CUSTOM
3838 Name: linking
39 Version: 1
39 Version: 2
4040 SymbolTable:
4141 - Index: 0
4242 Kind: FUNCTION
2424 GlobalMutable: false
2525 - Type: CUSTOM
2626 Name: linking
27 Version: 1
27 Version: 2
2828 SymbolTable:
2929 - Index: 0
3030 Kind: FUNCTION
4242 Content: '616263'
4343 - Type: CUSTOM
4444 Name: linking
45 Version: 1
45 Version: 2
4646 SymbolTable:
4747 - Index: 0
4848 Kind: DATA