[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMj1kXE3faN7nSSdoSU=ed+OPruefD_vJuhyRnsMuNiRygZZbg@mail.gmail.com>
Date: Mon, 7 Jun 2021 08:37:27 +0200
From: Ard Biesheuvel <ardb@...nel.org>
To: Mark-PK Tsai <mark-pk.tsai@...iatek.com>
Cc: Matthias Brugger <matthias.bgg@...il.com>,
"Steven Rostedt (VMware)" <rostedt@...dmis.org>,
Sami Tolvanen <samitolvanen@...gle.com>,
Matt Helsley <mhelsley@...are.com>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Linux ARM <linux-arm-kernel@...ts.infradead.org>,
linux-mediatek@...ts.infradead.org, yj.chiang@...iatek.com
Subject: Re: [PATCH] recordmcount: avoid using ABS symbol as reference
On Mon, 7 Jun 2021 at 04:42, Mark-PK Tsai <mark-pk.tsai@...iatek.com> wrote:
>
> 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
>
A RELA section's r_info field points to the section to which it
applies. This is why in the example above section #65522 points to
section #65521. This has nothing to do with the numerical value of
SHN_ABS.
> 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.
>
Could you give a better account of the error you are trying to address?
Also, arm64 no longer defines a section_count symbol (since v5.11), so
please make sure that the diagnostics of the issue you are addressing
are accurate for mainline.
> Signed-off-by: Mark-PK Tsai <mark-pk.tsai@...iatek.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
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@...ts.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Powered by blists - more mailing lists