[WebAssembly] Update relocation names to match spec

Summary: See https://github.com/WebAssembly/tool-conventions/blob/master/Linking.md

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

llvm-svn: 312342
This commit is contained in:
Sam Clegg 2017-09-01 17:32:01 +00:00
parent f483817fc1
commit 13a2e89926
14 changed files with 40 additions and 40 deletions

View File

@ -6,8 +6,8 @@
WASM_RELOC(R_WEBASSEMBLY_FUNCTION_INDEX_LEB, 0)
WASM_RELOC(R_WEBASSEMBLY_TABLE_INDEX_SLEB, 1)
WASM_RELOC(R_WEBASSEMBLY_TABLE_INDEX_I32, 2)
WASM_RELOC(R_WEBASSEMBLY_GLOBAL_ADDR_LEB, 3)
WASM_RELOC(R_WEBASSEMBLY_GLOBAL_ADDR_SLEB, 4)
WASM_RELOC(R_WEBASSEMBLY_GLOBAL_ADDR_I32, 5)
WASM_RELOC(R_WEBASSEMBLY_MEMORY_ADDR_LEB, 3)
WASM_RELOC(R_WEBASSEMBLY_MEMORY_ADDR_SLEB, 4)
WASM_RELOC(R_WEBASSEMBLY_MEMORY_ADDR_I32, 5)
WASM_RELOC(R_WEBASSEMBLY_TYPE_INDEX_LEB, 6)
WASM_RELOC(R_WEBASSEMBLY_GLOBAL_INDEX_LEB, 7)

View File

