Vtables not position independent for target thumbv7em-none-eabi #54431
Labels
A-linkage
Area: linking into static, shared libraries and binaries
A-LLVM
Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.
C-feature-request
Category: A feature request, i.e: not implemented / a PR.
O-Arm
Target: 32-bit Arm processors (armv6, armv7, thumb...), including 64-bit Arm in AArch32 state
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Summary
I'm having trouble using dynamic dispatch for trait objects on a cortex-m4.
The setup is rather complicated as relocated binaries only make sense for binaries which will actually be relocated. In this case I try to run a tock app created with libtock-rs.
The vtables in the binary get relocated, however the content of the vtables is not position independent but pointing to the load addresses of the function to be called.
I have written a "fixup-routine" in the following pull request, however uses a very rough heuristics to identify vtables in the .rodata section:
tock/libtock-rs#56
Description of the problem
I compile (using nightly-2018-08-16) the traitobj-Example in the PR using ropi-relocation model. Access to the vtable works just fine as the addresses of the vtables are access relatively to the position of the application in flash. However, the addresses in the vtables point to the static load address in the binary of the functions to call.
Currently, I solve the problem using a fixup routine which fixes the addresses in the vtables (and potentially destroys other elements of .rodata).
Expected behavior
The addresses in the vtables should be accessed in a way which is position independent.
At least there should be a way to identify vtables in the .rodata segment such that at least theoretically the vtables could be fixed. However, recently the behavior of the Rust compiler changed so that it creates vtable-Symbols which don't carry names containing "vtable" anymore so for me it is impossible to find these symbols ( rust nightly 2018-06-14 stil creates symbols named vtable).
Provide information
The description provided here is relatively rough. Please help me providing the information necessary to investigate the problem.
The text was updated successfully, but these errors were encountered: