Skip to content

Error: error relocating function #1307

@ayush-san

Description

@ayush-san

I am getting the following error when trying to run the code

RUST_LOG=info cargo run --release --config 'target."cfg(all())".runner="sudo -E"'

Error:

warning: [email protected]:    Compiling proc-macro2 v1.0.95
warning: [email protected]:    Compiling unicode-ident v1.0.18
warning: [email protected]:    Compiling compiler_builtins v0.1.160 (/home/ayush.chauhan/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/compiler-builtins/compiler-builtins)
warning: [email protected]:    Compiling quote v1.0.40
warning: [email protected]:    Compiling rustversion v1.0.21
warning: [email protected]:    Compiling syn v2.0.104
warning: [email protected]:    Compiling version_check v0.9.5
warning: [email protected]:    Compiling core v0.0.0 (/home/ayush.chauhan/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core)
warning: [email protected]:    Compiling num_enum_derive v0.7.4
warning: [email protected]:    Compiling proc-macro-error-attr v1.0.4
warning: [email protected]:    Compiling proc-macro-error v1.0.4
warning: [email protected]:    Compiling aya-ebpf-cty v0.2.2
warning: [email protected]:    Compiling rustix v0.38.44
warning: [email protected]:    Compiling num_enum v0.7.4
warning: [email protected]:    Compiling linux-raw-sys v0.4.15
warning: [email protected]:    Compiling bitflags v2.9.1
warning: [email protected]:    Compiling aya-ebpf-bindings v0.1.1
warning: [email protected]:    Compiling aya-log-common v0.1.15
warning: [email protected]:    Compiling aya-ebpf v0.1.1
warning: [email protected]:    Compiling home v0.5.11
warning: [email protected]:    Compiling either v1.15.0
warning: [email protected]:    Compiling which v6.0.3
warning: [email protected]:    Compiling aya-ebpf-macros v0.1.1
warning: [email protected]:    Compiling aya-log-parser v0.1.13
warning: [email protected]:    Compiling aya-log-ebpf-macros v0.1.0
warning: [email protected]:    Compiling network-monitor-ebpf v0.1.0 (/home/ayush.chauhan/network-monitor/network-monitor-ebpf)
warning: [email protected]:    Compiling network-monitor-common v0.1.0 (/home/ayush.chauhan/network-monitor/network-monitor-common)
warning: [email protected]:    Compiling log v0.4.27
warning: [email protected]:    Compiling aya-log-ebpf v0.1.1
warning: [email protected]:     Finished `release` profile [optimized] target(s) in 31.41s
    Finished `release` profile [optimized] target(s) in 0.29s
     Running `sudo -E target/release/network-monitor`
Error: error relocating function

Caused by:
    0: error relocating `ssl_read`
    1: section `8` not found, referenced by symbol `` #6

User space code

let p_read: &mut UProbe = ebpf.program_mut("ssl_read").unwrap().try_into()?;
p_read.load()?;
p_read.attach(Some("SSL_read"), 0, OPEN_SSL_PATH, opt.pid)?;

EBPF Code

#[uprobe]
pub fn ssl_read(ctx: ProbeContext) -> u32 {
    match try_ssl(ctx) {
        Ok(ret) => ret,
        Err(ret) => ret,
    }
}

// `try_ssl` function is an eBPF probe for capturing SSL data.
fn try_ssl(ctx: ProbeContext) -> Result<u32, u32> {
    info!(&ctx, "function try_ssl called by /lib64/libssl.so.10");
    Ok(0)
}

I generated the prject using the aya-template

cargo generate --name network-monitor -d program_type=uprobe https://github.com/aya-rs/aya-template

I have debugged that I am able to run the code if I remove EbpfLogger init from network-monitor/src/main.rs and its usage in network-monitor-ebpf/src/main.rs. But then I am not able log anything in ebpf code to debug

Linux information

> cat /etc/os-release
NAME="Amazon Linux AMI"
VERSION="2018.03"
ID="amzn"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions