On Fri, May 09, 2025 at 01:17:16PM -0700, Josh Poimboeuf wrote: > +#define SEC_NAME_LEN 512 > #define SYM_NAME_LEN 512 >
> +static int validate_ffunction_fdata_sections(struct elf *elf) > +{ > + struct symbol *sym; > + bool found_text = false, found_data = false; > + > + for_each_sym(elf, sym) { > + char sec_name[SEC_NAME_LEN]; > + > + if (!found_text && is_func_sym(sym)) { > + snprintf(sec_name, SEC_NAME_LEN, ".text.%s", sym->name); So given SYM_NAME_LEN is 512, this SEC_NAME_LEN should be at least 6 more, no? > + if (!strcmp(sym->sec->name, sec_name)) > + found_text = true; > + } > + > + if (!found_data && is_object_sym(sym)) { > + snprintf(sec_name, SEC_NAME_LEN, ".data.%s", sym->name); > + if (!strcmp(sym->sec->name, sec_name)) > + found_data = true; > + } > + > + if (found_text && found_data) > + return 0; > + } > + > + ERROR("changed object '%s' not built with -ffunction-sections and > -fdata-sections", elf->name); > + return -1; > +}