linux-stable/tools/objtool/include/objtool
Tiezhu Yang d5ab2bc36c objtool: Check local label in add_dead_ends()
When update the latest upstream gcc and binutils, it generates more
objtool warnings on LoongArch, like this:

  init/main.o: warning: objtool: unexpected relocation symbol type in .rela.discard.unreachable

We can see that the reloc sym name is local label instead of section in
relocation section '.rela.discard.unreachable', in this case, the reloc
sym type is STT_NOTYPE instead of STT_SECTION.

As suggested by Peter Zijlstra, we add a "local_label" member in struct
symbol, then set it as true if symbol type is STT_NOTYPE and symbol name
starts with ".L" string in classify_symbols().

Let's check reloc->sym->local_label to not return -1 in add_dead_ends(),
and also use reloc->sym->offset instead of reloc addend which is 0 to
find the corresponding instruction. At the same time, let's replace the
variable "addend" with "offset" to reflect the reality.

Here are some detailed info:
[fedora@linux 6.8.test]$ gcc --version
gcc (GCC) 14.0.1 20240129 (experimental)
[fedora@linux 6.8.test]$ as --version
GNU assembler (GNU Binutils) 2.42.50.20240129
[fedora@linux 6.8.test]$ readelf -r init/main.o | grep -A 2 "rela.discard.unreachable"
Relocation section '.rela.discard.unreachable' at offset 0x6028 contains 1 entry:
  Offset          Info           Type           Sym. Value    Sym. Name + Addend
000000000000  00d900000063 R_LARCH_32_PCREL  00000000000002c4 .L500^B1 + 0

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
2024-03-11 22:23:47 +08:00
..
arch.h objtool/x86: Fix SRSO mess 2023-08-16 09:39:16 +02:00
builtin.h objtool: Add verbose option for disassembling affected functions 2023-05-16 06:31:51 -07:00
cfi.h objtool: Allow stack operations in UNWIND_HINT_UNDEFINED regions 2023-06-07 10:03:11 -07:00
check.h x86,objtool: Separate unret validation from unwind hints 2023-03-23 23:18:58 +01:00
elf.h objtool: Check local label in add_dead_ends() 2024-03-11 22:23:47 +08:00
endianness.h objtool: Use target file endianness instead of a compiled constant 2022-11-18 19:00:15 +11:00
objtool.h objtool: Remove instruction::list 2023-02-23 09:21:44 +01:00
orc.h objtool/x86: Separate arch-specific and generic parts 2024-03-11 22:23:47 +08:00
special.h objtool: Optimize layout of struct special_alt 2023-02-01 09:15:24 -08:00
warn.h objtool: Include backtrace in verbose mode 2023-05-16 06:31:52 -07:00