mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-26 10:49:33 +00:00
![Thomas Gleixner](/assets/img/avatar_default.png)
Based on 2 normalized pattern(s): this program is free software you can redistribute it and or modify it under the terms of the gnu general public license as published by the free software foundation either version 2 of the license or at your option any later version this program is distributed in the hope that it will be useful but without any warranty without even the implied warranty of merchantability or fitness for a particular purpose see the gnu general public license for more details you should have received a copy of the gnu general public license along with this program if not see http www gnu org licenses this program is free software you can redistribute it and or modify it under the terms of the gnu general public license as published by the free software foundation either version 2 of the license or at your option any later version this program is distributed in the hope that it will be useful but without any warranty without even the implied warranty of merchantability or fitness for a particular purpose see the gnu general public license for more details [based] [from] [clk] [highbank] [c] you should have received a copy of the gnu general public license along with this program if not see http www gnu org licenses extracted by the scancode license scanner the SPDX license identifier GPL-2.0-or-later has been chosen to replace the boilerplate/reference in 355 file(s). Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org> Reviewed-by: Jilayne Lovejoy <opensource@jilayne.com> Reviewed-by: Steve Winslow <swinslow@gmail.com> Reviewed-by: Allison Randal <allison@lohutok.net> Cc: linux-spdx@vger.kernel.org Link: https://lkml.kernel.org/r/20190519154041.837383322@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
66 lines
1.3 KiB
C
66 lines
1.3 KiB
C
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
/*
|
|
* Copyright (C) 2015 Josh Poimboeuf <jpoimboe@redhat.com>
|
|
*/
|
|
|
|
#ifndef _WARN_H
|
|
#define _WARN_H
|
|
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <sys/types.h>
|
|
#include <sys/stat.h>
|
|
#include <fcntl.h>
|
|
#include "elf.h"
|
|
|
|
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 "\n", \
|
|
objname, ##__VA_ARGS__)
|
|
|
|
#define WARN_FUNC(format, sec, offset, ...) \
|
|
({ \
|
|
char *_str = offstr(sec, offset); \
|
|
WARN("%s: " format, _str, ##__VA_ARGS__); \
|
|
free(_str); \
|
|
})
|
|
|
|
#define BT_FUNC(format, insn, ...) \
|
|
({ \
|
|
struct instruction *_insn = (insn); \
|
|
char *_str = offstr(_insn->sec, _insn->offset); \
|
|
WARN(" %s: " format, _str, ##__VA_ARGS__); \
|
|
free(_str); \
|
|
})
|
|
|
|
#define WARN_ELF(format, ...) \
|
|
WARN(format ": %s", ##__VA_ARGS__, elf_errmsg(-1))
|
|
|
|
#endif /* _WARN_H */
|