Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 6 Jun 2019 17:55:33 -0700
From:      Mark Millard <marklmi@yahoo.com>
To:        FreeBSD PowerPC ML <freebsd-ppc@freebsd.org>
Subject:   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:  <FBE50EB5-F3DB-4386-8EA4-DF524B98023D@yahoo.com>

next in thread | raw e-mail | index | archive | help

/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 =3D=3D 1
                memcpy(where, (Elf_Addr *)addr, 3*sizeof(Elf_Addr));
#else
                *where =3D 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]=3D013a358835fddcd6bbb82d35a6ce36243eccb743, not stripped

So, naturally, module loading such (manual or automatic)
is a problem for the 32-bit powerpc context.

The context was head -r347549 .

=3D=3D=3D
Mark Millard
marklmi at yahoo.com
( dsl-only.net went
away in early 2018-Mar)




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?FBE50EB5-F3DB-4386-8EA4-DF524B98023D>