|
|
@ -550,7 +550,11 @@ impl Btf {
|
|
|
|
|| name == "memmove"
|
|
|
|
|| name == "memmove"
|
|
|
|
|| name == "memcmp"
|
|
|
|
|| name == "memcmp"
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Sanitize BTF_FUNC_GLOBAL and memset, memcpy
|
|
|
|
// Sanitize BTF_FUNC_GLOBAL when not supported and ensure that
|
|
|
|
|
|
|
|
// memory builtins are marked as static. Globals are type checked
|
|
|
|
|
|
|
|
// and verified separately from their callers, while instead we
|
|
|
|
|
|
|
|
// want tracking info (eg bound checks) to be propagated to the
|
|
|
|
|
|
|
|
// memory builtins.
|
|
|
|
let mut fixed_ty = ty.clone();
|
|
|
|
let mut fixed_ty = ty.clone();
|
|
|
|
if ty.linkage() == FuncLinkage::Global {
|
|
|
|
if ty.linkage() == FuncLinkage::Global {
|
|
|
|
if !features.btf_func_global {
|
|
|
|
if !features.btf_func_global {
|
|
|
@ -1387,9 +1391,8 @@ mod tests {
|
|
|
|
let func_proto_type_id =
|
|
|
|
let func_proto_type_id =
|
|
|
|
btf.add_type(BtfType::FuncProto(FuncProto::new(params, int_type_id)));
|
|
|
|
btf.add_type(BtfType::FuncProto(FuncProto::new(params, int_type_id)));
|
|
|
|
|
|
|
|
|
|
|
|
["memset", "memcpy", "memcmp", "memmove"]
|
|
|
|
let builtins = ["memset", "memcpy", "memcmp", "memmove"];
|
|
|
|
.iter()
|
|
|
|
for fname in builtins {
|
|
|
|
.for_each(|fname| {
|
|
|
|
|
|
|
|
let func_name_offset = btf.add_string(fname.to_string());
|
|
|
|
let func_name_offset = btf.add_string(fname.to_string());
|
|
|
|
let func_type_id = btf.add_type(BtfType::Func(Func::new(
|
|
|
|
let func_type_id = btf.add_type(BtfType::Func(Func::new(
|
|
|
|
func_name_offset,
|
|
|
|
func_name_offset,
|
|
|
@ -1415,7 +1418,7 @@ mod tests {
|
|
|
|
// Ensure we can convert to bytes and back again
|
|
|
|
// Ensure we can convert to bytes and back again
|
|
|
|
let raw = btf.to_bytes();
|
|
|
|
let raw = btf.to_bytes();
|
|
|
|
Btf::parse(&raw, Endianness::default()).unwrap();
|
|
|
|
Btf::parse(&raw, Endianness::default()).unwrap();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|