On 11/10/16 at 01:27am, Thiago Jung Bauermann wrote: > powerpc's purgatory.ro has 12 relocation types when built as > a relocatable object. To implement support for them requires > arch_kexec_apply_relocations_add to duplicate a lot of code with > module_64.c:apply_relocate_add. > > When built as a Position Independent Executable there are only 4 > relocation types in purgatory.ro, so it becomes practical for the powerpc > implementation of kexec_file to have its own relocation implementation. > > Also, the purgatory is an executable and not an intermediary output from > the compiler so it makes sense conceptually that it is easier to build > it as a PIE than as a partially linked object. > > Apart from the greatly reduced number of relocations, there are two > differences between a relocatable object and a PIE: > > 1. __kexec_load_purgatory needs to use the program headers rather than the > section headers to figure out how to load the binary. > 2. Symbol values are absolute addresses instead of relative to the > start of the section. > > This patch adds the support needed in generic code for the differences > above and allows powerpc to load and relocate a position independent > purgatory. > [snip] The kexec-tools machine_apply_elf_rel is pretty simple for ppc64, it is not that complex. So could you look into simplify your kexec_file implementation? kernel/kexec_file.c kexec_apply_relocations only do limited things and some of the logic is in arch/x86, so move general code out of arch code, then I guess the arch code will be simpler and then we probably do not need this PIE stuff anymore. BTW, __kexec_really_load_purgatory looks worse than ___kexec_load_purgatory ;) Thanks Dave