Skip to content

Commit

Permalink
link: fix TestExecutableLazyLoadSymbols on arm64
Browse files Browse the repository at this point in the history
Creating a uprobe on arm64 validates that the address is a multiple
of AARCH64_INSN_SIZE aka 4. The tests currently uses 123 which isn't
divisible by 4 and hence we get EINVAL on arm64. Fix this by using
an address that is divisible by 4.

Signed-off-by: Lorenz Bauer <lmb@isovalent.com>
  • Loading branch information
lmb committed Dec 6, 2023
1 parent 175abb2 commit 6d15172
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions link/uprobe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,17 @@ func TestExecutableLazyLoadSymbols(t *testing.T) {
ex, err := OpenExecutable("/bin/bash")
qt.Assert(t, qt.IsNil(err))
// Addresses must be empty, will be lazy loaded.
qt.Assert(t, qt.DeepEquals(ex.addresses, map[string]uint64{}))
qt.Assert(t, qt.HasLen(ex.addresses, 0))

prog := mustLoadProgram(t, ebpf.Kprobe, 0, "")
up, err := ex.Uprobe(bashSym, prog, &UprobeOptions{Address: 123})
// Address must be a multiple of 4 on arm64, see
// https://elixir.bootlin.com/linux/v6.6.4/source/arch/arm64/kernel/probes/uprobes.c#L42
up, err := ex.Uprobe(bashSym, prog, &UprobeOptions{Address: 124})
qt.Assert(t, qt.IsNil(err))
up.Close()

// Addresses must still be empty as Address has been provided via options.
qt.Assert(t, qt.DeepEquals(ex.addresses, map[string]uint64{}))
qt.Assert(t, qt.HasLen(ex.addresses, 0))

up, err = ex.Uprobe(bashSym, prog, nil)
qt.Assert(t, qt.IsNil(err))
Expand Down

0 comments on commit 6d15172

Please sign in to comment.