Blame view
tools/objtool/warn.h
1.34 KB
1ccea77e2 treewide: Replace... |
1 |
/* SPDX-License-Identifier: GPL-2.0-or-later */ |
442f04c34 objtool: Add tool... |
2 3 |
/* * Copyright (C) 2015 Josh Poimboeuf <jpoimboe@redhat.com> |
442f04c34 objtool: Add tool... |
4 5 6 7 |
*/ #ifndef _WARN_H #define _WARN_H |
baa41469a objtool: Implemen... |
8 9 10 11 12 13 |
#include <stdlib.h> #include <string.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include "elf.h" |
442f04c34 objtool: Add tool... |
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
extern const char *objname; static inline char *offstr(struct section *sec, unsigned long offset) { struct symbol *func; char *name, *str; unsigned long name_off; func = find_containing_func(sec, offset); if (func) { name = func->name; name_off = offset - func->offset; } else { name = sec->name; name_off = offset; } str = malloc(strlen(name) + 20); if (func) sprintf(str, "%s()+0x%lx", name, name_off); else sprintf(str, "%s+0x%lx", name, name_off); return str; } #define WARN(format, ...) \ fprintf(stderr, \ "%s: warning: objtool: " format " ", \ objname, ##__VA_ARGS__) #define WARN_FUNC(format, sec, offset, ...) \ ({ \ char *_str = offstr(sec, offset); \ WARN("%s: " format, _str, ##__VA_ARGS__); \ free(_str); \ }) |
7697eee3d objtool: Add --ba... |
53 54 55 56 57 58 59 |
#define BT_FUNC(format, insn, ...) \ ({ \ struct instruction *_insn = (insn); \ char *_str = offstr(_insn->sec, _insn->offset); \ WARN(" %s: " format, _str, ##__VA_ARGS__); \ free(_str); \ }) |
baa41469a objtool: Implemen... |
60 61 |
#define WARN_ELF(format, ...) \ WARN(format ": %s", ##__VA_ARGS__, elf_errmsg(-1)) |
442f04c34 objtool: Add tool... |
62 |
#endif /* _WARN_H */ |