@@ -403,62 +403,6 @@ static int symbols_collect(struct object *obj)
403
403
return 0 ;
404
404
}
405
405
406
- static struct btf * btf__parse_raw (const char * file )
407
- {
408
- struct btf * btf ;
409
- struct stat st ;
410
- __u8 * buf ;
411
- FILE * f ;
412
-
413
- if (stat (file , & st ))
414
- return NULL ;
415
-
416
- f = fopen (file , "rb" );
417
- if (!f )
418
- return NULL ;
419
-
420
- buf = malloc (st .st_size );
421
- if (!buf ) {
422
- btf = ERR_PTR (- ENOMEM );
423
- goto exit_close ;
424
- }
425
-
426
- if ((size_t ) st .st_size != fread (buf , 1 , st .st_size , f )) {
427
- btf = ERR_PTR (- EINVAL );
428
- goto exit_free ;
429
- }
430
-
431
- btf = btf__new (buf , st .st_size );
432
-
433
- exit_free :
434
- free (buf );
435
- exit_close :
436
- fclose (f );
437
- return btf ;
438
- }
439
-
440
- static bool is_btf_raw (const char * file )
441
- {
442
- __u16 magic = 0 ;
443
- int fd , nb_read ;
444
-
445
- fd = open (file , O_RDONLY );
446
- if (fd < 0 )
447
- return false;
448
-
449
- nb_read = read (fd , & magic , sizeof (magic ));
450
- close (fd );
451
- return nb_read == sizeof (magic ) && magic == BTF_MAGIC ;
452
- }
453
-
454
- static struct btf * btf_open (const char * path )
455
- {
456
- if (is_btf_raw (path ))
457
- return btf__parse_raw (path );
458
- else
459
- return btf__parse_elf (path , NULL );
460
- }
461
-
462
406
static int symbols_resolve (struct object * obj )
463
407
{
464
408
int nr_typedefs = obj -> nr_typedefs ;
@@ -469,7 +413,7 @@ static int symbols_resolve(struct object *obj)
469
413
struct btf * btf ;
470
414
__u32 nr ;
471
415
472
- btf = btf_open (obj -> btf ?: obj -> path );
416
+ btf = btf__parse (obj -> btf ?: obj -> path , NULL );
473
417
err = libbpf_get_error (btf );
474
418
if (err ) {
475
419
pr_err ("FAILED: load BTF from %s: %s" ,
0 commit comments