linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: Sami Tolvanen <samitolvanen@google.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] objtool: use sh_info to find the base for .rela sections
Date: Tue, 21 Apr 2020 13:07:51 -0700	[thread overview]
Message-ID: <202004211307.C8E3AC87@keescook> (raw)
In-Reply-To: <20200421182501.149101-1-samitolvanen@google.com>

On Tue, Apr 21, 2020 at 11:25:01AM -0700, Sami Tolvanen wrote:
> ELF doesn't require .rela section names to match the base section. Use
> the section index in sh_info to find the section instead of looking it
> up by name.
> 
> LLD, for example, generates a .rela section that doesn't match the base
> section name when we merge sections in a linker script for a binary
> compiled with -ffunction-sections.
> 
> Signed-off-by: Sami Tolvanen <samitolvanen@google.com>

Reviewed-by: Kees Cook <keescook@chromium.org>

-Kees

> ---
>  tools/objtool/elf.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
> index 09ddc8f1def3..73cfe45975c8 100644
> --- a/tools/objtool/elf.c
> +++ b/tools/objtool/elf.c
> @@ -468,7 +468,7 @@ static int read_relas(struct elf *elf)
>  		if (sec->sh.sh_type != SHT_RELA)
>  			continue;
>  
> -		sec->base = find_section_by_name(elf, sec->name + 5);
> +		sec->base = find_section_by_index(elf, sec->sh.sh_info);
>  		if (!sec->base) {
>  			WARN("can't find base section for rela section %s",
>  			     sec->name);
> 
> base-commit: ae83d0b416db002fe95601e7f97f64b59514d936
> -- 
> 2.26.1.301.g55bc3eb7cb9-goog
> 

-- 
Kees Cook

      reply	other threads:[~2020-04-21 20:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-21 18:25 [PATCH] objtool: use sh_info to find the base for .rela sections Sami Tolvanen
2020-04-21 20:07 ` Kees Cook [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202004211307.C8E3AC87@keescook \
    --to=keescook@chromium.org \
    --cc=jpoimboe@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=samitolvanen@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).