kpatch-elf: add find_rela_by_offset()

Add find_rela_by_offset(), which, given a relocation section and offset,
will return the rela struct with the matching offset.
This commit is contained in:
Jessica Yu 2017-01-23 12:43:27 -08:00
parent 42902d0fcc
commit 900d28fe75
2 changed files with 13 additions and 0 deletions

View File

@ -118,6 +118,18 @@ struct symbol *find_symbol_by_name(struct list_head *list, const char *name)
return NULL;
}
struct rela *find_rela_by_offset(struct section *relasec, unsigned int offset)
{
struct rela *rela;
list_for_each_entry(rela, &relasec->relas, list) {
if (rela->offset == offset)
return rela;
}
return NULL;
}
/* returns the offset of the string in the string table */
int offset_of_string(struct list_head *list, char *name)
{

View File

@ -117,6 +117,7 @@ struct section *find_section_by_index(struct list_head *list, unsigned int index
struct section *find_section_by_name(struct list_head *list, const char *name);
struct symbol *find_symbol_by_index(struct list_head *list, size_t index);
struct symbol *find_symbol_by_name(struct list_head *list, const char *name);
struct rela *find_rela_by_offset(struct section *relasec, unsigned int offset);
#define ALLOC_LINK(_new, _list) \
{ \