@@ -15,7 +15,7 @@
int is_rela_section(struct section *sec)
{
- return (sec->sh.sh_type == SHT_RELA);
+ return sec && (sec->sh.sh_type == SHT_RELA);
}
int is_local_sym(struct symbol *sym)
@@ -270,6 +270,27 @@ int is_standard_section(struct section *sec)
}
}
+int is_referenced_section(const struct section *sec,
+ const struct kpatch_elf *kelf)
+{
+ struct symbol *sym;
+
+ if (is_rela_section(sec->rela) && sec->rela->include)
+ return true;
+
+ list_for_each_entry(sym, &kelf->symbols, list) {
+ if (!sym->include || !sym->sec)
+ continue;
+ /* Ignore section associated sections */
+ if (sym->type == STT_SECTION)
+ continue;
+ if (sym->sec->index == sec->index)
+ return true;
+ }
+
+ return false;
+}
+
/* returns the offset of the string in the string table */
int offset_of_string(struct list_head *list, char *name)
{
@@ -151,6 +151,8 @@ int is_text_section(struct section *sec);
int is_debug_section(struct section *sec);
int is_rela_section(struct section *sec);
int is_standard_section(struct section *sec);
+int is_referenced_section(const struct section *sec,
+ const struct kpatch_elf *kelf);
int is_local_sym(struct symbol *sym);
void rela_insn(struct section *sec, struct rela *rela, struct insn *insn);