Date: Thu, 10 Aug 2017 22:24:56 -0700 From: Mark Millard <markmi@dsl-only.net> To: Dimitry Andric <dim@freebsd.org>, Ed Maste <emaste@freebsd.org>, FreeBSD Toolchain <freebsd-toolchain@freebsd.org>, FreeBSD PowerPC ML <freebsd-ppc@freebsd.org>, FreeBSD Current <freebsd-current@freebsd.org> Subject: Re: I have submitted bugzilla 221107 for a (e.g.) -r321706 system clang 5 vintage TARGET_ARCH=powerpc buildkernel failure for aha.kld: R_PPC_PLTREL24 reloc against local symbol Message-ID: <F9F0D662-0C1D-48E8-8BCA-8E79E17FE0DB@dsl-only.net> In-Reply-To: <46806707-4FB6-4265-A5B3-F3D4EF3C861C@dsl-only.net> References: <186BF66E-04E5-4663-AD0B-E07A9C631925@dsl-only.net> <636276E6-BA4C-4C28-84FF-A34BDF1F1702@dsl-only.net> <51700A90-8DB5-4D81-AC83-D3FB0FDEFED7@dsl-only.net> <46806707-4FB6-4265-A5B3-F3D4EF3C861C@dsl-only.net>
next in thread | previous in thread | raw e-mail | index | archive | help
[clang 5 generates R_PPC_PLTREL24 in the .o files for global symbols in places gcc 4.2.1 generates R_PPC_ADDR16_HA / R_PPC_ADDR16_LO pairs.] On 2017-Aug-10, at 7:22 PM, Mark Millard <markmi at dsl-only.net> wrote: > [A top post about the failing R_PPC_PLTREL24 since > the material does not flow well as a sequential > read from prior material. I found that the .kld > does not match the contributing .o for GLOBAL > status for routines and the LOCAL in the .kld is > rejected by ld in ppc_elf_check_relocs.] >=20 > There is something consistent between the two example > failures. (The examples here are from a more recent > head version for a buildkernel attempt.) >=20 > (I inserted some lines not matched by the shown grep.) >=20 > # readelf -a = /usr/obj/powerpcvtsc_clang/powerpc.powerpc/usr/src/sys/GENERICvtsc-NODBG/m= odules/usr/src/sys/modules/aha/aha.kld | grep aha_alloc > 00002b8c 00003e12 R_PPC_PLTREL24 00000000 aha_alloc + 0 > 000031a8 00003e12 R_PPC_PLTREL24 00000000 aha_alloc + 0 > Symbol table (.symtab) contains 180 entries: > Num: Value Size Type Bind Vis Ndx Name > 62: 0000000000000000 96 FUNC LOCAL DEFAULT 1 aha_alloc >=20 > but in aha.o : >=20 > 44: 0000000000000000 96 FUNC GLOBAL DEFAULT 2 aha_alloc >=20 > # readelf -a = /usr/obj/powerpcvtsc_clang/powerpc.powerpc/usr/src/sys/GENERICvtsc-NODBG/m= odules/usr/src/sys/modules/agp/agp.kld | grep agp_find_caps > 00002e08 00004912 R_PPC_PLTREL24 00000000 agp_find_caps + 0 > Symbol table (.symtab) contains 180 entries: > Num: Value Size Type Bind Vis Ndx Name > 73: 0000000000000000 172 FUNC LOCAL DEFAULT 1 = agp_find_caps >=20 > but in agp.o : >=20 > 58: 0000000000000000 172 FUNC GLOBAL DEFAULT 2 = agp_find_caps >=20 > building the .kld's is turning GLOBAL into LOCAL -- and the LOCAL > is being rejected by: >=20 > /usr/src/contrib/binutils/bfd/elf32-ppc.c >=20 > in its routine: >=20 > /* Look through the relocs for a section during the first phase, and > allocate space in the global offset table or procedure linkage > table. */ >=20 > static bfd_boolean > ppc_elf_check_relocs (bfd *abfd, > struct bfd_link_info *info, > asection *sec, > const Elf_Internal_Rela *relocs) >=20 > via: >=20 >=20 > r_symndx =3D ELF32_R_SYM (rel->r_info); > if (r_symndx < symtab_hdr->sh_info) > h =3D NULL; > else =20 >=20 > . . . > tls_type =3D 0; > r_type =3D ELF32_R_TYPE (rel->r_info); > . . . =20 > switch (r_type) > { > . . . > case R_PPC_PLT32: > case R_PPC_PLTREL24: > case R_PPC_PLTREL32: > case R_PPC_PLT16_LO: > case R_PPC_PLT16_HI: > case R_PPC_PLT16_HA: > #ifdef DEBUG > fprintf (stderr, "Reloc requires a PLT entry\n"); > #endif > /* This symbol requires a procedure linkage table entry. We > actually build the entry in finish_dynamic_symbol, > because this might be a case of linking PIC code without > linking in any dynamic objects, in which case we don't > need to generate a procedure linkage table after all. */ >=20 > if (h =3D=3D NULL) > { > /* It does not make sense to have a procedure linkage > table entry for a local symbol. */ > (*_bfd_error_handler) (_("%B(%A+0x%lx): %s reloc against = " > "local symbol"), > abfd, > sec, > (long) rel->r_offset, > = ppc_elf_howto_table[r_type]->name); > bfd_set_error (bfd_error_bad_value); > return FALSE; > } > else > . . . clang 5 and gcc 4.2.1 do not match for what goes in aha*.o and agp*.o files for the problem symbols in clang 5's output: gcc 4.2.1 ( R_PPC_ADDR16_HA / R_PPC_ADDR16_LO ): # readelf -at = /usr/obj/powerpcvtsc_gcc421/powerpc.powerpc/usr/src/sys/GENERICvtsc-NODBG/= modules/usr/src/sys/modules/aha/aha*.o | grep aha_alloc 50: 0000000000000514 112 FUNC GLOBAL DEFAULT 1 aha_alloc 00000032 00003206 R_PPC_ADDR16_HA 00000000 aha_alloc + 0 0000003e 00003204 R_PPC_ADDR16_LO 00000000 aha_alloc + 0 0000052a 00003206 R_PPC_ADDR16_HA 00000000 aha_alloc + 0 0000052e 00003204 R_PPC_ADDR16_LO 00000000 aha_alloc + 0 50: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND aha_alloc # readelf -at = /usr/obj/powerpcvtsc_gcc421/powerpc.powerpc/usr/src/sys/GENERICvtsc-NODBG/= modules/usr/src/sys/modules/agp/agp*.o | grep caps 0000204a 00003a06 R_PPC_ADDR16_HA 00000434 agp_find_caps + 0 0000204e 00003a04 R_PPC_ADDR16_LO 00000434 agp_find_caps + 0 00002312 00003a06 R_PPC_ADDR16_HA 00000434 agp_find_caps + 0 0000231a 00003a04 R_PPC_ADDR16_LO 00000434 agp_find_caps + 0 00000000 00003a01 R_PPC_ADDR32 00000434 agp_find_caps + 0 58: 0000000000000434 192 FUNC GLOBAL DEFAULT 1 agp_find_caps 000002be 00003906 R_PPC_ADDR16_HA 00000000 agp_find_caps + 0 000002c6 00003904 R_PPC_ADDR16_LO 00000000 agp_find_caps + 0 57: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND agp_find_caps clang 5 ( R_PPC_PLTREL24 ): # readelf -at = /usr/obj/powerpcvtsc_clang/powerpc.powerpc/usr/src/sys/GENERICvtsc-NODBG/m= odules/usr/src/sys/modules/aha/aha*.o | grep aha_alloc 44: 0000000000000000 96 FUNC GLOBAL DEFAULT 2 aha_alloc 000000f0 00002e12 R_PPC_PLTREL24 00000000 aha_alloc + 0 0000070c 00002e12 R_PPC_PLTREL24 00000000 aha_alloc + 0 46: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND aha_alloc # readelf -at = /usr/obj/powerpcvtsc_clang/powerpc.powerpc/usr/src/sys/GENERICvtsc-NODBG/m= odules/usr/src/sys/modules/agp/agp*.o | grep caps 58: 0000000000000000 172 FUNC GLOBAL DEFAULT 2 agp_find_caps 00000138 00003512 R_PPC_PLTREL24 00000000 agp_find_caps + 0 53: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND agp_find_caps (Turning some R_PPC_PLTREL24 into LOCAL for *.kld files is a no-no as far as powerpc (32-bit) ld is concerned.) =3D=3D=3D Mark Millard markmi at dsl-only.net
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?F9F0D662-0C1D-48E8-8BCA-8E79E17FE0DB>