lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250627102930.GU1613200@noisy.programming.kicks-ass.net>
Date: Fri, 27 Jun 2025 12:29:30 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Josh Poimboeuf <jpoimboe@...nel.org>
Cc: x86@...nel.org, linux-kernel@...r.kernel.org,
	Petr Mladek <pmladek@...e.com>, Miroslav Benes <mbenes@...e.cz>,
	Joe Lawrence <joe.lawrence@...hat.com>,
	live-patching@...r.kernel.org, Song Liu <song@...nel.org>,
	laokz <laokz@...mail.com>, Jiri Kosina <jikos@...nel.org>,
	Marcos Paulo de Souza <mpdesouza@...e.com>,
	Weinan Liu <wnliu@...gle.com>,
	Fazla Mehrab <a.mehrab@...edance.com>,
	Chen Zhongjin <chenzhongjin@...wei.com>,
	Puranjay Mohan <puranjay@...nel.org>,
	Dylan Hatch <dylanbhatch@...gle.com>
Subject: Re: [PATCH v3 26/64] objtool: Add section/symbol type helpers

On Thu, Jun 26, 2025 at 04:55:13PM -0700, Josh Poimboeuf wrote:
> @@ -177,11 +178,71 @@ static inline unsigned int elf_text_rela_type(struct elf *elf)
>  	return elf_addr_size(elf) == 4 ? R_TEXT32 : R_TEXT64;
>  }
>  
> +static inline bool sym_has_sec(struct symbol *sym)
> +{
> +	return sym->sec->idx;
> +}
> +
> +static inline bool is_null_sym(struct symbol *sym)
> +{
> +	return !sym->idx;
> +}
> +
> +static inline bool is_sec_sym(struct symbol *sym)
> +{
> +	return sym->type == STT_SECTION;
> +}
> +
> +static inline bool is_object_sym(struct symbol *sym)
> +{
> +	return sym->type == STT_OBJECT;
> +}
> +
> +static inline bool is_func_sym(struct symbol *sym)
> +{
> +	return sym->type == STT_FUNC;
> +}
> +
> +static inline bool is_file_sym(struct symbol *sym)
> +{
> +	return sym->type == STT_FILE;
> +}
> +
> +static inline bool is_notype_sym(struct symbol *sym)
> +{
> +	return sym->type == STT_NOTYPE;
> +}
> +
> +static inline bool is_global_sym(struct symbol *sym)
> +{
> +	return sym->bind == STB_GLOBAL;
> +}
> +
> +static inline bool is_weak_sym(struct symbol *sym)
> +{
> +	return sym->bind == STB_WEAK;
> +}
> +
> +static inline bool is_local_sym(struct symbol *sym)
> +{
> +	return sym->bind == STB_LOCAL;
> +}
> +
>  static inline bool is_reloc_sec(struct section *sec)
>  {
>  	return sec->sh.sh_type == SHT_RELA || sec->sh.sh_type == SHT_REL;
>  }
>  
> +static inline bool is_string_sec(struct section *sec)
> +{
> +	return sec->sh.sh_flags & SHF_STRINGS;
> +}
> +
> +static inline bool is_text_sec(struct section *sec)
> +{
> +	return sec->sh.sh_flags & SHF_EXECINSTR;
> +}
> +
>  static inline bool sec_changed(struct section *sec)
>  {
>  	return sec->_changed;
> @@ -222,6 +283,11 @@ static inline bool is_32bit_reloc(struct reloc *reloc)
>  	return reloc->sec->sh.sh_entsize < 16;
>  }
>  
> +static inline unsigned long sec_size(struct section *sec)
> +{
> +	return sec->sh.sh_size;
> +}
> +


Naming seems inconsistent, there are:

  sym_has_sec(), sec_changed() and sec_size()

which have the object first, but then most new ones are:

  is_foo_sym() and is_foo_sec()

which have the object last.


Can we make this consistent and do something like:

  s/is_\([^_]*\)_\(sym\|sec\)/\2_is_\1/

?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