Hello Baoquan, Am Freitag, 4. November 2016, 15:38:40 BRST schrieb Baoquan He: > On 11/02/16 at 04:00am, Thiago Jung Bauermann wrote: > > Hello, > > > > The kexec_file code currently builds the purgatory as a partially linked > > object (using ld -r). Is there a particular reason to use that instead of > > a position independent executable (PIE)? > > It's taken as "-r", relocatable in user space kexec-tools too originally. > I think Vivek just keeps it the same when moving into kernel. Ok. If that's the only reason then PIE is better suited at least for powerpc. > > I found a discussion from 2013 in the archives but from what I understood > > it was about the purgatory as a separate object vs having it linked into > > the kernel, which is different from what I'm asking: > > > > http://lists.infradead.org/pipermail/kexec/2013-December/010535.html > > > > Here is my motivation for this question: > > On ppc64 purgatory.ro has 12 relocation types when built as a partially > > > > linked object. This makes arch_kexec_apply_relocations_add duplicate a lot > > of code with module_64.c:apply_relocate_add to implement these > > relocations. The alternative is to do some refactoring so that both > > functions can share the implementation of the relocations. This is done > > in patches 5 and 6 of the > > kexec_file_load implementation for powerpc: > In user space kexec-tools utility, you also got this problem? Yes, kexec-tools' purgatory.ro has 10 relocation types instead of 12 (I don't know why), but that's still a lot. > > @@ -942,7 +1085,13 @@ static Elf_Sym *kexec_purgatory_find_symbol(struct > > purgatory_info *pi,> > > /* Go through symbols for a match */ > > for (k = 0; k < sechdrs[i].sh_size/sizeof(Elf_Sym); k++) { > > > > - if (ELF_ST_BIND(syms[k].st_info) != STB_GLOBAL) > > + /* > > + * FIXME: See if we can or should export the .TOC. > > + * symbol as global instead of searching local symbols > > + * here. > > + */ > > + if (ELF_ST_BIND(syms[k].st_info) != STB_GLOBAL && > > + ELF_ST_BIND(syms[k].st_info) != STB_LOCAL) > > > > continue; > > > > if (strcmp(strtab + syms[k].st_name, name) != 0) > > I don't need the change above anymore. I found a way to obtain the TOC pointer without looking for the .TOC. symbol. -- Thiago Jung Bauermann IBM Linux Technology Center