1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_BUILDID_H
3 #define _LINUX_BUILDID_H
4
5 #include <linux/types.h>
6
7 #define BUILD_ID_SIZE_MAX 20
8
9 struct vm_area_struct;
10 struct file;
11
12 int build_id_parse(struct vm_area_struct *vma, unsigned char *build_id, __u32 *size);
13 int build_id_parse_file(struct file *file, unsigned char *build_id, __u32 *size);
14 int build_id_parse_nofault(struct vm_area_struct *vma, unsigned char *build_id, __u32 *size);
15 int build_id_parse_buf(const void *buf, unsigned char *build_id, u32 buf_size);
16
17 #if IS_ENABLED(CONFIG_STACKTRACE_BUILD_ID) || IS_ENABLED(CONFIG_VMCORE_INFO)
18 extern unsigned char vmlinux_build_id[BUILD_ID_SIZE_MAX];
19 void init_vmlinux_build_id(void);
20 #else
init_vmlinux_build_id(void)21 static inline void init_vmlinux_build_id(void) { }
22 #endif
23
24 struct freader {
25 void *buf;
26 u32 buf_sz;
27 int err;
28 union {
29 struct {
30 struct file *file;
31 struct folio *folio;
32 void *addr;
33 loff_t folio_off;
34 bool may_fault;
35 };
36 struct {
37 const char *data;
38 u64 data_sz;
39 };
40 };
41 };
42
43 void freader_init_from_file(struct freader *r, void *buf, u32 buf_sz,
44 struct file *file, bool may_fault);
45 void freader_init_from_mem(struct freader *r, const char *data, u64 data_sz);
46 const void *freader_fetch(struct freader *r, loff_t file_off, size_t sz);
47 void freader_cleanup(struct freader *r);
48
49 #endif
50