Skip to content

Commit

Permalink
selftests/bpf: Fix test_core_reloc_mods on big-endian machines
Browse files Browse the repository at this point in the history
This is the same as commit d164dd9 ("selftests/bpf: Fix
test_core_autosize on big-endian machines"), but for
test_core_reloc_mods.

Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20211026010831.748682-7-iii@linux.ibm.com
  • Loading branch information
Ilya Leoshkevich authored and Andrii Nakryiko committed Oct 26, 2021
1 parent 3e7ed9c commit 2e2c6d3
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tools/testing/selftests/bpf/progs/test_core_reloc_mods.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,16 @@ struct core_reloc_mods {
core_reloc_mods_substruct_t h;
};

#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
#define CORE_READ(dst, src) bpf_core_read(dst, sizeof(*(dst)), src)
#else
#define CORE_READ(dst, src) ({ \
int __sz = sizeof(*(dst)) < sizeof(*(src)) ? sizeof(*(dst)) : \
sizeof(*(src)); \
bpf_core_read((char *)(dst) + sizeof(*(dst)) - __sz, __sz, \
(const char *)(src) + sizeof(*(src)) - __sz); \
})
#endif

SEC("raw_tracepoint/sys_enter")
int test_core_mods(void *ctx)
Expand Down

0 comments on commit 2e2c6d3

Please sign in to comment.