Commit 2e2c6d3f authored by Ilya Leoshkevich's avatar Ilya Leoshkevich Committed by Andrii Nakryiko

selftests/bpf: Fix test_core_reloc_mods on big-endian machines

This is the same as commit d164dd9a ("selftests/bpf: Fix
test_core_autosize on big-endian machines"), but for
test_core_reloc_mods.
Signed-off-by: default avatarIlya Leoshkevich <iii@linux.ibm.com>
Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20211026010831.748682-7-iii@linux.ibm.com
parent 3e7ed9ce
......@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment