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/>.
23 #include <sys/types.h>
28 extern const char *objname
;
30 static inline char *offstr(struct section
*sec
, unsigned long offset
)
34 unsigned long name_off
;
36 func
= find_containing_func(sec
, offset
);
39 name_off
= offset
- func
->offset
;
45 str
= malloc(strlen(name
) + 20);
48 sprintf(str
, "%s()+0x%lx", name
, name_off
);
50 sprintf(str
, "%s+0x%lx", name
, name_off
);
55 #define WARN(format, ...) \
57 "%s: warning: objtool: " format "\n", \
58 objname, ##__VA_ARGS__)
60 #define WARN_FUNC(format, sec, offset, ...) \
62 char *_str = offstr(sec, offset); \
63 WARN("%s: " format, _str, ##__VA_ARGS__); \
67 #define WARN_ELF(format, ...) \
68 WARN(format ": %s", ##__VA_ARGS__, elf_errmsg(-1))