Involving devel/binutils at powerpc64 in buildworld buildkernel : got/toc optimization is not supported for addis %r1,%r1,TOC_REF(trapstk)@ha (and the like)

Mark Millard marklmi at yahoo.com
Tue Jan 7 07:18:58 UTC 2020



On 2020-Jan-6, at 22:52, Mark Millard <marklmi at yahoo.com> wrote:

> The following is based on what I noticed while
> working on updating to head -r356426 ,  including
> building multiple ways (discovering what fails
> to build and such).
> 
> I was looking at messages and noticed that there
> were messages such as:
> 
> --- kernel.full ---
> locore.o: in function `dbtrap':
> /usr/src/sys/powerpc/aim/trap_subr64.S:905:(.text+0xa68): got/toc optimization is not supported for 0x3c210000 instruction
> 
> That is the addis instruction in:
> 
> dbtrap:
>        /* Write the trap vector to SPRG3 by computing LR & 0xff00 */
>        mflr    %r1
>        andi.   %r1,%r1,0xff00
>        mtsprg3 %r1
> 
>        GET_TOCBASE(%r1)                        /* get new SP */
>        addis   %r1,%r1,TOC_REF(trapstk)@ha
>        ld      %r1,TOC_REF(trapstk)@l(%r1)
>        addi    %r1,%r1,(TRAPSTKSZ-48)
> 
> (based on line number).
> 
> This was for system-clang and devel/binutils at powerpc64
> being used to do the build.
> 
> But it also happened for devel/freebsd-gcc9 at powerpc64
> and devel/binutils at powerpc64 bing used to do the
> build:
> 
> --- kernel.full ---
> locore.o: in function `dbtrap':
> /usr/src/sys/powerpc/aim/trap_subr64.S:905:(.text+0xa68): got/toc optimization is not supported for 0x3c210000 instruction
> 
> (Same instruction, same message.)
> 
> 
> There are lots of similar messages for other instruction
> encodings for zfs.ko.full --but only for the
> devel/freebsd-gcc9 at powerpc64 and devel/binutils at powerpc64
> combination:
> 
> --- zfs.ko.full ---
> zfs.kld: in function `acl_trivial_create':
> /usr/src/sys/cddl/contrib/opensolaris/common/acl/acl_common.c:1646:(.text+0x568): got/toc optimization is not supported for 0x3d9e0000 instruction
> zfs.kld: in function `cacl_malloc':
> /usr/src/sys/cddl/contrib/opensolaris/common/acl/acl_common.c:243:(.text+0x5e0): got/toc optimization is not supported for 0x3d9e0000 instruction
> zfs.kld: in function `ace_trivial':
> /usr/src/sys/cddl/contrib/opensolaris/common/acl/acl_common.c:1764:(.text+0x990): got/toc optimization is not supported for 0x3d9e0000 instruction
> zfs.kld: in function `avl_nearest':
> . . .
> 
> The list for zfs.ko.full is large.
> 
> Overall there are examples of each of:
> 
> got/toc optimization is not supported for 0x3c210000 instruction
> got/toc optimization is not supported for 0x3c9e0000 instruction
> got/toc optimization is not supported for 0x3cbe0000 instruction
> got/toc optimization is not supported for 0x3cde0000 instruction
> got/toc optimization is not supported for 0x3cfe0000 instruction
> got/toc optimization is not supported for 0x3d1e0000 instruction
> got/toc optimization is not supported for 0x3d3e0000 instruction
> got/toc optimization is not supported for 0x3d5e0000 instruction
> got/toc optimization is not supported for 0x3d9e0000 instruction
> got/toc optimization is not supported for 0x3dde0000 instruction
> got/toc optimization is not supported for 0x3dfe0000 instruction
> got/toc optimization is not supported for 0x3e1e0000 instruction
> got/toc optimization is not supported for 0x3e3e0000 instruction
> got/toc optimization is not supported for 0x3e5e0000 instruction
> got/toc optimization is not supported for 0x3e7e0000 instruction
> got/toc optimization is not supported for 0x3e9e0000 instruction
> got/toc optimization is not supported for 0x3ebe0000 instruction
> got/toc optimization is not supported for 0x3ede0000 instruction
> got/toc optimization is not supported for 0x3efe0000 instruction
> got/toc optimization is not supported for 0x3f1e0000 instruction
> got/toc optimization is not supported for 0x3f3e0000 instruction
> got/toc optimization is not supported for 0x3f5e0000 instruction
> got/toc optimization is not supported for 0x3f7e0000 instruction
> got/toc optimization is not supported for 0x3f9e0000 instruction
> got/toc optimization is not supported for 0x3fbe0000 instruction
> 
> I'm not sure of the implications, but I figured that the
> information might be of use at some point.

Looking around on the web, it looks like the
relevant code in gnu's ld might be from this
2019-Aug-19 material:

+	      enum {no_check, check_lo, check_ha} insn_check;
 
 	      r_type = ELF64_R_TYPE (rel->r_info);
+	      switch (r_type)
+		{
+		default:
+		  insn_check = no_check;
+		  break;
+
+		case R_PPC64_PLT16_HA:
+		case R_PPC64_GOT_TLSLD16_HA:
+		case R_PPC64_GOT_TLSGD16_HA:
+		case R_PPC64_GOT_TPREL16_HA:
+		case R_PPC64_GOT_DTPREL16_HA:
+		case R_PPC64_GOT16_HA:
+		case R_PPC64_TOC16_HA:
+		  insn_check = check_ha;
+		  break;
+
+		case R_PPC64_PLT16_LO:
+		case R_PPC64_PLT16_LO_DS:
+		case R_PPC64_GOT_TLSLD16_LO:
+		case R_PPC64_GOT_TLSGD16_LO:
+		case R_PPC64_GOT_TPREL16_LO_DS:
+		case R_PPC64_GOT_DTPREL16_LO_DS:
+		case R_PPC64_GOT16_LO:
+		case R_PPC64_GOT16_LO_DS:
+		case R_PPC64_TOC16_LO:
+		case R_PPC64_TOC16_LO_DS:
+		  insn_check = check_lo;
+		  break;
+		}
+
+	      if (insn_check != no_check)
+		{
+		  bfd_vma off = rel->r_offset & ~3;
+
+		  if (!bfd_get_section_contents (ibfd, sec, buf, off, 4))
+		    goto got_error_ret;
+
+		  insn = bfd_get_32 (ibfd, buf);
+		  if (insn_check == check_lo
+		      ? !ok_lo_toc_insn (insn, r_type)
+		      : ((insn & ((0x3f << 26) | 0x1f << 16))
+			 != ((15u << 26) | (2 << 16)) /* addis rt,2,imm */))
+		    {
+		      char str[12];
+
+		      ppc64_elf_tdata (ibfd)->unexpected_toc_insn = 1;
+		      sprintf (str, "%#08x", insn);
+		      info->callbacks->einfo
+			/* xgettext:c-format */
+			(_("%H: got/toc optimization is not supported for"
+			   " %s instruction\n"),
+			 ibfd, sec, rel->r_offset & ~3, str);
+		      continue;
+		    }
+		}




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



More information about the freebsd-ppc mailing list