Commit 00b2e953 authored by Andrii Nakryiko's avatar Andrii Nakryiko Committed by Alexei Starovoitov

selftests/bpf: Add test validating failure on ambiguous relocation value

Add test simulating ambiguous field size relocation, while fields themselves
are at the exact same offset.
Signed-off-by: default avatarAndrii Nakryiko <andriin@fb.com>
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20200818223921.2911963-5-andriin@fb.com
parent 353c788c
...@@ -452,6 +452,7 @@ static struct core_reloc_test_case test_cases[] = { ...@@ -452,6 +452,7 @@ static struct core_reloc_test_case test_cases[] = {
/* size relocation checks */ /* size relocation checks */
SIZE_CASE(size), SIZE_CASE(size),
SIZE_CASE(size___diff_sz), SIZE_CASE(size___diff_sz),
SIZE_ERR_CASE(size___err_ambiguous),
}; };
struct data { struct data {
......
#include "core_reloc_types.h"
void f(struct core_reloc_size___err_ambiguous1 x,
struct core_reloc_size___err_ambiguous2 y) {}
...@@ -809,3 +809,28 @@ struct core_reloc_size___diff_sz { ...@@ -809,3 +809,28 @@ struct core_reloc_size___diff_sz {
void *ptr_field; void *ptr_field;
enum { OTHER_VALUE = 0xFFFFFFFFFFFFFFFF } enum_field; enum { OTHER_VALUE = 0xFFFFFFFFFFFFFFFF } enum_field;
}; };
/* Error case of two candidates with the fields (int_field) at the same
* offset, but with differing final relocation values: size 4 vs size 1
*/
struct core_reloc_size___err_ambiguous1 {
/* int at offset 0 */
int int_field;
struct { int x; } struct_field;
union { int x; } union_field;
int arr_field[4];
void *ptr_field;
enum { VALUE___1 = 123 } enum_field;
};
struct core_reloc_size___err_ambiguous2 {
/* char at offset 0 */
char int_field;
struct { int x; } struct_field;
union { int x; } union_field;
int arr_field[4];
void *ptr_field;
enum { VALUE___2 = 123 } enum_field;
};
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