linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] recordmcount: avoid using ABS symbol as reference
@ 2021-06-07  2:38 Mark-PK Tsai
  2021-06-07  6:37 ` Ard Biesheuvel
  0 siblings, 1 reply; 14+ messages in thread
From: Mark-PK Tsai @ 2021-06-07  2:38 UTC (permalink / raw)
  To: Matthias Brugger
  Cc: rostedt, Mark-PK Tsai, Sami Tolvanen, Matt Helsley, linux-kernel,
	linux-arm-kernel, linux-mediatek, yj.chiang

Avoid using ABS symbol, which won't be relocate, as reference.

On arm64 platform, if there's shndx equals SHN_ABS(0xfff1).

Section Headers:
[Nr]    Name                         Type      Address          Off      Size   ES  Flg Lk     Inf    Al
[65521] .text.n_tty_receive_buf      PROGBITS  0000000000000000 3cdab520 000054 00  AX  0      0      4
[65522] .rela.text.n_tty_receive_buf RELA      0000000000000000 3cdab578 000030 18  I   152076 65521  8

find_secsym_ndx, which use r_info in rela section to find the reference
symbol, may take ABS symbol as base.

Symbol table '.symtab' contains 453285 entries:
   Num:    Value          Size Type    Bind   Vis       Ndx Name
     6: 0000000000000002     0 NOTYPE  LOCAL  DEFAULT   ABS section_count

Which cause an invalid address in __mcount_loc.

Signed-off-by: Mark-PK Tsai <mark-pk.tsai@mediatek.com>
---
 scripts/recordmcount.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/scripts/recordmcount.h b/scripts/recordmcount.h
index f9b19524da11..9b69167fb7ff 100644
--- a/scripts/recordmcount.h
+++ b/scripts/recordmcount.h
@@ -526,6 +526,10 @@ static int find_secsym_ndx(unsigned const txtndx,
 	for (symp = sym0, t = nsym; t; --t, ++symp) {
 		unsigned int const st_bind = ELF_ST_BIND(symp->st_info);
 
+		/* avoid absolute symbols */
+		if (symp->st_shndx == SHN_ABS)
+			continue;
+
 		if (txtndx == get_symindex(symp, symtab, symtab_shndx)
 			/* avoid STB_WEAK */
 		    && (STB_LOCAL == st_bind || STB_GLOBAL == st_bind)) {
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2021-06-08  1:15 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-07  2:38 [PATCH] recordmcount: avoid using ABS symbol as reference Mark-PK Tsai
2021-06-07  6:37 ` Ard Biesheuvel
2021-06-07  6:59   ` Mark-PK Tsai
2021-06-07  7:07     ` Ard Biesheuvel
2021-06-07  7:42       ` Mark-PK Tsai
2021-06-07  8:06         ` Mark-PK Tsai
2021-06-07  9:50           ` Ard Biesheuvel
2021-06-07 10:32             ` Mark-PK Tsai
2021-06-07 11:44             ` Peter Zijlstra
2021-06-07 13:18               ` Mark-PK Tsai
2021-06-07 13:44               ` Steven Rostedt
2021-06-07 17:31                 ` Mark-PK Tsai
2021-06-07 15:40               ` Peter Zijlstra
2021-06-08  1:15                 ` Mark-PK Tsai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).