[all-commits] [llvm/llvm-project] 7d2c2a: [lld][WebAssembly] Return 0 for synthetic function...
Heejin Ahn via All-commits
all-commits at lists.llvm.org
Fri Jun 21 15:56:24 PDT 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 7d2c2af0453c28d0902668523099a1f46a0bc348
https://github.com/llvm/llvm-project/commit/7d2c2af0453c28d0902668523099a1f46a0bc348
Author: Heejin Ahn <aheejin at gmail.com>
Date: 2024-06-21 (Fri, 21 Jun 2024)
Changed paths:
A lld/test/wasm/Inputs/signature-mismatch-debug-info-a.s
A lld/test/wasm/Inputs/signature-mismatch-debug-info-b.s
A lld/test/wasm/Inputs/signature-mismatch-debug-info-main.s
A lld/test/wasm/signature-mismatch-debug-info.test
M lld/wasm/InputChunks.h
Log Message:
-----------
[lld][WebAssembly] Return 0 for synthetic function offsets (#96134)
When two or more functions' signatures differ, one of them is selected
and for other signatures `unreachable` stubs are generated:
https://github.com/llvm/llvm-project/blob/57778ec36c9c7e96b76a167f19dccbe00d49c9d4/lld/wasm/SymbolTable.cpp#L975
https://github.com/llvm/llvm-project/blob/57778ec36c9c7e96b76a167f19dccbe00d49c9d4/lld/wasm/SymbolTable.cpp#L852-L870
And when these `SyntheticFunction`s are generated, this constructor is
used,
https://github.com/llvm/llvm-project/blob/57778ec36c9c7e96b76a167f19dccbe00d49c9d4/lld/wasm/InputChunks.h#L266-L269
which does not set its `function` field:
https://github.com/llvm/llvm-project/blob/57778ec36c9c7e96b76a167f19dccbe00d49c9d4/lld/wasm/InputChunks.h#L304
As a result, the `function` field contains a garbage value for these
stub functions.
`InputFunction::getFunctionCodeOffset()` is called when relocations are
resolved for `.debug_info` section to get functions' PC locations. But
because these stub functions don't have their `function` field set, this
function segfaults:
https://github.com/llvm/llvm-project/blob/57778ec36c9c7e96b76a167f19dccbe00d49c9d4/lld/wasm/InputChunks.h#L282
This bug seems to be triggered when these conditions are met:
- There is a signature mismatch warning with multiple different
definitions (one definition with other declarations is not sufficient)
with weak linkage with the same name
- The 'stub' function containing unreachable has a callsite, meaning it
isn't DCE'd
- .debug_info section is generated (i.e., DWARF is used)
This PR initializes the field with `nullptr`, and in
`InputFunction::getFunctionCodeOffset`, checks if `function` is
`nullptr`, and if so, just returns 0. This function is called only for
resolving relocations in the `.debug_info` section, and addresses of
these stub functions, which are not the functions users wrote in the
first place, are not really meaningful anyway.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list