From 56c587adfd2999a5f096cf49266552de931aa1e3 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 16 Jan 2019 01:34:48 +0000 Subject: [PATCH] [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 llvm-svn: 351285 --- llvm/include/llvm/BinaryFormat/Wasm.h | 2 +- llvm/lib/MC/WasmObjectWriter.cpp | 2 +- llvm/test/MC/WebAssembly/array-fill.ll | 2 +- llvm/test/MC/WebAssembly/assembler-binary.ll | 2 +- llvm/test/MC/WebAssembly/bss.ll | 8 ++++---- llvm/test/MC/WebAssembly/comdat.ll | 4 ++-- llvm/test/MC/WebAssembly/event-section.ll | 2 +- llvm/test/MC/WebAssembly/explicit-sections.ll | 6 +++--- llvm/test/MC/WebAssembly/function-sections.ll | 2 +- llvm/test/MC/WebAssembly/global-ctor-dtor.ll | 4 ++-- llvm/test/MC/WebAssembly/unnamed-data.ll | 10 +++++----- llvm/test/MC/WebAssembly/weak-alias.ll | 8 ++++---- llvm/test/Object/Inputs/trivial-object-test.wasm | Bin 370 -> 370 bytes llvm/test/Object/obj2yaml.test | 4 ++-- llvm/test/Object/wasm-bad-metadata-version.yaml | 2 +- llvm/test/ObjectYAML/wasm/code_section.yaml | 2 +- llvm/test/ObjectYAML/wasm/data_section.yaml | 2 +- llvm/test/ObjectYAML/wasm/event_section.yaml | 4 ++-- llvm/test/ObjectYAML/wasm/invalid_global_weak.yaml | 2 +- llvm/test/ObjectYAML/wasm/linking_section.yaml | 2 +- llvm/test/ObjectYAML/wasm/weak_symbols.yaml | 2 +- llvm/test/tools/llvm-nm/wasm/exports.yaml | 2 +- llvm/test/tools/llvm-nm/wasm/imports.yaml | 2 +- llvm/test/tools/llvm-nm/wasm/weak-symbols.yaml | 2 +- llvm/test/tools/llvm-objdump/Inputs/trivial.obj.wasm | Bin 370 -> 370 bytes llvm/test/tools/llvm-readobj/Inputs/trivial.obj.wasm | Bin 341 -> 341 bytes 26 files changed, 39 insertions(+), 39 deletions(-) diff --git a/llvm/include/llvm/BinaryFormat/Wasm.h b/llvm/include/llvm/BinaryFormat/Wasm.h index 8c9810f..d9f0f94 100644 --- a/llvm/include/llvm/BinaryFormat/Wasm.h +++ b/llvm/include/llvm/BinaryFormat/Wasm.h @@ -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; diff --git a/llvm/lib/MC/WasmObjectWriter.cpp b/llvm/lib/MC/WasmObjectWriter.cpp index c4839ff..0cca375 100644 --- a/llvm/lib/MC/WasmObjectWriter.cpp +++ b/llvm/lib/MC/WasmObjectWriter.cpp @@ -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); diff --git a/llvm/test/MC/WebAssembly/array-fill.ll b/llvm/test/MC/WebAssembly/array-fill.ll index 7af4e74..7f3d8bd 100644 --- a/llvm/test/MC/WebAssembly/array-fill.ll +++ b/llvm/test/MC/WebAssembly/array-fill.ll @@ -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: ... diff --git a/llvm/test/MC/WebAssembly/assembler-binary.ll b/llvm/test/MC/WebAssembly/assembler-binary.ll index 5e67b09..def7f8c 100644 --- a/llvm/test/MC/WebAssembly/assembler-binary.ll +++ b/llvm/test/MC/WebAssembly/assembler-binary.ll @@ -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 diff --git a/llvm/test/MC/WebAssembly/bss.ll b/llvm/test/MC/WebAssembly/bss.ll index 2c0cdf2..1ab3ec1 100644 --- a/llvm/test/MC/WebAssembly/bss.ll +++ b/llvm/test/MC/WebAssembly/bss.ll @@ -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: ... diff --git a/llvm/test/MC/WebAssembly/comdat.ll b/llvm/test/MC/WebAssembly/comdat.ll index 3691277..997840a 100644 --- a/llvm/test/MC/WebAssembly/comdat.ll +++ b/llvm/test/MC/WebAssembly/comdat.ll @@ -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 diff --git a/llvm/test/MC/WebAssembly/event-section.ll b/llvm/test/MC/WebAssembly/event-section.ll index 2138170..dc2e9b6 100644 --- a/llvm/test/MC/WebAssembly/event-section.ll +++ b/llvm/test/MC/WebAssembly/event-section.ll @@ -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 diff --git a/llvm/test/MC/WebAssembly/explicit-sections.ll b/llvm/test/MC/WebAssembly/explicit-sections.ll index e069cee..ab2bb16 100644 --- a/llvm/test/MC/WebAssembly/explicit-sections.ll +++ b/llvm/test/MC/WebAssembly/explicit-sections.ll @@ -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: ... diff --git a/llvm/test/MC/WebAssembly/function-sections.ll b/llvm/test/MC/WebAssembly/function-sections.ll index 8f1e29a..b9b9c28 100644 --- a/llvm/test/MC/WebAssembly/function-sections.ll +++ b/llvm/test/MC/WebAssembly/function-sections.ll @@ -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 diff --git a/llvm/test/MC/WebAssembly/global-ctor-dtor.ll b/llvm/test/MC/WebAssembly/global-ctor-dtor.ll index a759329..4dd8deb 100644 --- a/llvm/test/MC/WebAssembly/global-ctor-dtor.ll +++ b/llvm/test/MC/WebAssembly/global-ctor-dtor.ll @@ -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 diff --git a/llvm/test/MC/WebAssembly/unnamed-data.ll b/llvm/test/MC/WebAssembly/unnamed-data.ll index 4794902..ef7a0e5 100644 --- a/llvm/test/MC/WebAssembly/unnamed-data.ll +++ b/llvm/test/MC/WebAssembly/unnamed-data.ll @@ -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: ... diff --git a/llvm/test/MC/WebAssembly/weak-alias.ll b/llvm/test/MC/WebAssembly/weak-alias.ll index f0997c1..ea496db 100644 --- a/llvm/test/MC/WebAssembly/weak-alias.ll +++ b/llvm/test/MC/WebAssembly/weak-alias.ll @@ -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: ... diff --git a/llvm/test/Object/Inputs/trivial-object-test.wasm b/llvm/test/Object/Inputs/trivial-object-test.wasm index 8652d67f69222ab57610df1b13d3972e031460a1..a894522fa152ba86d59c6c585788e1467809f416 100644 GIT binary patch delta 28 kcmeyw^oeQ0Q%0tV&*FI)7&!Ejii`Ei5{sB72Qn%G0GOQ#KmY&$ delta 28 kcmeyw^oeQ0Q%1&#&*FI)894Nkii`Ei5{p