mirror of https://gitee.com/openkylin/linux.git
Merge branch 'core-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull objtool fixes from Ingo Molnar: "Two fixes for boundary conditions" * 'core-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: objtool: Fix segfault in .cold detection with -ffunction-sections objtool: Fix double-free in .cold detection error path
This commit is contained in:
commit
575d7d0d6f
|
@ -31,6 +31,8 @@
|
||||||
#include "elf.h"
|
#include "elf.h"
|
||||||
#include "warn.h"
|
#include "warn.h"
|
||||||
|
|
||||||
|
#define MAX_NAME_LEN 128
|
||||||
|
|
||||||
struct section *find_section_by_name(struct elf *elf, const char *name)
|
struct section *find_section_by_name(struct elf *elf, const char *name)
|
||||||
{
|
{
|
||||||
struct section *sec;
|
struct section *sec;
|
||||||
|
@ -298,6 +300,8 @@ static int read_symbols(struct elf *elf)
|
||||||
/* Create parent/child links for any cold subfunctions */
|
/* Create parent/child links for any cold subfunctions */
|
||||||
list_for_each_entry(sec, &elf->sections, list) {
|
list_for_each_entry(sec, &elf->sections, list) {
|
||||||
list_for_each_entry(sym, &sec->symbol_list, list) {
|
list_for_each_entry(sym, &sec->symbol_list, list) {
|
||||||
|
char pname[MAX_NAME_LEN + 1];
|
||||||
|
size_t pnamelen;
|
||||||
if (sym->type != STT_FUNC)
|
if (sym->type != STT_FUNC)
|
||||||
continue;
|
continue;
|
||||||
sym->pfunc = sym->cfunc = sym;
|
sym->pfunc = sym->cfunc = sym;
|
||||||
|
@ -305,14 +309,21 @@ static int read_symbols(struct elf *elf)
|
||||||
if (!coldstr)
|
if (!coldstr)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
coldstr[0] = '\0';
|
pnamelen = coldstr - sym->name;
|
||||||
pfunc = find_symbol_by_name(elf, sym->name);
|
if (pnamelen > MAX_NAME_LEN) {
|
||||||
coldstr[0] = '.';
|
WARN("%s(): parent function name exceeds maximum length of %d characters",
|
||||||
|
sym->name, MAX_NAME_LEN);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
strncpy(pname, sym->name, pnamelen);
|
||||||
|
pname[pnamelen] = '\0';
|
||||||
|
pfunc = find_symbol_by_name(elf, pname);
|
||||||
|
|
||||||
if (!pfunc) {
|
if (!pfunc) {
|
||||||
WARN("%s(): can't find parent function",
|
WARN("%s(): can't find parent function",
|
||||||
sym->name);
|
sym->name);
|
||||||
goto err;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
sym->pfunc = pfunc;
|
sym->pfunc = pfunc;
|
||||||
|
|
Loading…
Reference in New Issue