提交 5f51b512 编写于 作者: P Peter Zijlstra 提交者: Zheng Zengkai

recordmcount: Correct st_shndx handling

stable inclusion
from stable-5.10.47
commit d91c50e6a67800bee69f681ee78c3b767e9a0c2e
bugzilla: 172973 https://gitee.com/openeuler/kernel/issues/I4DAKB

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=d91c50e6a67800bee69f681ee78c3b767e9a0c2e

--------------------------------

[ Upstream commit fb780761 ]

One should only use st_shndx when >SHN_UNDEF and <SHN_LORESERVE. When
SHN_XINDEX, then use .symtab_shndx. Otherwise use 0.

This handles the case: st_shndx >= SHN_LORESERVE && st_shndx != SHN_XINDEX.

Link: https://lore.kernel.org/lkml/20210607023839.26387-1-mark-pk.tsai@mediatek.com/
Link: https://lkml.kernel.org/r/20210616154126.2794-1-mark-pk.tsai@mediatek.comReported-by: NMark-PK Tsai <mark-pk.tsai@mediatek.com>
Tested-by: NMark-PK Tsai <mark-pk.tsai@mediatek.com>
Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
[handle endianness of sym->st_shndx]
Signed-off-by: NMark-PK Tsai <mark-pk.tsai@mediatek.com>
Signed-off-by: NSteven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Acked-by: NWeilong Chen <chenweilong@huawei.com>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 922f2894
......@@ -192,15 +192,20 @@ static unsigned int get_symindex(Elf_Sym const *sym, Elf32_Word const *symtab,
Elf32_Word const *symtab_shndx)
{
unsigned long offset;
unsigned short shndx = w2(sym->st_shndx);
int index;
if (sym->st_shndx != SHN_XINDEX)
return w2(sym->st_shndx);
if (shndx > SHN_UNDEF && shndx < SHN_LORESERVE)
return shndx;
if (shndx == SHN_XINDEX) {
offset = (unsigned long)sym - (unsigned long)symtab;
index = offset / sizeof(*sym);
return w(symtab_shndx[index]);
}
return 0;
}
static unsigned int get_shnum(Elf_Ehdr const *ehdr, Elf_Shdr const *shdr0)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册