Date: Thu, 6 Jun 2019 21:41:06 -0500 From: Justin Hibbits <jrh29@alumni.cwru.edu> To: Mark Millard <marklmi@yahoo.com> Cc: FreeBSD PowerPC ML <freebsd-ppc@freebsd.org> Subject: Re: 32-bit powerpc's elf_reloc_internal has no support for R_PPC_JMP_SLOT but clang with devel/powerpc64-binutils uses such for building kernel modules Message-ID: <CAHSQbTAAQMQNYcmGQttmcZsgQ9A4n6gd%2BvODttohERJEtZn9wA@mail.gmail.com> In-Reply-To: <FBE50EB5-F3DB-4386-8EA4-DF524B98023D@yahoo.com> References: <FBE50EB5-F3DB-4386-8EA4-DF524B98023D@yahoo.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Jun 6, 2019 at 8:06 PM Mark Millard via freebsd-ppc <freebsd-ppc@freebsd.org> wrote: > > > /usr/src/sys/powerpc/powerpc/elf64_machdep.c has: > > static int > elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, const void *data, > int type, int local, elf_lookup_fn lookup) > { > . . . > case R_PPC_JMP_SLOT: /* function descriptor copy */ > lookup(lf, symidx, 1, &addr); > #if !defined(_CALL_ELF) || _CALL_ELF == 1 > memcpy(where, (Elf_Addr *)addr, 3*sizeof(Elf_Addr)); > #else > *where = addr; > #endif > __asm __volatile("dcbst 0,%0; sync" :: "r"(where) : "memory"); > break; > > . . . > > But /usr/src/sys/powerpc/powerpc/elf32_machdep.c 's elf_reloc_internal > does not have any R_PPC_JMP_SLOT case in its code. > > Yet, from using clang as the system compiler for targeting 32-bit powerpc, > readelf -asW /boot/kernel/if_gem.ko shows the likes of: > > Relocation section with addend (.rela.plt): > r_offset r_info r_type st_value st_name + r_addend > 00018328 00000215 R_PPC_JMP_SLOT 00000000 if_maddr_runlock + 0 > 00018330 00000315 R_PPC_JMP_SLOT 00000000 mii_mediachg + 0 > 00018338 00000415 R_PPC_JMP_SLOT 00000000 m_freem + 0 > 00018340 00000515 R_PPC_JMP_SLOT 00000000 device_get_softc + 0 > 00018348 00000715 R_PPC_JMP_SLOT 00000000 device_set_desc + 0 > 00018350 00000815 R_PPC_JMP_SLOT 00000000 printf + 0 > 00018358 00000b15 R_PPC_JMP_SLOT 00000000 ether_crc32_le + 0 > 00018360 00000e15 R_PPC_JMP_SLOT 00000000 bpf_mtap + 0 > . . . > > # file /boot/kernel/if_gem.ko > /boot/kernel/if_gem.ko: ELF 32-bit MSB shared object, PowerPC or cisco 4500, version 1 (FreeBSD), dynamically linked, BuildID[sha1]=013a358835fddcd6bbb82d35a6ce36243eccb743, not stripped > > So, naturally, module loading such (manual or automatic) > is a problem for the 32-bit powerpc context. > > The context was head -r347549 . > > === > Mark Millard > marklmi at yahoo.com > ( dsl-only.net went > away in early 2018-Mar) Can you try this patch? Untested, just compiled. It's essentially a copy of the ELFv2 part of the elf64_machdep bit you posted above. - Justin diff --git a/sys/powerpc/powerpc/elf32_machdep.c b/sys/powerpc/powerpc/elf32_machdep.c index 11c14671d0b..219a61363cd 100644 --- a/sys/powerpc/powerpc/elf32_machdep.c +++ b/sys/powerpc/powerpc/elf32_machdep.c @@ -295,6 +295,12 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, const void *data, *where = elf_relocaddr(lf, relocbase + addend); break; + case R_PPC_JMP_SLOT: + lookup(lf, symidx, 1, &addr); + *where = addr; + __asm __volatile("dcbst 0,%0; sync" :: "r"(where) : "memory"); + break; + default: printf("kldload: unexpected relocation type %d\n", (int) rtype);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAHSQbTAAQMQNYcmGQttmcZsgQ9A4n6gd%2BvODttohERJEtZn9wA>