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/ ?