[llvm] 665d1a0 - Revert "[WebAssembly][Object]Use file offset as function symbol address for linked files (#76198)"
Mitch Phillips via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 3 02:23:20 PST 2024
Author: Mitch Phillips
Date: 2024-01-03T11:23:10+01:00
New Revision: 665d1a0eb4e50cdc1b6f0f678a4c2b1e1875dc66
URL: https://github.com/llvm/llvm-project/commit/665d1a0eb4e50cdc1b6f0f678a4c2b1e1875dc66
DIFF: https://github.com/llvm/llvm-project/commit/665d1a0eb4e50cdc1b6f0f678a4c2b1e1875dc66.diff
LOG: Revert "[WebAssembly][Object]Use file offset as function symbol address for linked files (#76198)"
This reverts commit fc5f51cf5af4364b38bf22e491d46e1e892ade0c.
Reason: Broke the sanitizer buildbot -
https://lab.llvm.org/buildbot/#/builders/5/builds/39751/steps/12/logs/stdio
Added:
Modified:
llvm/lib/Object/WasmObjectFile.cpp
Removed:
llvm/test/tools/llvm-nm/wasm/linked.yaml
llvm/test/tools/llvm-objdump/wasm/linked-symbol-table.yaml
################################################################################
diff --git a/llvm/lib/Object/WasmObjectFile.cpp b/llvm/lib/Object/WasmObjectFile.cpp
index ccc29d0cb73d61..40665d686cf939 100644
--- a/llvm/lib/Object/WasmObjectFile.cpp
+++ b/llvm/lib/Object/WasmObjectFile.cpp
@@ -1667,18 +1667,10 @@ Expected<StringRef> WasmObjectFile::getSymbolName(DataRefImpl Symb) const {
Expected<uint64_t> WasmObjectFile::getSymbolAddress(DataRefImpl Symb) const {
auto &Sym = getWasmSymbol(Symb);
if (Sym.Info.Kind == wasm::WASM_SYMBOL_TYPE_FUNCTION &&
- isDefinedFunctionIndex(Sym.Info.ElementIndex)) {
- // For object files, use the section offset. The linker relies on this.
- // For linked files, use the file offset. This behavior matches the way
- // browsers print stack traces and is useful for binary size analysis.
- // (see https://webassembly.github.io/spec/web-api/index.html#conventions)
- uint32_t Adjustment = isRelocatableObject() || isSharedObject()
- ? 0
- : Sections[CodeSection].Offset;
- return getDefinedFunction(Sym.Info.ElementIndex).CodeSectionOffset +
- Adjustment;
- }
- return getSymbolValue(Symb);
+ isDefinedFunctionIndex(Sym.Info.ElementIndex))
+ return getDefinedFunction(Sym.Info.ElementIndex).CodeSectionOffset;
+ else
+ return getSymbolValue(Symb);
}
uint64_t WasmObjectFile::getWasmSymbolValue(const WasmSymbol &Sym) const {
diff --git a/llvm/test/tools/llvm-nm/wasm/linked.yaml b/llvm/test/tools/llvm-nm/wasm/linked.yaml
deleted file mode 100644
index 992c1811743b7a..00000000000000
--- a/llvm/test/tools/llvm-nm/wasm/linked.yaml
+++ /dev/null
@@ -1,74 +0,0 @@
-# RUN: yaml2obj %s -o %t.wasm
-# RUN: llvm-nm %t.wasm | FileCheck %s
-
-# CHECK: 0000009f T my_func_export
-# CHECK-NEXT: 0000002a D my_global_export
-# CHECK-NEXT: 00000000 D my_table_export
-
---- !WASM
-FileHeader:
- Version: 0x1
-Sections:
- - Type: TYPE
- Signatures:
- - Index: 0
- ParamTypes: []
- ReturnTypes: []
- - Type: IMPORT
- Imports:
- - Module: env
- Field: foo
- Kind: FUNCTION
- SigIndex: 0
- - Module: env
- Field: bar
- Kind: GLOBAL
- GlobalType: I32
- GlobalMutable: true
- - Module: env
- Field: memory
- Kind: MEMORY
- Memory:
- Minimum: 0x1
- - Type: FUNCTION
- FunctionTypes: [ 0 ]
- - Type: TABLE
- Tables:
- - Index: 0
- ElemType: FUNCREF
- Limits:
- Flags: [ HAS_MAX ]
- Minimum: 0x1
- Maximum: 0x1
- - Type: GLOBAL
- Globals:
- - Index: 1
- Mutable: false
- Type: I32
- InitExpr:
- Opcode: I32_CONST
- Value: 42
- - Type: EXPORT
- Exports:
- - Name: my_func_export
- Kind: FUNCTION
- Index: 1
- - Name: my_global_export
- Kind: GLOBAL
- Index: 1
- - Name: my_table_export
- Kind: TABLE
- Index: 0
- - Type: CODE
- Functions:
- - Index: 1
- Locals:
- Body: 00
- - Type: DATA
- Segments:
- - SectionOffset: 0
- InitFlags: 0
- Offset:
- Opcode: I32_CONST
- Value: 0
- Content: ''
diff --git a/llvm/test/tools/llvm-objdump/wasm/linked-symbol-table.yaml b/llvm/test/tools/llvm-objdump/wasm/linked-symbol-table.yaml
deleted file mode 100644
index 6dd949a441496c..00000000000000
--- a/llvm/test/tools/llvm-objdump/wasm/linked-symbol-table.yaml
+++ /dev/null
@@ -1,75 +0,0 @@
-# RUN: yaml2obj %s -o %t.wasm
-# RUN: llvm-objdump -t %t.wasm | FileCheck %s
-#
-# CHECK: SYMBOL TABLE:
-# CHECK-NEXT: 0000009f g F CODE my_func_export
-# CHECK-NEXT: 0000002a g O DATA my_global_export
-# CHECK-NEXT: 00000000 g TABLE my_table_export
-
---- !WASM
-FileHeader:
- Version: 0x1
-Sections:
- - Type: TYPE
- Signatures:
- - Index: 0
- ParamTypes: []
- ReturnTypes: []
- - Type: IMPORT
- Imports:
- - Module: env
- Field: foo
- Kind: FUNCTION
- SigIndex: 0
- - Module: env
- Field: bar
- Kind: GLOBAL
- GlobalType: I32
- GlobalMutable: true
- - Module: env
- Field: memory
- Kind: MEMORY
- Memory:
- Minimum: 0x1
- - Type: FUNCTION
- FunctionTypes: [ 0 ]
- - Type: TABLE
- Tables:
- - Index: 0
- ElemType: FUNCREF
- Limits:
- Flags: [ HAS_MAX ]
- Minimum: 0x1
- Maximum: 0x1
- - Type: GLOBAL
- Globals:
- - Index: 1
- Mutable: false
- Type: I32
- InitExpr:
- Opcode: I32_CONST
- Value: 42
- - Type: EXPORT
- Exports:
- - Name: my_func_export
- Kind: FUNCTION
- Index: 1
- - Name: my_global_export
- Kind: GLOBAL
- Index: 1
- - Name: my_table_export
- Kind: TABLE
- Index: 0
- - Type: CODE
- Functions:
- - Index: 1
- Locals:
- Body: 00
- - Type: DATA
- Segments:
- - SectionOffset: 0
- InitFlags: 0
- Offset:
- Opcode: I32_CONST
- Value: 0
- Content: ''
More information about the llvm-commits
mailing list