Merge pull request #1273 from jpoimboe/create-secsym

create-diff-object: Create missing section symbol
This commit is contained in:
Josh Poimboeuf 2022-06-07 20:32:17 -07:00 committed by GitHub
commit 7fdbb2561c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 6 deletions

View File

@ -3355,12 +3355,23 @@ static void kpatch_create_intermediate_sections(struct kpatch_elf *kelf,
/* add rela to fill in krelas[index].dest field */ /* add rela to fill in krelas[index].dest field */
ALLOC_LINK(rela2, &krela_sec->rela->relas); ALLOC_LINK(rela2, &krela_sec->rela->relas);
if (relasec->base->secsym) if (!relasec->base->secsym) {
rela2->sym = relasec->base->secsym; struct symbol *sym;
else
ERROR("can't create dynrela for section %s (symbol %s): no bundled or section symbol",
relasec->name, rela->sym->name);
/*
* Newer toolchains are stingy with their
* section symbols, create one if it doesn't
* exist already.
*/
ALLOC_LINK(sym, &kelf->symbols);
sym->sec = relasec->base;
sym->sym.st_info = GELF_ST_INFO(STB_LOCAL, STT_SECTION);
sym->type = STT_SECTION;
sym->bind = STB_LOCAL;
sym->name = relasec->base->name;
relasec->base->secsym = sym;
}
rela2->sym = relasec->base->secsym;
rela2->type = absolute_rela_type(kelf); rela2->type = absolute_rela_type(kelf);
rela2->addend = rela->offset; rela2->addend = rela->offset;
rela2->offset = (unsigned int)(index * sizeof(*krelas) + \ rela2->offset = (unsigned int)(index * sizeof(*krelas) + \

@ -1 +1 @@
Subproject commit 94d00075b71e087b73c46d6a1bfdfe910ee62636 Subproject commit d9491d9ea422f317573938ee6c2f57ce2f12f786