Date: Thu, 27 Jun 2019 14:33:53 -0700 From: Mark Millard <marklmi@yahoo.com> To: Justin Hibbits <jrh29@alumni.cwru.edu> Cc: freeBSD PowerPC ML <freebsd-ppc@freebsd.org> Subject: Re: Update to based on head -r349444: cross build using system clang 8.0.1 and devel/powerpc64-binutils failed for libc.so.7.full : bss-plt forced due to .../tmp/usr/lib/crtbeginS.o then exit code 1 Message-ID: <56E29D38-F7EE-465E-B347-B6E889892106@yahoo.com> In-Reply-To: <A1801F93-982E-4404-B7A4-450261BB8295@yahoo.com> References: <CA176031-0E10-4725-B1D8-306196668202@yahoo.com> <7D8D1CB4-AF77-4681-8174-160F98F449CE@yahoo.com> <A1801F93-982E-4404-B7A4-450261BB8295@yahoo.com>
index | next in thread | previous in thread | raw e-mail
[Looks like ppc_elf_select_plt_layout code requires a R_PPC_REL16 variant
to be in use for it pick secure PLT in some contexts.]
On 2019-Jun-27, at 13:01, Mark Millard <marklmi at yahoo.com> wrote:
> [I show the command listed in the .meta file for how crtbeginS.o was produced.]
>
> On 2019-Jun-26, at 17:05, Mark Millard <marklmi at yahoo.com> wrote:
>
>> [I forgot to include my src.conf.powerpc-clang_altbinutils-bootstrap.amd64-host
>> file.]
>>
>> On 2019-Jun-26, at 16:57, Mark Millard <marklmi@yahoo.com> wrote:
>>
>>> This was an amd64->powerpc (32-bit) cross build. it happens even
>>> when /usr/obj/powerpcvtsc_clang_altbinutils/ is empty at the
>>> start.
>>>
>>> --- libc.so.7.full ---
>>> building shared library libc.so.7
>>> /usr/local/powerpc64-unknown-freebsd13.0/bin/ld: bss-plt forced due to /usr/obj/powerpcvtsc_clang_altbinutils/powerpc.powerpc/usr/src/powerpc.powerpc/tmp/usr/lib/crtbeginS.o
>>> cc: error: linker command failed with exit code 1 (use -v to see invocation)
>>> *** [libc.so.7.full] Error code 1
>
> FYI the command producing crtbeginS.o for this type of context is recorded as:
> (I did some line splitting for readability.)
>
> # Meta data file /usr/obj/powerpcvtsc_clang_altbinutils/powerpc.powerpc/usr/src/powerpc.powerpc/gnu/lib/csu/crtbeginS.o.meta
> CMD cc -target powerpc-unknown-freebsd13.0 \
> --sysroot=/usr/obj/powerpcvtsc_clang_altbinutils/powerpc.powerpc/usr/src/powerpc.powerpc/tmp \
> -B/usr/local/powerpc64-unknown-freebsd13.0/bin/ \
> -O2 -pipe \
> -B/usr/local/powerpc64-unknown-freebsd13.0/bin/ \
> -DIN_GCC -DHAVE_LD_EH_FRAME_HDR -DDT_CONFIG -D__GLIBC__=3 \
> -fno-inline-functions -fno-exceptions -fno-zero-initialized-in-bss \
> -fno-asynchronous-unwind-tables -fno-omit-frame-pointer \
> -I/usr/src/contrib/gcclibs/include -I/usr/src/contrib/gcc/config -I/usr/src/contrib/gcc -I. \
> -I/usr/src/gnu/usr.bin/cc/cc_tools \
> -g -std=gnu89 -Qunused-arguments -g0 \
> -DCRT_BEGIN -DCRTSTUFFS_O -DSHARED \
> -fpic -c -o crtbeginS.o /usr/src/contrib/gcc/crtstuff.c
> CWD /usr/obj/powerpcvtsc_clang_altbinutils/powerpc.powerpc/usr/src/powerpc.powerpc/gnu/lib/csu
> TARGET crtbeginS.o
> -- command output --
>
> -- filemon acquired metadata --
> . . .
Look like binutils requires use of one of:
case R_PPC_REL16:
case R_PPC_REL16_LO:
case R_PPC_REL16_HI:
case R_PPC_REL16_HA:
ppc_elf_tdata (abfd)->has_rel16 = 1;
break;
in order to cause secure PLT use instead of bss-plt
(from ppc_elf_select_plt_layout in .../binutils-2_25_1/bfd/elf32-ppc.c ):
. . .
if (htab->plt_type == PLT_UNSET)
{
struct elf_link_hash_entry *h;
if (htab->params->plt_style == PLT_OLD)
htab->plt_type = PLT_OLD;
else if (info->shared
&& htab->elf.dynamic_sections_created
&& (h = elf_link_hash_lookup (&htab->elf, "_mcount",
FALSE, FALSE, TRUE)) != NULL
&& (h->type == STT_FUNC
|| h->needs_plt)
&& h->ref_regular
&& !(SYMBOL_CALLS_LOCAL (info, h)
|| (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
&& h->root.type == bfd_link_hash_undefweak)))
. . .
else
{
bfd *ibfd;
enum ppc_elf_plt_type plt_type = htab->params->plt_style;
/* Look through the reloc flags left by ppc_elf_check_relocs.
Use the old style bss plt if a file makes plt calls
without using the new relocs, and if ld isn't given
--secure-plt and we never see REL16 relocs. */
if (plt_type == PLT_UNSET)
plt_type = PLT_OLD;
for (ibfd = info->input_bfds; ibfd; ibfd = ibfd->link.next)
if (is_ppc_elf (ibfd))
{
if (ppc_elf_tdata (ibfd)->has_rel16)
plt_type = PLT_NEW;
else if (ppc_elf_tdata (ibfd)->makes_plt_call)
{
plt_type = PLT_OLD;
htab->old_bfd = ibfd;
break;
}
}
htab->plt_type = plt_type;
}
}
if (htab->plt_type == PLT_OLD && htab->params->plt_style == PLT_NEW)
{
if (htab->old_bfd != NULL)
info->callbacks->einfo (_("%P: bss-plt forced due to %B\n"),
htab->old_bfd);
else
info->callbacks->einfo (_("%P: bss-plt forced by profiling\n"));
}
. . .
And crtbeginS.o shows no use of any of the 4 R_PPC_REL16 variants ...
Relocation section with addend (.rela.text):
r_offset r_info r_type st_value st_name + r_addend
0000001c 00000d17 R_PPC_LOCAL24PC 00000000 _GLOBAL_OFFSET_TABLE_ + fffffffc
00000026 0000060e R_PPC_GOT16 00000008 __do_global_dtors_aux.completed + 0
00000036 00000f0e R_PPC_GOT16 00000000 __cxa_finalize + 0
00000042 0000100e R_PPC_GOT16 00000000 __dso_handle + 0
00000048 00000f12 R_PPC_PLTREL24 00000000 __cxa_finalize + 8000
0000004e 0000070e R_PPC_GOT16 00000004 __do_global_dtors_aux.p + 0
00000062 0000070e R_PPC_GOT16 00000004 __do_global_dtors_aux.p + 0
00000086 0000060e R_PPC_GOT16 00000008 __do_global_dtors_aux.completed + 0
000000ec 00000d17 R_PPC_LOCAL24PC 00000000 _GLOBAL_OFFSET_TABLE_ + fffffffc
000000f6 0000040e R_PPC_GOT16 00000000 __JCR_LIST__ + 0
00000106 00000e0e R_PPC_GOT16 00000000 _Jv_RegisterClasses + 0
00000112 0000040e R_PPC_GOT16 00000000 __JCR_LIST__ + 0
Relocation section with addend (.rela.fini):
r_offset r_info r_type st_value st_name + r_addend
00000000 00000b0a R_PPC_REL24 00000000 .text + 0
Relocation section with addend (.rela.init):
r_offset r_info r_type st_value st_name + r_addend
00000000 00000b0a R_PPC_REL24 00000000 .text + d4
Relocation section with addend (.rela.data):
r_offset r_info r_type st_value st_name + r_addend
00000000 00001001 R_PPC_ADDR32 00000000 __dso_handle + 0
00000004 00000c01 R_PPC_ADDR32 00000000 .dtors + 4
>
>>> . . .
>>
>>
>> # more ~/src.configs/src.conf.powerpc-clang_altbinutils-bootstrap.amd64-host
>> TO_TYPE=powerpc
>> TOOLS_TO_TYPE=powerpc64
>> VERSION_CONTEXT=13.0
>> #
>> KERNCONF=GENERICvtsc-NODBG
>> TARGET=${TO_TYPE}
>> .if ${.MAKE.LEVEL} == 0
>> TARGET_ARCH=${TO_TYPE}
>> .export TARGET_ARCH
>> .endif
>> #
>> #WITH_CROSS_COMPILER=
>> WITH_SYSTEM_COMPILER=
>> WITHOUT_SYSTEM_LINKER=
>> #
>> # llvm's libunwind for 32-bit powerpc:
>> # Two of its .S files get tons of error reports.
>> # So avoid llvm's libunwind for now.
>> WITHOUT_LLVM_LIBUNWIND=
>> WITH_LIBCPLUSPLUS=
>> WITHOUT_LLD_BOOTSTRAP=
>> WITHOUT_BINUTILS_BOOTSTRAP=
>> WITH_ELFTOOLCHAIN_BOOTSTRAP=
>> #Disables avoiding bootstrap: WITHOUT_LLVM_TARGET_ALL=
>> WITHOUT_LLVM_TARGET_AARCH64=
>> WITHOUT_LLVM_TARGET_ARM=
>> WITHOUT_LLVM_TARGET_MIPS=
>> WITH_LLVM_TARGET_POWERPC=
>> WITHOUT_LLVM_TARGET_SPARC=
>> WITHOUT_LLVM_TARGET_X86=
>> #WITH_CLANG_BOOTSTRAP=
>> WITH_CLANG=
>> WITH_CLANG_IS_CC=
>> WITH_CLANG_FULL=
>> WITH_CLANG_EXTRAS=
>> # Note: LLD is only for experimentation
>> WITH_LLD=
>> WITHOUT_LLD_IS_LD=
>> WITH_BINUTILS=
>> WITH_PORT_BASE_BINUTILS=
>> # Note: no 8 Byte atomics, so not LLDB
>> WITHOUT_LLDB=
>> #
>> WITH_BOOT=
>> WITHOUT_LIB32=
>> #
>> LOADER_DEFAULT_INTERP=4th
>> #
>> WITHOUT_GCC_BOOTSTRAP=
>> WITHOUT_GCC=
>> WITHOUT_GCC_IS_CC=
>> WITHOUT_GNUCXX=
>> #
>> NO_WERROR=
>> #
>> # Avoid "converts between pointers to integer types with different sign [-Werror,-Wpointer-sign]"
>> # and such from blocking the build.
>> WERROR=
>> MALLOC_PRODUCTION=
>> #
>> # Avoid stripping but do not control host -g status as well:
>> DEBUG_FLAGS+=
>> #
>> WITH_REPRODUCIBLE_BUILD=
>> WITH_DEBUG_FILES=
>> #
>> #
>> # For TO (so-called "cross") stages . . .
>> # So-called-cross via ${TO_TYPE}-xtoolchain-gcc/${TO_TYPE}-gcc. . .
>> # TOOLS_TO_TYPE based on ${TO_TYPE}-xtoolchain-gcc related binutils. . .
>> #
>> CROSS_BINUTILS_PREFIX=/usr/local/${TOOLS_TO_TYPE}-unknown-freebsd${VERSION_CONTEXT}/bin/
>> .if ${.MAKE.LEVEL} == 0
>> CFLAGS.powerpc+= -B${CROSS_BINUTILS_PREFIX}
>> CXXFLAGS.powerpc+= -B${CROSS_BINUTILS_PREFIX}
>> .export CFLAGS.powerpc
>> .export CXXFLAGS.powerpc
>> #
>> # Note: The WITH_CROSS_COMPILER picks up the CROSS_BINUTILS_PREFIX
>> # binding automatically.
>> #
>> XAS=/usr/local/${TOOLS_TO_TYPE}-unknown-freebsd${VERSION_CONTEXT}/bin/as -mppc32
>> XAR=/usr/local/${TOOLS_TO_TYPE}-unknown-freebsd${VERSION_CONTEXT}/bin/ar
>> XNM=/usr/local/${TOOLS_TO_TYPE}-unknown-freebsd${VERSION_CONTEXT}/bin/nm
>> XOBJCOPY=/usr/local/${TOOLS_TO_TYPE}-unknown-freebsd${VERSION_CONTEXT}/bin/objcopy
>> XOBJDUMP=/usr/local/${TOOLS_TO_TYPE}-unknown-freebsd${VERSION_CONTEXT}/bin/objdump
>> XRANLIB=/usr/local/${TOOLS_TO_TYPE}-unknown-freebsd${VERSION_CONTEXT}/bin/ranlib
>> XSIZE=/usr/local/${TOOLS_TO_TYPE}-unknown-freebsd${VERSION_CONTEXT}/bin/size
>> #NO-SUCH: XSTRINGS=/usr/local/${TOOLS_TO_TYPE}-unknown-freebsd${VERSION_CONTEXT}/bin/strings
>> XSTRINGS=/usr/local/bin/${TOOLS_TO_TYPE}-unknown-freebsd${VERSION_CONTEXT}-strings
>> .export XAS
>> .export XAR
>> .export XNM
>> .export XOBJCOPY
>> .export XOBJDUMP
>> .export XRANLIB
>> .export XSIZE
>> .export XSTRINGS
>> XLD=/usr/local/${TOOLS_TO_TYPE}-unknown-freebsd${VERSION_CONTEXT}/bin/ld -m elf32ppc_fbsd
>> .export XLD
>> .endif
===
Mark Millard
marklmi at yahoo.com
( dsl-only.net went
away in early 2018-Mar)
home |
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?56E29D38-F7EE-465E-B347-B6E889892106>
