@@ -3550,6 +3550,40 @@ static struct btf_raw_test raw_tests[] = {
3550
3550
},
3551
3551
BTF_STR_SEC ("\0x\0?.foo bar:buz" ),
3552
3552
},
3553
+ {
3554
+ .descr = "datasec: name with non-printable first char not is ok" ,
3555
+ .raw_types = {
3556
+ /* int */
3557
+ BTF_TYPE_INT_ENC (0 , BTF_INT_SIGNED , 0 , 32 , 4 ), /* [1] */
3558
+ /* VAR x */ /* [2] */
3559
+ BTF_TYPE_ENC (1 , BTF_INFO_ENC (BTF_KIND_VAR , 0 , 0 ), 1 ),
3560
+ BTF_VAR_STATIC ,
3561
+ /* DATASEC ?.data */ /* [3] */
3562
+ BTF_TYPE_ENC (3 , BTF_INFO_ENC (BTF_KIND_DATASEC , 0 , 1 ), 4 ),
3563
+ BTF_VAR_SECINFO_ENC (2 , 0 , 4 ),
3564
+ BTF_END_RAW ,
3565
+ },
3566
+ BTF_STR_SEC ("\0x\0\7foo" ),
3567
+ .err_str = "Invalid name" ,
3568
+ .btf_load_err = true,
3569
+ },
3570
+ {
3571
+ .descr = "datasec: name '\\0' is not ok" ,
3572
+ .raw_types = {
3573
+ /* int */
3574
+ BTF_TYPE_INT_ENC (0 , BTF_INT_SIGNED , 0 , 32 , 4 ), /* [1] */
3575
+ /* VAR x */ /* [2] */
3576
+ BTF_TYPE_ENC (1 , BTF_INFO_ENC (BTF_KIND_VAR , 0 , 0 ), 1 ),
3577
+ BTF_VAR_STATIC ,
3578
+ /* DATASEC \0 */ /* [3] */
3579
+ BTF_TYPE_ENC (3 , BTF_INFO_ENC (BTF_KIND_DATASEC , 0 , 1 ), 4 ),
3580
+ BTF_VAR_SECINFO_ENC (2 , 0 , 4 ),
3581
+ BTF_END_RAW ,
3582
+ },
3583
+ BTF_STR_SEC ("\0x\0" ),
3584
+ .err_str = "Invalid name" ,
3585
+ .btf_load_err = true,
3586
+ },
3553
3587
{
3554
3588
.descr = "type name '?foo' is not ok" ,
3555
3589
.raw_types = {
0 commit comments