mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nathan Chancellor <nathan@kernel.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: jpoimboe@redhat.com, linux-kernel@vger.kernel.org,
	Fangrui Song <i@maskray.me>,
	llvm@lists.linux.dev
Subject: Re: [PATCH 1/9] objtool: Generic annotation infrastructure
Date: Sat, 23 Nov 2024 20:16:40 -0700	[thread overview]
Message-ID: <20241124031640.GA3646332@thelio-3990X> (raw)
In-Reply-To: <20241122121555.621070802@infradead.org>

On Fri, Nov 22, 2024 at 01:10:17PM +0100, Peter Zijlstra wrote:
> Avoid endless .discard.foo sections for each annotation, create a
> single .discard.annotate section that takes an annotation type along
> with the instruction.
> 
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
...
> --- a/tools/objtool/check.c
> +++ b/tools/objtool/check.c
> @@ -2373,6 +2373,49 @@ static int read_unwind_hints(struct objt
>  	return 0;
>  }
>  
> +static int read_annotate(struct objtool_file *file, void (*func)(int type, struct instruction *insn))
> +{
> +	struct section *sec;
> +	struct instruction *insn;
> +	struct reloc *reloc;
> +	int type;
> +
> +	sec = find_section_by_name(file->elf, ".discard.annotate");
> +	if (!sec)
> +		return 0;
> +
> +	if (!sec->rsec)
> +		return 0;
> +
> +	if (sec->sh.sh_entsize != 8) {
> +		static bool warned = false;
> +		if (!warned) {
> +			WARN("%s: dodgy linker, sh_entsize != 8", sec->name);

Thanks to Fangrui, this has been resolved in LLVM main:

https://github.com/llvm/llvm-project/commit/d4bed617f4378873d7ddf4b53c041e7b39d1a9ca
https://github.com/ClangBuiltLinux/linux/issues/2057#issuecomment-2495675374

I have built a version of LLVM from main and verified that this warning
does not trigger with that version, while it does with LLVM 19.1.4.

> +			warned = true;
> +		}
> +		sec->sh.sh_entsize = 8;
> +	}
> +
> +	for_each_reloc(sec->rsec, reloc) {
> +		type = *(u32 *)(sec->data->d_buf + (reloc_idx(reloc) * sec->sh.sh_entsize) + 4);
> +
> +		insn = find_insn(file, reloc->sym->sec,
> +				 reloc->sym->offset + reloc_addend(reloc));
> +		if (!insn) {
> +			WARN("bad .discard.annotate entry: %d of type %d", reloc_idx(reloc), type);
> +			return -1;
> +		}
> +
> +		func(type, insn);
> +	}
> +
> +	return 0;
> +}

Cheers,
Nathan

  reply	other threads:[~2024-11-24  3:16 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-22 12:10 [PATCH 0/9] objtool: Rewrite annotations Peter Zijlstra
2024-11-22 12:10 ` [PATCH 1/9] objtool: Generic annotation infrastructure Peter Zijlstra
2024-11-24  3:16   ` Nathan Chancellor [this message]
2024-11-25  9:28     ` Peter Zijlstra
2024-11-22 12:10 ` [PATCH 2/9] objtool: Convert ANNOTATE_NOENDBR to ANNOTATE Peter Zijlstra
2024-11-22 12:10 ` [PATCH 3/9] objtool: Convert ANNOTATE_RETPOLINE_SAFE " Peter Zijlstra
2024-11-22 12:10 ` [PATCH 4/9] objtool: Convert instrumentation_{begin,end}() " Peter Zijlstra
2024-11-22 12:10 ` [PATCH 5/9] objtool: Convert VALIDATE_UNRET_BEGIN " Peter Zijlstra
2024-11-22 12:10 ` [PATCH 6/9] objtool: Convert ANNOTATE_IGNORE_ALTERNATIVE " Peter Zijlstra
2024-11-22 12:10 ` [PATCH 7/9] objtool: Convert ANNOTATE_INTRA_FUNCTION_CALLS " Peter Zijlstra
2024-11-22 17:22   ` Josh Poimboeuf
2024-11-22 12:10 ` [PATCH 8/9] objtool: Collapse annotate sequences Peter Zijlstra
2024-11-22 17:57   ` Josh Poimboeuf
2024-11-23 13:09     ` Peter Zijlstra
2024-11-22 12:10 ` [PATCH 9/9] objtool: Collect all annotations in objtool.h Peter Zijlstra
2024-11-22 17:54   ` Josh Poimboeuf
2024-11-23 13:19     ` Peter Zijlstra
2024-11-25 13:06       ` Peter Zijlstra
2024-11-25 13:40         ` Peter Zijlstra
2024-11-25 14:36           ` Peter Zijlstra
2024-11-22 17:40 ` [PATCH 0/9] objtool: Rewrite annotations Josh Poimboeuf
2024-11-23 13:21   ` Peter Zijlstra

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=20241124031640.GA3646332@thelio-3990X \
    --to=nathan@kernel.org \
    --cc=i@maskray.me \
    --cc=jpoimboe@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=peterz@infradead.org \
    /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

all inboxes | Powered by JetHome®