forked from rlane/ubpf
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixup! [WIP] Make the JIT'd code completely portable.
Add arm64
- Loading branch information
Showing
8 changed files
with
441 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
8f 00 00 00 01 00 00 00 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright (c) Microsoft Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#include <vector> | ||
#include <string> | ||
#include <iostream> | ||
|
||
extern "C" | ||
{ | ||
#include "ebpf.h" | ||
#include "ubpf.h" | ||
} | ||
|
||
#include "ubpf_custom_test_support.h" | ||
|
||
/** | ||
* @brief This program reads BPF instructions from stdin and memory contents from | ||
* the first agument. It then executes the BPF program and prints the | ||
* value of %r0 at the end of execution. | ||
*/ | ||
int main() | ||
{ | ||
std::string expected_error{"Failed to load program: unknown opcode 0x8f at PC 0" }; | ||
ubpf_jit_fn jit_fn; | ||
|
||
std::string program_string; | ||
std::getline(std::cin, program_string); | ||
|
||
std::vector<ebpf_inst> program = bytes_to_ebpf_inst(base16_decode(program_string)); | ||
|
||
ubpf_vm_up vm(ubpf_create(), ubpf_destroy); | ||
std::string error{}; | ||
|
||
if (!ubpf_setup_custom_test( | ||
vm, | ||
program_string, | ||
custom_test_fixup_cb{[](ubpf_vm_up&, std::string& ) { | ||
return true; | ||
}}, | ||
jit_fn, | ||
error)) { | ||
|
||
if (jit_fn == nullptr && expected_error == error) | ||
return 0; | ||
} | ||
|
||
return 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.