@ -142,9 +142,9 @@ struct WasmRelocationEntry {
bool hasAddend() const {
switch (Type) {
case wasm::R_WEBASSEMBLY_GLOBAL_ADDR_LEB:
case wasm::R_WEBASSEMBLY_GLOBAL_ADDR_SLEB:
case wasm::R_WEBASSEMBLY_GLOBAL_ADDR_I32:
case wasm::R_WEBASSEMBLY_MEMORY_ADDR_LEB:
case wasm::R_WEBASSEMBLY_MEMORY_ADDR_SLEB:
case wasm::R_WEBASSEMBLY_MEMORY_ADDR_I32:
return true;
default:
return false;
@ -495,9 +495,9 @@ uint32_t WasmObjectWriter::getRelocationIndexValue(
return IndirectSymbolIndices[RelEntry.Symbol];
case wasm::R_WEBASSEMBLY_FUNCTION_INDEX_LEB:
case wasm::R_WEBASSEMBLY_GLOBAL_INDEX_LEB:
case wasm::R_WEBASSEMBLY_GLOBAL_ADDR_LEB:
case wasm::R_WEBASSEMBLY_GLOBAL_ADDR_SLEB:
case wasm::R_WEBASSEMBLY_GLOBAL_ADDR_I32:
case wasm::R_WEBASSEMBLY_MEMORY_ADDR_LEB:
case wasm::R_WEBASSEMBLY_MEMORY_ADDR_SLEB:
case wasm::R_WEBASSEMBLY_MEMORY_ADDR_I32:
if (!SymbolIndices.count(RelEntry.Symbol))
report_fatal_error("symbol not found function/global index space: " +
RelEntry.Symbol->getName());
@ -537,17 +537,17 @@ void WasmObjectWriter::applyRelocations(
WriteI32(Stream, Index, Offset);
break;
}
case wasm::R_WEBASSEMBLY_GLOBAL_ADDR_SLEB: {
case wasm::R_WEBASSEMBLY_MEMORY_ADDR_SLEB: {
uint32_t Value = ProvisionalValue(RelEntry);
WritePatchableSLEB(Stream, Value, Offset);
break;
}
case wasm::R_WEBASSEMBLY_GLOBAL_ADDR_LEB: {
case wasm::R_WEBASSEMBLY_MEMORY_ADDR_LEB: {
uint32_t Value = ProvisionalValue(RelEntry);
WritePatchableLEB(Stream, Value, Offset);
break;
}
case wasm::R_WEBASSEMBLY_GLOBAL_ADDR_I32: {
case wasm::R_WEBASSEMBLY_MEMORY_ADDR_I32: {
uint32_t Value = ProvisionalValue(RelEntry);
WriteI32(Stream, Value, Offset);
break;
@ -967,7 +967,7 @@ void WasmObjectWriter::writeObject(MCAssembler &Asm,
for (const WasmRelocationEntry &RelEntry : CodeRelocations) {
switch (RelEntry.Type) {
case wasm::R_WEBASSEMBLY_TABLE_INDEX_SLEB:
case wasm::R_WEBASSEMBLY_GLOBAL_ADDR_SLEB:
case wasm::R_WEBASSEMBLY_MEMORY_ADDR_SLEB:
IsAddressTaken.insert(RelEntry.Symbol);
break;
default:
@ -977,7 +977,7 @@ void WasmObjectWriter::writeObject(MCAssembler &Asm,
for (const WasmRelocationEntry &RelEntry : DataRelocations) {
switch (RelEntry.Type) {
case wasm::R_WEBASSEMBLY_TABLE_INDEX_I32:
case wasm::R_WEBASSEMBLY_GLOBAL_ADDR_I32:
case wasm::R_WEBASSEMBLY_MEMORY_ADDR_I32:
IsAddressTaken.insert(RelEntry.Symbol);
break;
default:

View File

@ -395,9 +395,9 @@ Error WasmObjectFile::parseRelocSection(StringRef Name, const uint8_t *Ptr,
case wasm::R_WEBASSEMBLY_TYPE_INDEX_LEB:
case wasm::R_WEBASSEMBLY_GLOBAL_INDEX_LEB:
break;
case wasm::R_WEBASSEMBLY_GLOBAL_ADDR_LEB:
case wasm::R_WEBASSEMBLY_GLOBAL_ADDR_SLEB:
case wasm::R_WEBASSEMBLY_GLOBAL_ADDR_I32:
case wasm::R_WEBASSEMBLY_MEMORY_ADDR_LEB:
case wasm::R_WEBASSEMBLY_MEMORY_ADDR_SLEB:
case wasm::R_WEBASSEMBLY_MEMORY_ADDR_I32:
Reloc.Addend = readVarint32(Ptr);
break;
default:

View File

@ -73,7 +73,7 @@ WebAssemblyWasmObjectWriter::getRelocType(const MCValue &Target,
case WebAssembly::fixup_code_sleb128_i32:
if (IsFunction)
return wasm::R_WEBASSEMBLY_TABLE_INDEX_SLEB;
return wasm::R_WEBASSEMBLY_GLOBAL_ADDR_SLEB;
return wasm::R_WEBASSEMBLY_MEMORY_ADDR_SLEB;
case WebAssembly::fixup_code_sleb128_i64:
llvm_unreachable("fixup_sleb128_i64 not implemented yet");
case WebAssembly::fixup_code_uleb128_i32:
@ -81,11 +81,11 @@ WebAssemblyWasmObjectWriter::getRelocType(const MCValue &Target,
return wasm::R_WEBASSEMBLY_TYPE_INDEX_LEB;
if (IsFunction)
return wasm::R_WEBASSEMBLY_FUNCTION_INDEX_LEB;
return wasm::R_WEBASSEMBLY_GLOBAL_ADDR_LEB;
return wasm::R_WEBASSEMBLY_MEMORY_ADDR_LEB;
case FK_Data_4:
if (IsFunction)
return wasm::R_WEBASSEMBLY_TABLE_INDEX_I32;
return wasm::R_WEBASSEMBLY_GLOBAL_ADDR_I32;
return wasm::R_WEBASSEMBLY_MEMORY_ADDR_I32;
case FK_Data_8:
llvm_unreachable("FK_Data_8 not implemented yet");
default:

View File

@ -9,7 +9,7 @@
; CHECK: - Type: DATA
; CHECK: Relocations:
; CHECK: - Type: R_WEBASSEMBLY_GLOBAL_ADDR_I32
; CHECK: - Type: R_WEBASSEMBLY_MEMORY_ADDR_I32
; CHECK: Index: 0
; CHECK: Offset: 0x0000000E
; CHECK: Segments:

View File

@ -24,13 +24,13 @@ entry:
; CHECK: Relocations [
; CHECK-NEXT: Section (8) CODE {
; CHECK-NEXT: Relocation {
; CHECK-NEXT: Type: R_WEBASSEMBLY_GLOBAL_ADDR_LEB (3)
; CHECK-NEXT: Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB (3)
; CHECK-NEXT: Offset: 0x9
; CHECK-NEXT: Index: 0x0
; CHECK-NEXT: Addend: 0
; CHECK-NEXT: }
; CHECK-NEXT: Relocation {
; CHECK-NEXT: Type: R_WEBASSEMBLY_GLOBAL_ADDR_LEB (3)
; CHECK-NEXT: Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB (3)
; CHECK-NEXT: Offset: 0x14
; CHECK-NEXT: Index: 0x1
; CHECK-NEXT: Addend: 0

View File

@ -11,13 +11,13 @@
; CHECK: Relocations [
; CHECK: Section (6) DATA {
; CHECK: Relocation {
; CHECK: Type: R_WEBASSEMBLY_GLOBAL_ADDR_I32 (5)
; CHECK: Type: R_WEBASSEMBLY_MEMORY_ADDR_I32 (5)
; CHECK: Offset: 0xE
; CHECK: Index: 0x0
; CHECK: Addend: 8
; CHECK: }
; CHECK: Relocation {
; CHECK: Type: R_WEBASSEMBLY_GLOBAL_ADDR_I32 (5)
; CHECK: Type: R_WEBASSEMBLY_MEMORY_ADDR_I32 (5)
; CHECK: Offset: 0x16
; CHECK: Index: 0x1
; CHECK: Addend: -16

View File

@ -39,10 +39,10 @@
; CHECK-NEXT: Index: 3
; CHECK-NEXT: - Type: DATA
; CHECK-NEXT: Relocations:
; CHECK-NEXT: - Type: R_WEBASSEMBLY_GLOBAL_ADDR_I32
; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_I32
; CHECK-NEXT: Index: 0
; CHECK-NEXT: Offset: 0x00000016
; CHECK-NEXT: - Type: R_WEBASSEMBLY_GLOBAL_ADDR_I32
; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_I32
; CHECK-NEXT: Index: 1
; CHECK-NEXT: Offset: 0x0000001E
; CHECK-NEXT: Segments:

View File

@ -60,7 +60,7 @@ ELF-MIPSEL: R_MIPS_CALL16 puts
ELF-MIPSEL: R_MIPS_CALL16 SomeOtherFunction
WASM: CODE
WASM-NEXT: R_WEBASSEMBLY_GLOBAL_ADDR_SLEB 0+0
WASM-NEXT: R_WEBASSEMBLY_MEMORY_ADDR_SLEB 0+0
WASM-NEXT: R_WEBASSEMBLY_FUNCTION_INDEX_LEB 0+0
WASM-NEXT: R_WEBASSEMBLY_FUNCTION_INDEX_LEB 1+0

View File

@ -14,11 +14,11 @@ Sections:
Value: 4
Content: '10001000'
Relocations:
- Type: R_WEBASSEMBLY_GLOBAL_ADDR_I32
- Type: R_WEBASSEMBLY_MEMORY_ADDR_I32
Index: 0
Offset: 0x00000006
Addend: 8
- Type: R_WEBASSEMBLY_GLOBAL_ADDR_I32
- Type: R_WEBASSEMBLY_MEMORY_ADDR_I32
Index: 0
Offset: 0x00000006
Addend: -6
@ -29,11 +29,11 @@ Sections:
# CHECK: Sections:
# CHECK: - Type: DATA
# CHECK-NEXT: Relocations:
# CHECK-NEXT: - Type: R_WEBASSEMBLY_GLOBAL_ADDR_I32
# CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_I32
# CHECK-NEXT: Index: 0
# CHECK-NEXT: Offset: 0x00000006
# CHECK-NEXT: Addend: 8
# CHECK-NEXT: - Type: R_WEBASSEMBLY_GLOBAL_ADDR_I32
# CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_I32
# CHECK-NEXT: Index: 0
# CHECK-NEXT: Offset: 0x00000006
# CHECK-NEXT: Addend: -6

View File

@ -5,4 +5,4 @@
@bar = hidden global i32* @foo2, align 4
; CHECK: RELOCATION RECORDS FOR [DATA]:
; CHECK-NEXT: 0000000e R_WEBASSEMBLY_GLOBAL_ADDR_I32 1+0
; CHECK-NEXT: 0000000e R_WEBASSEMBLY_MEMORY_ADDR_I32 1+0

View File

@ -289,7 +289,7 @@ MACHO-ARM-NEXT: ]
WASM: Relocations [
WASM-NEXT: Section (8) CODE {
WASM-NEXT: Relocation {
WASM-NEXT: Type: R_WEBASSEMBLY_GLOBAL_ADDR_SLEB (4)
WASM-NEXT: Type: R_WEBASSEMBLY_MEMORY_ADDR_SLEB (4)
WASM-NEXT: Offset: 0x4
WASM-NEXT: Index: 0x0
WASM-NEXT: Addend: 0

View File

@ -83,9 +83,9 @@ void WasmDumper::printRelocation(const SectionRef &Section,
bool HasAddend = false;
switch (RelocType) {
case wasm::R_WEBASSEMBLY_GLOBAL_ADDR_LEB:
case wasm::R_WEBASSEMBLY_GLOBAL_ADDR_SLEB:
case wasm::R_WEBASSEMBLY_GLOBAL_ADDR_I32:
case wasm::R_WEBASSEMBLY_MEMORY_ADDR_LEB:
case wasm::R_WEBASSEMBLY_MEMORY_ADDR_SLEB:
case wasm::R_WEBASSEMBLY_MEMORY_ADDR_I32:
HasAddend = true;
break;
default:

View File

@ -370,9 +370,9 @@ int WasmWriter::writeRelocSection(raw_ostream &OS,
encodeULEB128(Reloc.Offset, OS);
encodeULEB128(Reloc.Index, OS);
switch (Reloc.Type) {
case wasm::R_WEBASSEMBLY_GLOBAL_ADDR_LEB:
case wasm::R_WEBASSEMBLY_GLOBAL_ADDR_SLEB:
case wasm::R_WEBASSEMBLY_GLOBAL_ADDR_I32:
case wasm::R_WEBASSEMBLY_MEMORY_ADDR_LEB:
case wasm::R_WEBASSEMBLY_MEMORY_ADDR_SLEB:
case wasm::R_WEBASSEMBLY_MEMORY_ADDR_I32:
encodeULEB128(Reloc.Addend, OS);
}
}