powerpc/mm/4k: don't allocate larger pmd page table for 4k
[linux/fpc-iii.git] / tools / objtool / warn.h
blobac7e07523e844f15fb8a71fbe0948fa2b639d715
1 /*
2 * Copyright (C) 2015 Josh Poimboeuf <jpoimboe@redhat.com>
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.
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.
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/>.
18 #ifndef _WARN_H
19 #define _WARN_H
21 extern const char *objname;
23 static inline char *offstr(struct section *sec, unsigned long offset)
25 struct symbol *func;
26 char *name, *str;
27 unsigned long name_off;
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;
38 str = malloc(strlen(name) + 20);
40 if (func)
41 sprintf(str, "%s()+0x%lx", name, name_off);
42 else
43 sprintf(str, "%s+0x%lx", name, name_off);
45 return str;
48 #define WARN(format, ...) \
49 fprintf(stderr, \
50 "%s: warning: objtool: " format "\n", \
51 objname, ##__VA_ARGS__)
53 #define WARN_FUNC(format, sec, offset, ...) \
54 ({ \
55 char *_str = offstr(sec, offset); \
56 WARN("%s: " format, _str, ##__VA_ARGS__); \
57 free(_str); \
60 #endif /* _WARN_H */