-
Notifications
You must be signed in to change notification settings - Fork 44
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
Support additional 64bit immediate instruction modes #763
Comments
This documentation has helped me understand relocations: https://docs.kernel.org/bpf/llvm_reloc.html |
I have spent some time on the relocation issue. Consider the following simple example:
Its disassembly looks like this:
The relocations are at instructions
The symbol table:
The |
@Alan-Jowett, based on the algorithm you suggested above, should we keep each relocation in a separate region of its own (i.e., one region for I apologize if this seems confusing. I have limited knowledge about relocations and how the verifier already implements map relocations, and there is a possibility I am way off with the above description. |
@a-hamza-r this is what Linux / libbpf is doing: // Copyright (c) Prevail Verifier contributors.
// SPDX-License-Identifier: MIT
#include "bpf.h"
static volatile uint32_t global_var = 0;
static volatile uint32_t global_var_2 = 0;
int func(void* ctx) {
global_var ++;
global_var_2 += 2;
return 0;
} The xlated assembly is then:
The ELF file contains 1 .bss section with two relocations point to it and the xlated BPF byte code shows 1 array map of size == size of bss section. I think if verifier followed the same example, it would be a good thing. From reading the libbpf code, it names the section map as follows: So, assuming the program was called "global_variables.o" the map would be called: Given that the verifier's loader is already updating lddw instructions to set the source = 1 for map relocations, it may make sense to have it do the same for this type of relocation. |
https://www.ietf.org/archive/id/draft-ietf-bpf-isa-04.html#name-platform-variables
The BPF ISA at the IETF defines various 64bit immediate loads:
Currently the verifier only supports type 0 and type 1 loads.
Type 1 loads are supported here:
https://github.com/vbpf/ebpf-verifier/blob/16e06cf98c36848c0da804d71310041e4243642b/src/asm_files.cpp#L431C1-L435C22
To support type 3, the code should handle the case where the relocation is to a .rodata section (aka platform variables).
Behavior would be:
At that point, the rest of the code should operate correctly.
The text was updated successfully, but these errors were encountered: