]> granicus.if.org Git - llvm/commitdiff
[WebAssembly] Store section alignment as a power of 2
authorSam Clegg <sbc@chromium.org>
Wed, 16 Jan 2019 01:34:48 +0000 (01:34 +0000)
committerSam Clegg <sbc@chromium.org>
Wed, 16 Jan 2019 01:34:48 +0000 (01:34 +0000)
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

26 files changed:
include/llvm/BinaryFormat/Wasm.h
lib/MC/WasmObjectWriter.cpp
test/MC/WebAssembly/array-fill.ll
test/MC/WebAssembly/assembler-binary.ll
test/MC/WebAssembly/bss.ll
test/MC/WebAssembly/comdat.ll
test/MC/WebAssembly/event-section.ll
test/MC/WebAssembly/explicit-sections.ll
test/MC/WebAssembly/function-sections.ll
test/MC/WebAssembly/global-ctor-dtor.ll
test/MC/WebAssembly/unnamed-data.ll
test/MC/WebAssembly/weak-alias.ll
test/Object/Inputs/trivial-object-test.wasm
test/Object/obj2yaml.test
test/Object/wasm-bad-metadata-version.yaml
test/ObjectYAML/wasm/code_section.yaml
test/ObjectYAML/wasm/data_section.yaml
test/ObjectYAML/wasm/event_section.yaml
test/ObjectYAML/wasm/invalid_global_weak.yaml
test/ObjectYAML/wasm/linking_section.yaml
test/ObjectYAML/wasm/weak_symbols.yaml
test/tools/llvm-nm/wasm/exports.yaml
test/tools/llvm-nm/wasm/imports.yaml
test/tools/llvm-nm/wasm/weak-symbols.yaml
test/tools/llvm-objdump/Inputs/trivial.obj.wasm
test/tools/llvm-readobj/Inputs/trivial.obj.wasm

index 8c9810fb1307571d8c5f72e5e2dd8932e52da319..d9f0f94b298d4e72f68fca5de4ca926c479ac51c 100644 (file)
@@ -26,7 +26,7 @@ const char WasmMagic[] = {'\0', 'a', 's', 'm'};
 // Wasm binary format version
 const uint32_t WasmVersion = 0x1;
 // Wasm linking metadata version
-const uint32_t WasmMetadataVersion = 0x1;
+const uint32_t WasmMetadataVersion = 0x2;
 // Wasm uses a 64k page size
 const uint32_t WasmPageSize = 65536;
 
