Closed liu-song-6 closed 2 years ago
Recent toolchains only create a section symbol if it's needed, i.e. if there's a reference to it. I think the fix here would be to just create the section symbol, something like so (untested)
diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c
index bebe3bd..d71259b 100644
--- a/kpatch-build/create-diff-object.c
+++ b/kpatch-build/create-diff-object.c
@@ -3355,12 +3355,23 @@ static void kpatch_create_intermediate_sections(struct kpatch_elf *kelf,
/* add rela to fill in krelas[index].dest field */
ALLOC_LINK(rela2, &krela_sec->rela->relas);
- if (relasec->base->secsym)
- rela2->sym = relasec->base->secsym;
- else
- ERROR("can't create dynrela for section %s (symbol %s): no bundled or section symbol",
- relasec->name, rela->sym->name);
+ if (!relasec->base->secsym) {
+ struct symbol *sym;
+ /*
+ * 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->addend = rela->offset;
rela2->offset = (unsigned int)(index * sizeof(*krelas) + \
I was able to recreate, and I verified the above patch fixed it. Will make a pull request.
Yes, this works great, thanks!
We are seeing the following error from kpatch-build
The patch to repro this error can be very simple:
After digging into this, we found this happens because missing symbol name for the
.static_call_sites
section. We need to accessstatic_call_sites
section for the tracepoint calltrace_btrfs_done_preemptive_reclaim
. The symbol name forstatic_call_sites
is generated by the following step inscripts/Makefile.build
:As space-info.c doesn't export any symbol, space-info.o doesn't have any
__ksymtab
, and we skippedcmd_gensymtypes_c
.I tried a few things to fix this issue, but haven't figured out a good solution. Any suggestions on what would be the best fix here?
Thanks!