1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * Copyright (C) 2015 Josh Poimboeuf <jpoimboe@redhat.com>
11 #include <sys/types.h>
16 extern const char *objname
;
18 static inline char *offstr(struct section
*sec
, unsigned long offset
)
22 unsigned long name_off
;
24 func
= find_func_containing(sec
, offset
);
27 name_off
= offset
- func
->offset
;
33 str
= malloc(strlen(name
) + 20);
36 sprintf(str
, "%s()+0x%lx", name
, name_off
);
38 sprintf(str
, "%s+0x%lx", name
, name_off
);
43 #define WARN(format, ...) \
45 "%s: warning: objtool: " format "\n", \
46 objname, ##__VA_ARGS__)
48 #define WARN_FUNC(format, sec, offset, ...) \
50 char *_str = offstr(sec, offset); \
51 WARN("%s: " format, _str, ##__VA_ARGS__); \
55 #define BT_FUNC(format, insn, ...) \
57 struct instruction *_insn = (insn); \
58 char *_str = offstr(_insn->sec, _insn->offset); \
59 WARN(" %s: " format, _str, ##__VA_ARGS__); \
63 #define WARN_ELF(format, ...) \
64 WARN(format ": %s", ##__VA_ARGS__, elf_errmsg(-1))