index c4839ffe6801762149f4b1dacdbada7d7528743c..0cca3757be907fd0005577d891e8be0a8ebe1551 100644 (file)
@@ -1256,7 +1256,7 @@ uint64_t WasmObjectWriter::writeObject(MCAssembler &Asm,
       Segment.Offset = DataSize;
       Segment.Section = &Section;
       addData(Segment.Data, Section);
-      Segment.Alignment = Section.getAlignment();
+      Segment.Alignment = Log2_32(Section.getAlignment());
       Segment.Flags = 0;
       DataSize += Segment.Data.size();
       Section.setSegmentIndex(SegmentIndex);
index 7af4e740dc8ab769dbd5293034e4532f4d7ce176..7f3d8bda346587b7ccfa56f5ec6fa946e10efc89 100644 (file)
@@ -22,6 +22,6 @@ target triple = "wasm32-unknown-unknown"
 ; CHECK-NEXT:     SegmentInfo:    
 ; CHECK-NEXT:       - Index:           0
 ; CHECK-NEXT:         Name:            .data
-; CHECK-NEXT:         Alignment:       1
+; CHECK-NEXT:         Alignment:       0
 ; CHECK-NEXT:         Flags:           [ ]
 ; CHECK-NEXT: ...
index 5e67b0902c7135eba783c5bf5cb5e2c03fa44950..def7f8c2879f79422ed93da9c9061761f35dc715 100644 (file)
@@ -77,7 +77,7 @@ entry:
 ; CHECK-NEXT:         Body:            1080808080000B
 ; CHECK-NEXT:   - Type:            CUSTOM
 ; CHECK-NEXT:     Name:            linking
-; CHECK-NEXT:     Version:         1
+; CHECK-NEXT:     Version:         2
 ; CHECK-NEXT:     SymbolTable:
 ; CHECK-NEXT:       - Index:           0
 ; CHECK-NEXT:         Kind:            FUNCTION
index 2c0cdf289ec44e091dc66779ce1d7be21444945e..1ab3ec1339bad648057eb6aa82f37cc364d6510c 100644 (file)
@@ -64,18 +64,18 @@ target triple = "wasm32-unknown-unknown"
 ; CHECK-NEXT:     SegmentInfo:    
 ; CHECK-NEXT:       - Index:           0
 ; CHECK-NEXT:         Name:            .bss.g0
-; CHECK-NEXT:         Alignment:       4
+; CHECK-NEXT:         Alignment:       2
 ; CHECK-NEXT:         Flags:           [ ]
 ; CHECK-NEXT:       - Index:           1
 ; CHECK-NEXT:         Name:            .bss.g1
-; CHECK-NEXT:         Alignment:       4
+; CHECK-NEXT:         Alignment:       2
 ; CHECK-NEXT:         Flags:           [ ]
 ; CHECK-NEXT:       - Index:           2
 ; CHECK-NEXT:         Name:            .bss.foo
-; CHECK-NEXT:         Alignment:       1
+; CHECK-NEXT:         Alignment:       0
 ; CHECK-NEXT:         Flags:           [ ]
 ; CHECK-NEXT:       - Index:           3
 ; CHECK-NEXT:         Name:            .bss.bar
-; CHECK-NEXT:         Alignment:       1
+; CHECK-NEXT:         Alignment:       0
 ; CHECK-NEXT:         Flags:           [ ]
 ; CHECK-NEXT: ...
index 369127751f3f9ef17fb46f2d17b7ecb836b73c57..997840a80fbcfc2b27fd0f224a6bca44b41696c5 100644 (file)
@@ -75,7 +75,7 @@ define linkonce_odr i32 @sharedFn() #1 comdat($sharedComdat) {
 ; CHECK-NEXT:        Content:         '616263'
 ; CHECK-NEXT:  - Type:            CUSTOM
 ; CHECK-NEXT:    Name:            linking
-; CHECK-NEXT:    Version:         1
+; CHECK-NEXT:    Version:         2
 ; CHECK-NEXT:    SymbolTable:
 ; CHECK-NEXT:       - Index:           0
 ; CHECK-NEXT:         Kind:            FUNCTION
@@ -106,7 +106,7 @@ define linkonce_odr i32 @sharedFn() #1 comdat($sharedComdat) {
 ; CHECK-NEXT:    SegmentInfo:
 ; CHECK-NEXT:      - Index:           0
 ; CHECK-NEXT:        Name:            .rodata.constantData
-; CHECK-NEXT:        Alignment:       1
+; CHECK-NEXT:        Alignment:       0
 ; CHECK-NEXT:        Flags:           [  ]
 ; CHECK-NEXT:    Comdats:
 ; CHECK-NEXT:        Name:            basicInlineFn
index 213817007f0287fac2ce1f768c36ebda8dab09f5..dc2e9b6a7a9987b1330053bd060f63289953e403 100644 (file)
@@ -44,7 +44,7 @@ define i32 @test_throw1(i8* %p) {
 
 ; CHECK:        - Type:            CUSTOM
 ; CHECK-NEXT:     Name:            linking
-; CHECK-NEXT:     Version:         1
+; CHECK-NEXT:     Version:         2
 ; CHECK-NEXT:     SymbolTable:
 
 ; CHECK:            - Index:           1
index e069cee6ff4ffa5a05e90f52d46b9773ee42adaf..ab2bb163fff4145024eadd90676e69f5d4dc343a 100644 (file)
@@ -60,14 +60,14 @@ target triple = "wasm32-unknown-unknown"
 ; CHECK-NEXT:     SegmentInfo:    
 ; CHECK-NEXT:       - Index:           0
 ; CHECK-NEXT:         Name:            .data.global0
-; CHECK-NEXT:         Alignment:       8
+; CHECK-NEXT:         Alignment:       3
 ; CHECK-NEXT:         Flags:           [ ]
 ; CHECK-NEXT:       - Index:           1
 ; CHECK-NEXT:         Name:            .sec1
-; CHECK-NEXT:         Alignment:       8
+; CHECK-NEXT:         Alignment:       3
 ; CHECK-NEXT:         Flags:           [ ]
 ; CHECK-NEXT:       - Index:           2
 ; CHECK-NEXT:         Name:            .sec2
-; CHECK-NEXT:         Alignment:       8
+; CHECK-NEXT:         Alignment:       3
 ; CHECK-NEXT:         Flags:           [ ]
 ; CHECK-NEXT: ...
index 8f1e29adccf4f443dacfa5ed0bfbf368e1269733..b9b9c28376eb4fcb5494b66a12c6d6f23a8242f9 100644 (file)
@@ -14,7 +14,7 @@ entry:
 
 ; CHECK:        - Type:            CUSTOM
 ; CHECK-NEXT:     Name:            linking
-; CHECK-NEXT:     Version:         1
+; CHECK-NEXT:     Version:         2
 ; CHECK-NEXT:     SymbolTable:     
 ; CHECK-NEXT:       - Index:           0
 ; CHECK-NEXT:         Kind:            FUNCTION
index a75932914eb1d13b0d9753f1c14587249cdeed83..4dd8deb6707bff84b6c7cfb93a08176cde7a20f9 100644 (file)
@@ -110,7 +110,7 @@ declare void @func3()
 ; CHECK-NEXT:         Content:         '01040000'
 ; CHECK-NEXT:   - Type:            CUSTOM
 ; CHECK-NEXT:     Name:            linking
-; CHECK-NEXT:     Version:         1
+; CHECK-NEXT:     Version:         2
 ; CHECK-NEXT:     SymbolTable:
 ; CHECK-NEXT:       - Index:           0
 ; CHECK-NEXT:         Kind:            FUNCTION
@@ -170,7 +170,7 @@ declare void @func3()
 ; CHECK-NEXT:     SegmentInfo:
 ; CHECK-NEXT:       - Index:           0
 ; CHECK-NEXT:         Name:            .data.global1
-; CHECK-NEXT:         Alignment:       8
+; CHECK-NEXT:         Alignment:       3
 ; CHECK-NEXT:         Flags:           [ ]
 ; CHECK-NEXT:     InitFunctions:     
 ; CHECK-NEXT:       - Priority: 42
index 47949026ca819f3ea2e42a3498b3ed43b8524fe3..ef7a0e5e8b77a578fbf86b7aa5056eae96e789e2 100644 (file)
@@ -44,7 +44,7 @@ target triple = "wasm32-unknown-unknown"
 ; CHECK-NEXT:         Content:         '06000000'
 ; CHECK-NEXT:   - Type:            CUSTOM
 ; CHECK-NEXT:     Name:            linking
-; CHECK-NEXT:     Version:         1
+; CHECK-NEXT:     Version:         2
 ; CHECK-NEXT:     SymbolTable:      
 ; CHECK-NEXT:       - Index:           0
 ; CHECK-NEXT:         Kind:            DATA
@@ -73,18 +73,18 @@ target triple = "wasm32-unknown-unknown"
 ; CHECK-NEXT:     SegmentInfo:    
 ; CHECK-NEXT:       - Index:       0
 ; CHECK-NEXT:         Name:        .rodata..L.str1
-; CHECK-NEXT:         Alignment:   1
+; CHECK-NEXT:         Alignment:   0
 ; CHECK-NEXT:         Flags:       [ ]
 ; CHECK-NEXT:       - Index:       1
 ; CHECK-NEXT:         Name:        .rodata..L.str2
-; CHECK-NEXT:         Alignment:   1
+; CHECK-NEXT:         Alignment:   0
 ; CHECK-NEXT:         Flags:       [ ]
 ; CHECK-NEXT:       - Index:       2
 ; CHECK-NEXT:         Name:        .data.a
-; CHECK-NEXT:         Alignment:   8
+; CHECK-NEXT:         Alignment:   3
 ; CHECK-NEXT:         Flags:       [ ]
 ; CHECK-NEXT:       - Index:       3
 ; CHECK-NEXT:         Name:        .data.b
-; CHECK-NEXT:         Alignment:   8
+; CHECK-NEXT:         Alignment:   3
 ; CHECK-NEXT:         Flags:       [ ]
 ; CHECK_NEXT:   ...
index f0997c1efe48a02ccab71eb69d07955046bb674d..ea496db505261fb99cacc3474273675801bafe70 100644 (file)
@@ -138,7 +138,7 @@ entry:
 ; CHECK-NEXT:         Content:         '01000000'
 ; CHECK-NEXT:   - Type:            CUSTOM
 ; CHECK-NEXT:     Name:            linking
-; CHECK-NEXT:     Version:         1
+; CHECK-NEXT:     Version:         2
 ; CHECK-NEXT:     SymbolTable:
 ; CHECK-NEXT:       - Index:           0
 ; CHECK-NEXT:         Kind:            FUNCTION
@@ -197,15 +197,15 @@ entry:
 ; CHECK-NEXT:     SegmentInfo:
 ; CHECK-NEXT:       - Index:           0
 ; CHECK-NEXT:         Name:            .data.bar
-; CHECK-NEXT:         Alignment:       8
+; CHECK-NEXT:         Alignment:       3
 ; CHECK-NEXT:         Flags:           [ ]
 ; CHECK-NEXT:       - Index:           1
 ; CHECK-NEXT:         Name:            .data.direct_address
-; CHECK-NEXT:         Alignment:       8
+; CHECK-NEXT:         Alignment:       3
 ; CHECK-NEXT:         Flags:           [ ]
 ; CHECK-NEXT:       - Index:           2
 ; CHECK-NEXT:         Name:            .data.alias_address
-; CHECK-NEXT:         Alignment:       8
+; CHECK-NEXT:         Alignment:       3
 ; CHECK-NEXT:         Flags:           [ ]
 ; CHECK-NEXT: ...
 
index 8652d67f69222ab57610df1b13d3972e031460a1..a894522fa152ba86d59c6c585788e1467809f416 100644 (file)
Binary files a/test/Object/Inputs/trivial-object-test.wasm and b/test/Object/Inputs/trivial-object-test.wasm differ
index 46a0d77363647c85f7c15de4b83f9910dbdb1378..5accdd45693da9fab99bcf60fe3e0ddbdebdbbfb 100644 (file)
@@ -651,7 +651,7 @@ WASM-NEXT: FileHeader:
 WASM-NEXT:   Version:         0x00000001
 WASM:        - Type:            CUSTOM
 WASM-NEXT:     Name:            linking
-WASM-NEXT:     Version:         1
+WASM-NEXT:     Version:         2
 WASM-NEXT:     SymbolTable:
 WASM-NEXT:       - Index:           0
 WASM-NEXT:         Kind:            FUNCTION
@@ -675,7 +675,7 @@ WASM:              Name:            var
 WASM:          SegmentInfo:
 WASM-NEXT:       - Index:           0
 WASM-NEXT:         Name:            .rodata..L.str
-WASM-NEXT:         Alignment:       1
+WASM-NEXT:         Alignment:       0
 WASM-NEXT:         Flags:           [  ]
 WASM-NEXT:       - Index:           1
 WASM:      ...
index b2970bb59eadd02ccf35413657044941f3c5044f..7bda5b8d13aa538169a7ca9284db17eb5d647b57 100644 (file)
@@ -8,4 +8,4 @@ Sections:
     Name:            linking
     Version:         0
 
-# CHECK: {{.*}}: Unexpected metadata version: 0 (Expected: 1)
+# CHECK: {{.*}}: Unexpected metadata version: 0 (Expected: 2)
index 0d7cf61638bccd234c21a5d4a97efee2f26d023d..1a63ce5515071c2b0345688375ae461ea9affd4a 100644 (file)
@@ -39,7 +39,7 @@ Sections:
         Body:            108180808000210020000F0B
   - Type:            CUSTOM
     Name:            linking
-    Version:         1
+    Version:         2
     SymbolTable:
       - Index:           0
         Kind:            FUNCTION
index ef5945dcaac6887cbd1f3c25c68e99f929402834..aa18301ca22726cdf03c27a18b12ebd23792eaa9 100644 (file)
@@ -24,7 +24,7 @@ Sections:
         Addend:          -6
   - Type:            CUSTOM
     Name:            linking
-    Version:         1
+    Version:         2
     SymbolTable:
       - Index:           0
         Kind:            DATA
index 017efda056ce14dfd2ff939dcaf446a81c9ee1c5..f026899ac7247ba3220e8d116c01a4fef76ee111 100644 (file)
@@ -32,7 +32,7 @@ Sections:
         Body:            200008808080800041000B
   - Type:            CUSTOM
     Name:            linking
-    Version:         1
+    Version:         2
     SymbolTable:
       - Index:           0
         Kind:            FUNCTION
@@ -78,7 +78,7 @@ Sections:
 # CHECK-NEXT:         Body:            200008808080800041000B
 # CHECK-NEXT:   - Type:            CUSTOM
 # CHECK-NEXT:     Name:            linking
-# CHECK-NEXT:     Version:         1
+# CHECK-NEXT:     Version:         2
 # CHECK-NEXT:     SymbolTable:
 # CHECK-NEXT:       - Index:           0
 # CHECK-NEXT:         Kind:            FUNCTION
index c364075e2e45d0cbc536307d9d11afa998f375fa..4566e8f0f009de8445d910ddad7522223990d184 100644 (file)
@@ -13,7 +13,7 @@ Sections:
         GlobalMutable:   false
   - Type:            CUSTOM
     Name:            linking
-    Version:         1
+    Version:         2
     SymbolTable:
       - Index:           0
         Kind:            GLOBAL
index d1f0243037dfadc9a70a4496485122775487e9e7..69817f50970ad1239f2c8786756c7c2c6bf4dc8a 100644 (file)
@@ -29,7 +29,7 @@ Sections:
         Content:         '11110000'
   - Type:            CUSTOM
     Name:            linking
-    Version:         1
+    Version:         2
     SymbolTable:
       - Index:           0
         Kind:            FUNCTION
index 3e9ca34deac066df4b5e33fc28cc45fb1230e927..fb85b829a371b9de95adb73a5cfbfcfacfc59ab2 100644 (file)
@@ -36,7 +36,7 @@ Sections:
         Body:            00
   - Type:            CUSTOM
     Name:            linking
-    Version:         1
+    Version:         2
     SymbolTable:
       - Index:           0
         Kind:            FUNCTION
index 55d2b76470a236f2b096143a90adca0d0856db39..c1ee6d7cf5882c6df7b4b232e544c23aacb7b480 100644 (file)
@@ -37,7 +37,7 @@ Sections:
         Content:         '616263'
   - Type:            CUSTOM
     Name:            linking
-    Version:         1
+    Version:         2
     SymbolTable:
        - Index:           0
          Kind:            FUNCTION
index 9696972de4dcbc2505b85f2548dcfb5b0a5ad844..2ea0d0f13fe34fd52fda8a9483a7ac8616762477 100644 (file)
@@ -25,7 +25,7 @@ Sections:
         GlobalMutable:   false
   - Type:            CUSTOM
     Name:            linking
-    Version:         1
+    Version:         2
     SymbolTable:
        - Index:           0
          Kind:            FUNCTION
index caa981df43692dbc80b53032736f77d1fd36170b..36711b17b981d783cc9f200804e895c27fce2229 100644 (file)
@@ -43,7 +43,7 @@ Sections:
         Content:         '616263'
   - Type:            CUSTOM
     Name:            linking
-    Version:         1
+    Version:         2
     SymbolTable:
        - Index:           0
          Kind:            DATA
index 8652d67f69222ab57610df1b13d3972e031460a1..a894522fa152ba86d59c6c585788e1467809f416 100644 (file)
Binary files a/test/tools/llvm-objdump/Inputs/trivial.obj.wasm and b/test/tools/llvm-objdump/Inputs/trivial.obj.wasm differ
index 2f99d3446123f06927724b5d2c733d32cdef044d..10ebbeed6acbfc35ce460b83c61218b7e64ec1fa 100644 (file)
Binary files a/test/tools/llvm-readobj/Inputs/trivial.obj.wasm and b/test/tools/llvm-readobj/Inputs/trivial.obj.wasm differ