[WebAssembly] Reorder reloc sections to come between symtab and name
authorNicholas Wilson <nicholas@nicholaswilson.me.uk>
Mon, 5 Mar 2018 12:59:03 +0000 (12:59 +0000)
committerNicholas Wilson <nicholas@nicholaswilson.me.uk>
Mon, 5 Mar 2018 12:59:03 +0000 (12:59 +0000)
This is required in order to enable relocs to be validated
as they are read in.

Also update tests with new section ordering.

Differential Revision: https://reviews.llvm.org/D43940

llvm-svn: 326694

llvm/lib/MC/WasmObjectWriter.cpp
llvm/test/Object/Inputs/trivial-object-test.wasm
llvm/test/tools/llvm-objdump/Inputs/trivial.obj.wasm
llvm/test/tools/llvm-objdump/wasm.txt
llvm/test/tools/llvm-readobj/Inputs/trivial.obj.wasm
llvm/test/tools/llvm-readobj/sections.test

index 3c86ca4..87ef0d9 100644 (file)
@@ -1307,9 +1307,9 @@ void WasmObjectWriter::writeObject(MCAssembler &Asm,
   writeElemSection(TableElems);
   writeCodeSection(Asm, Layout, Functions);
   writeDataSection();
+  writeLinkingMetaDataSection(SymbolInfos, InitFuncs, Comdats);
   writeCodeRelocSection();
   writeDataRelocSection();
-  writeLinkingMetaDataSection(SymbolInfos, InitFuncs, Comdats);
 
   // TODO: Translate the .comment section to the output.
   // TODO: Translate debug sections to the output.
index ae1c987..0c91bf2 100644 (file)
Binary files a/llvm/test/Object/Inputs/trivial-object-test.wasm and b/llvm/test/Object/Inputs/trivial-object-test.wasm differ
index ae1c987..0c91bf2 100644 (file)
Binary files a/llvm/test/tools/llvm-objdump/Inputs/trivial.obj.wasm and b/llvm/test/tools/llvm-objdump/Inputs/trivial.obj.wasm differ
index 5b88b63..ef6265c 100644 (file)
@@ -7,8 +7,8 @@
 # CHECK-NEXT:  2 FUNCTION      00000002 0000000000000000
 # CHECK-NEXT:  3 CODE          00000019 0000000000000000 TEXT
 # CHECK-NEXT:  4 DATA          0000001c 0000000000000000 DATA
-# CHECK-NEXT:  5 reloc.CODE    00000017 0000000000000000
-# CHECK-NEXT:  6 linking       00000055 0000000000000000
+# CHECK-NEXT:  5 linking       00000055 0000000000000000
+# CHECK-NEXT:  6 reloc.CODE    00000017 0000000000000000
 
 # RUN: llvm-objdump -p %p/Inputs/trivial.obj.wasm | FileCheck %s -check-prefix CHECK-HEADER
 
index 416e577..326bbc4 100644 (file)
Binary files a/llvm/test/tools/llvm-readobj/Inputs/trivial.obj.wasm and b/llvm/test/tools/llvm-readobj/Inputs/trivial.obj.wasm differ
index 64f2954..a243b7c 100644 (file)
@@ -528,14 +528,14 @@ WASM-NEXT:     ]
 WASM-NEXT:   }
 WASM-NEXT:   Section {
 WASM-NEXT:     Type: CUSTOM (0x0)
-WASM-NEXT:     Size: 23
+WASM-NEXT:     Size: 65
 WASM-NEXT:     Offset: 191
-WASM-NEXT:     Name: reloc.CODE
+WASM-NEXT:     Name: linking
 WASM-NEXT:   }
 WASM-NEXT:   Section {
 WASM-NEXT:     Type: CUSTOM (0x0)
-WASM-NEXT:     Size: 65
-WASM-NEXT:     Offset: 220
-WASM-NEXT:     Name: linking
+WASM-NEXT:     Size: 23
+WASM-NEXT:     Offset: 262
+WASM-NEXT:     Name: reloc.CODE
 WASM-NEXT:   }
 WASM-NEXT: ]