Linux Audio

Check our new training course

Loading...
Note: File does not exist in v3.15.
 1/*
 2 * Copyright (C) 2015 Josh Poimboeuf <jpoimboe@redhat.com>
 3 *
 4 * This program is free software; you can redistribute it and/or
 5 * modify it under the terms of the GNU General Public License
 6 * as published by the Free Software Foundation; either version 2
 7 * of the License, or (at your option) any later version.
 8 *
 9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef _WARN_H
19#define _WARN_H
20
21extern const char *objname;
22
23static inline char *offstr(struct section *sec, unsigned long offset)
24{
25	struct symbol *func;
26	char *name, *str;
27	unsigned long name_off;
28
29	func = find_containing_func(sec, offset);
30	if (func) {
31		name = func->name;
32		name_off = offset - func->offset;
33	} else {
34		name = sec->name;
35		name_off = offset;
36	}
37
38	str = malloc(strlen(name) + 20);
39
40	if (func)
41		sprintf(str, "%s()+0x%lx", name, name_off);
42	else
43		sprintf(str, "%s+0x%lx", name, name_off);
44
45	return str;
46}
47
48#define WARN(format, ...)				\
49	fprintf(stderr,					\
50		"%s: warning: objtool: " format "\n",	\
51		objname, ##__VA_ARGS__)
52
53#define WARN_FUNC(format, sec, offset, ...)		\
54({							\
55	char *_str = offstr(sec, offset);		\
56	WARN("%s: " format, _str, ##__VA_ARGS__);	\
57	free(_str);					\
58})
59
60#endif /* _WARN_H */