kpatch-elf: for rela sections, find base section by index rather than name

If there exist multiple sections with the same name (which can happen when
using the --unique option with ld, which will be used to keep multiple
(per-object) .parainstructions and .altinstructions sections separate),
find_section_by_name() will only return the first section name match, which
leads to incorrect base section assignments for rela sections. Fix this by
using the sh_info field of the rela section to find its base section
instead, which contains the index of the section to which the relocation
applies.
This commit is contained in:
Jessica Yu 2017-01-23 12:43:00 -08:00
parent a3108de96a
commit dac26b8cb2

View File

@ -144,7 +144,7 @@ void kpatch_create_rela_list(struct kpatch_elf *kelf, struct section *sec)
unsigned int symndx;
/* find matching base (text/data) section */
sec->base = find_section_by_name(&kelf->sections, sec->name + 5);
sec->base = find_section_by_index(&kelf->sections, sec->sh.sh_info);
if (!sec->base)
ERROR("can't find base section for rela section %s", sec->name);