-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[RISC-V] Unlinked obj file branches contain a fake infinite-loop destination. #104853
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
CC @MaskRay |
A fixup describes a modified section location. LLVM's choice is simpler and enables better compression. We can use |
@llvm/issue-subscribers-backend-risc-v Author: Patrick O'Neill (patrick-rivos)
Using the same input assembly file from:
```c
int x = 0;
int min(int y)
{
while (x != 192) {
x += 1;
}
return y;
}
int main() {
min(1);
}
```
gnu-as assembled program looks normal:
```
map-binutils.o: file format elf64-littleriscv
Disassembly of section .text: 0000000000000000 <min>: 0000000000000014 <.LBB0_2>: 0000000000000016 <main>: 000000000000002a <.LBB1_2>:
map.o: file format elf64-littleriscv Disassembly of section .text: 0000000000000000 <min>: 0000000000000016 <main>:
000000000001129e <min>:
|
Thanks for the reply. Just a note that
In my opinion those are easier to reason about since the relocation objdumps to include the function name so I don't need to cross-reference the headers:
From LLVM's side it seems simpler to implement but the user experience of chasing down branch destinations is not simple (at least the way I'm doing it :-) ). I'm speaking out of ignorance here - maybe I don't understand the magnitude of the savings here or how often unlinked obj files are compressed - but compression seems like strange justification for this behavior. |
Using the same input assembly file from:
gnu-as assembled program looks normal:
But LLVM's obj file looks like: (each branch is an infinite loop)
gnu-objdump and llvm-objdump agree on this output so it's probably not on the objdump side of things.
When actually linked the offsets are updated to the correct addresses (with both lld/ld):
I think the actual dests in the LLVM obj file are encoded using R_RISCV_BRANCH.
This behavior makes inspecting unlinked object files unintuitive at first glance.
The text was updated successfully, but these errors were encountered: