From owner-freebsd-ppc@freebsd.org Fri Aug 11 05:25:00 2017 Return-Path: Delivered-To: freebsd-ppc@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 11955DB7B99 for ; Fri, 11 Aug 2017 05:25:00 +0000 (UTC) (envelope-from markmi@dsl-only.net) Received: from asp.reflexion.net (outbound-mail-210-81.reflexion.net [208.70.210.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C479713B1 for ; Fri, 11 Aug 2017 05:24:59 +0000 (UTC) (envelope-from markmi@dsl-only.net) Received: (qmail 5532 invoked from network); 11 Aug 2017 05:24:57 -0000 Received: from unknown (HELO rtc-sm-01.app.dca.reflexion.local) (10.81.150.1) by 0 (rfx-qmail) with SMTP; 11 Aug 2017 05:24:57 -0000 Received: by rtc-sm-01.app.dca.reflexion.local (Reflexion email security v8.40.2) with SMTP; Fri, 11 Aug 2017 01:24:57 -0400 (EDT) Received: (qmail 10861 invoked from network); 11 Aug 2017 05:24:57 -0000 Received: from unknown (HELO iron2.pdx.net) (69.64.224.71) by 0 (rfx-qmail) with (AES256-SHA encrypted) SMTP; 11 Aug 2017 05:24:57 -0000 Received: from [192.168.1.26] (c-76-115-7-162.hsd1.or.comcast.net [76.115.7.162]) by iron2.pdx.net (Postfix) with ESMTPSA id 1019CEC8AE2; Thu, 10 Aug 2017 22:24:57 -0700 (PDT) From: Mark Millard Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) 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 Date: Thu, 10 Aug 2017 22:24:56 -0700 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> To: Dimitry Andric , Ed Maste , FreeBSD Toolchain , FreeBSD PowerPC ML , FreeBSD Current In-Reply-To: <46806707-4FB6-4265-A5B3-F3D4EF3C861C@dsl-only.net> Message-Id: X-Mailer: Apple Mail (2.3273) X-BeenThere: freebsd-ppc@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Porting FreeBSD to the PowerPC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Aug 2017 05:25:00 -0000 [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 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