ld version (for targetting powerpc64 from amd64):
( from the port devel/binutils@powerpc64 )
# powerpc64-unknown-freebsd13.0-ld --version
GNU ld (GNU Binutils) 2.33.1
. . .
Host OS version:
# uname -apKU
FreeBSD ... 13.0-CURRENT FreeBSD 13.0-CURRENT #57 r356426M: Mon Jan 6 16:37:25 PST 2020 . . . amd64 amd64 1300075 1300075
compiler used to build ld :
# cc -v
FreeBSD clang version 9.0.1 (g...@github.com:llvm/llvm-project.git c1a0a213378a458fbea1a5c77b315c7dce08fd05) (based on LLVM 9.0.1)
Target: x86_64-unknown-freebsd13.0
Thread model: posix
InstalledDir: /usr/bin
compiler/toolchain used to produced what was being linked:
devel/freebsd-gcc9@powerpc64 (compiler) and
devel/binutils@powerpc64 (other toolchain items).
As for the gcc9 version:
# /usr/local/bin/powerpc64-unknown-freebsd13.0-g++9 --version
powerpc64-unknown-freebsd13.0-g++9 (FreeBSD Ports Collection for powerpc64) 9.2.0
The evidence: I was able to attach with gdb and identify
the looping code, done originally after the code had been
running for hours:
[Switching to LWP 100943 of process 14113]
0x000000000035431d in ppc64_elf_inline_plt (info=<optimized out>) at elf64-ppc.c:7473
7473 && r_type != R_PPC64_PLTCALL_NOTOC)
(gdb) bt
#0 0x000000000035431d in ppc64_elf_inline_plt (info=<optimized out>) at elf64-ppc.c:7473
#1 0x000000000032acb0 in ppc_before_allocation () at eelf64ppc_fbsd.c:370
#2 0x0000000000319651 in lang_process () at ldlang.c:7678
#3 0x00000000003208d8 in main (argc=<optimized out>, argv=<optimized out>) at ./ldmain.c:441
As for the source code that loops badly in
some contexts:
. . .
/* Read the relocations. */
relstart = _bfd_elf_link_read_relocs (ibfd, sec, NULL, NULL,
info->keep_memory);
if (relstart == NULL)
return FALSE;
relend = relstart + sec->reloc_count;
for (rel = relstart; rel < relend; )
{
enum elf_ppc64_reloc_type r_type;
unsigned long r_symndx;
asection *sym_sec;
struct elf_link_hash_entry *h;
Elf_Internal_Sym *sym;
unsigned char *tls_maskp;
r_type = ELF64_R_TYPE (rel->r_info);
if (r_type != R_PPC64_PLTCALL
&& r_type != R_PPC64_PLTCALL_NOTOC)
continue;
. . .
Nothing is done before the continue to make rel
progress towards relend (or relend towards
relstart). It just repeats the same activity
over and over on the same rel value. An
observed case is:
(gdb) print r_type
$1 = R_PPC64_REL16_HA
(gdb) print/x *rel
$3 = {r_offset = 0x2, r_info = 0x18000000fc, r_addend = 0x2}
(I expect that unbounded looping is treated as
equivalent to a crash is so is a bug to report,
no matter what the inputs were.)
Unfortunately the context was large and complicated:
it failed trying to produce lld and so far I've not
isolated how to get R_PPC64_REL16_HA to occur in that
loop in a smaller context (or anything else that would
cause the continue to execute). But I figured this
evidence, of the unbounded loop existing, would be
useful.
However, here is the linker command that was recorded.
powerpc64-unknown-freebsd13.0-ld was run via
powerpc64-unknown-freebsd13.0-g++9 but that had -v
so there is a lot of output detail:
(There likely is some odd line splitting in getting
it copied over.)
# Meta data file /usr/obj/powerpc64vtsc_xtoolchain-gcc/powerpc.powerpc64/usr/src/powerpc.powerpc64/usr.bin/clang/lld/ld.lld.full.meta
CMD /usr/local/bin/powerpc64-unknown-freebsd13.0-g++9 --sysroot=/usr/obj/powerpc64vtsc_xtoolchain-gcc/powerpc.powerpc64/usr/src/powerpc.powerpc64/tmp -B/usr/local/powerpc64-unknown-freebsd13.0/bin/ -O
2 -pipe -I/usr/src/contrib/llvm-project/lld/ELF -I/usr/src/contrib/llvm-project/lld/include -I/usr/obj/powerpc64vtsc_xtoolchain-gcc/powerpc.powerpc64/usr/src/powerpc.powerpc64/usr.bin/clang/lld -I/usr
/obj/powerpc64vtsc_xtoolchain-gcc/powerpc.powerpc64/usr/src/powerpc.powerpc64/lib/clang/libllvm -I/usr/src/lib/clang/include -I/usr/src/contrib/llvm-project/llvm/include -D__STDC_CONSTANT_MACROS -D__S
TDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -DHAVE_VCS_VERSION_INC -DLLVM_DEFAULT_TARGET_TRIPLE=\"powerpc64-unknown-freebsd13.0\" -DLLVM_HOST_TRIPLE=\"powerpc64-unknown-freebsd13.0\" -DDEFAULT_SYSROOT=\"\
" -DLLVM_TARGET_ENABLE_POWERPC -DLLVM_NATIVE_ASMPARSER=LLVMInitializePowerPCAsmParser -DLLVM_NATIVE_ASMPRINTER=LLVMInitializePowerPCAsmPrinter -DLLVM_NATIVE_DISASSEMBLER=LLVMInitializePowerPCDisassemb
ler -DLLVM_NATIVE_TARGET=LLVMInitializePowerPCTarget -DLLVM_NATIVE_TARGETINFO=LLVMInitializePowerPCTargetInfo -DLLVM_NATIVE_TARGETMC=LLVMInitializePowerPCTargetMC -ffunction-sections -fdata-sections -
g1 -Wno-format-zero-length -fstack-protector-strong -Wno-error=address -Wno-error=array-bounds -Wno-error=attributes -Wno-error=bool-compare -Wno-error=cast-align -Wno-error=clobbered -Wno-error=depre
cated-declarations -Wno-error=enum-compare -Wno-error=extra -Wno-error=inline -Wno-error=logical-not-parentheses -Wno-error=strict-aliasing -Wno-error=uninitialized -Wno-error=unused-but-set-variable
-Wno-error=unused-function -Wno-error=unused-value -Wno-error=misleading-indentation -Wno-error=nonnull-compare -Wno-error=shift-negative-value -Wno-error=tautological-compare -Wno-error=unused-const-
variable -Wno-error=bool-operation -Wno-error=deprecated -Wno-error=expansion-to-defined -Wno-error=format-overflow -Wno-error=format-truncation -Wno-error=implicit-fallthrough -Wno-error=int-in-bool-
context -Wno-error=memset-elt-size -Wno-error=noexcept-type -Wno-error=nonnull -Wno-error=pointer-compare -Wno-error=stringop-overflow -Wno-error=aggressive-loop-optimizations -Wno-error=cast-function
-type -Wno-error=catch-value -Wno-error=multistatement-macros -Wno-error=restrict -Wno-error=sizeof-pointer-memaccess -Wno-error=stringop-truncation -Wno-address-of-packed-member -v -fno-exceptions -f
no-rtti -std=c++11 -Wl,--gc-sections -o ld.lld.full Common/Args.o Common/ErrorHandler.o Common/Filesystem.o Common/Memory.o Common/Reproduce.o Common/Strings.o Common/TargetOptionsCommandFlags.o C
ommon/Threads.o Common/Version.o ELF/AArch64ErrataFix.o ELF/Arch/AArch64.o ELF/Arch/AMDGPU.o ELF/Arch/ARM.o ELF/Arch/AVR.o ELF/Arch/Hexagon.o ELF/Arch/MSP430.o ELF/Arch/Mips.o ELF/Arch/MipsArchTree.o
ELF/Arch/PPC.o ELF/Arch/PPC64.o ELF/Arch/RISCV.o ELF/Arch/SPARCV9.o ELF/Arch/X86.o ELF/Arch/X86_64.o ELF/CallGraphSort.o ELF/DWARF.o ELF/Driver.o ELF/DriverUtils.o ELF/EhFrame.o ELF/ICF.o ELF/InputFil
es.o ELF/InputSection.o ELF/LTO.o ELF/LinkerScript.o ELF/MapFile.o ELF/MarkLive.o ELF/OutputSections.o ELF/Relocations.o ELF/ScriptLexer.o ELF/ScriptParser.o ELF/SymbolTable.o ELF/Symbols.o ELF/Synthe
ticSections.o ELF/Target.o ELF/Thunks.o ELF/Writer.o lib/Core/Error.o lib/Core/File.o lib/Core/LinkingContext.o lib/Core/Reader.o lib/Core/Resolver.o lib/Core/SymbolTable.o tools/lld/lld.o /usr/obj/po
werpc64vtsc_xtoolchain-gcc/powerpc.powerpc64/usr/src/powerpc.powerpc64/lib/clang/libllvm/libllvm.a -lexecinfo -lncursesw -lz -lpthread
CWD /usr/obj/powerpc64vtsc_xtoolchain-gcc/powerpc.powerpc64/usr/src/powerpc.powerpc64/usr.bin/clang/lld
TARGET ld.lld.full
-- command output --
Using built-in specs.
COLLECT_GCC=/usr/local/bin/powerpc64-unknown-freebsd13.0-g++9
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/powerpc64-unknown-freebsd13.0/9.2.0/lto-wrapper
Target: powerpc64-unknown-freebsd13.0
Configured with: /wrkdirs/usr/ports/devel/freebsd-gcc9/work-powerpc64/gcc-9.2.0/configure --target=powerpc64-unknown-freebsd13.0 --disable-nls --enable-languages=c,c++ --enable-gnu-indirect-function -
-enable-initfini-array --program-prefix=powerpc64-unknown-freebsd13.0- --program-suffix=9 --without-headers --with-gmp=/usr/local --with-pkgversion='FreeBSD Ports Collection for powerpc64' --with-syst
em-zlib --with-gxx-include-dir=/usr/include/c++/v1/ --with-sysroot=/ --with-as=/usr/local/bin/powerpc64-unknown-freebsd13.0-as --with-ld=/usr/local/bin/powerpc64-unknown-freebsd13.0-ld --with-abi=elfv
2 --prefix=/usr/local --localstatedir=/var --mandir=/usr/local/man --infodir=/usr/local/share/info/ --build=x86_64-unknown-freebsd13.0
Thread model: posix
gcc version 9.2.0 (FreeBSD Ports Collection for powerpc64)
COMPILER_PATH=/usr/local/powerpc64-unknown-freebsd13.0/bin/:/usr/local/libexec/gcc/powerpc64-unknown-freebsd13.0/9.2.0/:/usr/local/libexec/gcc/powerpc64-unknown-freebsd13.0/9.2.0/:/usr/local/libexec/g
cc/powerpc64-unknown-freebsd13.0/:/usr/local/lib/gcc/powerpc64-unknown-freebsd13.0/9.2.0/:/usr/local/lib/gcc/powerpc64-unknown-freebsd13.0/:/usr/local/lib/gcc/powerpc64-unknown-freebsd13.0/9.2.0/../..
/../../powerpc64-unknown-freebsd13.0/bin/
LIBRARY_PATH=/usr/local/powerpc64-unknown-freebsd13.0/bin/:/usr/local/lib/gcc/powerpc64-unknown-freebsd13.0/9.2.0/:/usr/obj/powerpc64vtsc_xtoolchain-gcc/powerpc.powerpc64/usr/src/powerpc.powerpc64/tmp
/usr/lib/
COLLECT_GCC_OPTIONS='-B' '/usr/local/powerpc64-unknown-freebsd13.0/bin/' '-O2' '-pipe' '-I' '/usr/src/contrib/llvm-project/lld/ELF' '-I' '/usr/src/contrib/llvm-project/lld/include' '-I' '/usr/obj/powe
rpc64vtsc_xtoolchain-gcc/powerpc.powerpc64/usr/src/powerpc.powerpc64/usr.bin/clang/lld' '-I' '/usr/obj/powerpc64vtsc_xtoolchain-gcc/powerpc.powerpc64/usr/src/powerpc.powerpc64/lib/clang/libllvm' '-I'
'/usr/src/lib/clang/include' '-I' '/usr/src/contrib/llvm-project/llvm/include' '-D' '__STDC_CONSTANT_MACROS' '-D' '__STDC_FORMAT_MACROS' '-D' '__STDC_LIMIT_MACROS' '-D' 'HAVE_VCS_VERSION_INC' '-D' 'LL
VM_DEFAULT_TARGET_TRIPLE="powerpc64-unknown-freebsd13.0"' '-D' 'LLVM_HOST_TRIPLE="powerpc64-unknown-freebsd13.0"' '-D' 'DEFAULT_SYSROOT=""' '-D' 'LLVM_TARGET_ENABLE_POWERPC' '-D' 'LLVM_NATIVE_ASMPARSE
R=LLVMInitializePowerPCAsmParser' '-D' 'LLVM_NATIVE_ASMPRINTER=LLVMInitializePowerPCAsmPrinter' '-D' 'LLVM_NATIVE_DISASSEMBLER=LLVMInitializePowerPCDisassembler' '-D' 'LLVM_NATIVE_TARGET=LLVMInitializ
ePowerPCTarget' '-D' 'LLVM_NATIVE_TARGETINFO=LLVMInitializePowerPCTargetInfo' '-D' 'LLVM_NATIVE_TARGETMC=LLVMInitializePowerPCTargetMC' '-ffunction-sections' '-fdata-sections' '-g1' '-Wno-format-zero-
length' '-fstack-protector-strong' '-Wno-error=address' '-Wno-error=array-bounds' '-Wno-error=attributes' '-Wno-error=bool-compare' '-Wno-error=cast-align' '-Wno-error=clobbered' '-Wno-error=deprecate
d-declarations' '-Wno-error=enum-compare' '-Wno-error=extra' '-Wno-error=inline' '-Wno-error=logical-not-parentheses' '-Wno-error=strict-aliasing' '-Wno-error=uninitialized' '-Wno-error=unused-but-set
-variable' '-Wno-error=unused-function' '-Wno-error=unused-value' '-Wno-error=misleading-indentation' '-Wno-error=nonnull-compare' '-Wno-error=shift-negative-value' '-Wno-error=tautological-compare' '
-Wno-error=unused-const-variable' '-Wno-error=bool-operation' '-Wno-error=deprecated' '-Wno-error=expansion-to-defined' '-Wno-error=format-overflow' '-Wno-error=format-truncation' '-Wno-error=implicit
-fallthrough' '-Wno-error=int-in-bool-context' '-Wno-error=memset-elt-size' '-Wno-error=noexcept-type' '-Wno-error=nonnull' '-Wno-error=pointer-compare' '-Wno-error=stringop-overflow' '-Wno-error=aggr
essive-loop-optimizations' '-Wno-error=cast-function-type' '-Wno-error=catch-value' '-Wno-error=multistatement-macros' '-Wno-error=restrict' '-Wno-error=sizeof-pointer-memaccess' '-Wno-error=stringop-
truncation' '-Wno-address-of-packed-member' '-v' '-fno-exceptions' '-fno-rtti' '-std=c++11' '-o' 'ld.lld.full' '-shared-libgcc' '-mabi=elfv2'
/usr/local/libexec/gcc/powerpc64-unknown-freebsd13.0/9.2.0/collect2 -plugin /usr/local/libexec/gcc/powerpc64-unknown-freebsd13.0/9.2.0/liblto_plugin.so -plugin-opt=/usr/local/libexec/gcc/powerpc64-un
known-freebsd13.0/9.2.0/lto-wrapper -plugin-opt=-fresolution=/tmp//ccTkdsPB.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-throug
h=-lgcc_s -plugin-opt=-pass-through=-lgcc --sysroot=/usr/obj/powerpc64vtsc_xtoolchain-gcc/powerpc.powerpc64/usr/src/powerpc.powerpc64/tmp --eh-frame-hdr -V -melf64ppc_fbsd -V -dynamic-linker /libexec/
ld-elf.so.1 -o ld.lld.full /usr/obj/powerpc64vtsc_xtoolchain-gcc/powerpc.powerpc64/usr/src/powerpc.powerpc64/tmp/usr/lib/crt1.o /usr/obj/powerpc64vtsc_xtoolchain-gcc/powerpc.powerpc64/usr/src/powerpc.
powerpc64/tmp/usr/lib/crti.o /usr/obj/powerpc64vtsc_xtoolchain-gcc/powerpc.powerpc64/usr/src/powerpc.powerpc64/tmp/usr/lib/crtbegin.o -L/usr/local/powerpc64-unknown-freebsd13.0/bin -L/usr/local/lib/gc
c/powerpc64-unknown-freebsd13.0/9.2.0 -L/usr/obj/powerpc64vtsc_xtoolchain-gcc/powerpc.powerpc64/usr/src/powerpc.powerpc64/tmp/usr/lib --gc-sections Common/Args.o Common/ErrorHandler.o Common/Filesyste
m.o Common/Memory.o Common/Reproduce.o Common/Strings.o Common/TargetOptionsCommandFlags.o Common/Threads.o Common/Version.o ELF/AArch64ErrataFix.o ELF/Arch/AArch64.o ELF/Arch/AMDGPU.o ELF/Arch/ARM.o
ELF/Arch/AVR.o ELF/Arch/Hexagon.o ELF/Arch/MSP430.o ELF/Arch/Mips.o ELF/Arch/MipsArchTree.o ELF/Arch/PPC.o ELF/Arch/PPC64.o ELF/Arch/RISCV.o ELF/Arch/SPARCV9.o ELF/Arch/X86.o ELF/Arch/X86_64.o ELF/Cal
lGraphSort.o ELF/DWARF.o ELF/Driver.o ELF/DriverUtils.o ELF/EhFrame.o ELF/ICF.o ELF/InputFiles.o ELF/InputSection.o ELF/LTO.o ELF/LinkerScript.o ELF/MapFile.o ELF/MarkLive.o ELF/OutputSections.o ELF/R
elocations.o ELF/ScriptLexer.o ELF/ScriptParser.o ELF/SymbolTable.o ELF/Symbols.o ELF/SyntheticSections.o ELF/Target.o ELF/Thunks.o ELF/Writer.o lib/Core/Error.o lib/Core/File.o lib/Core/LinkingContex
t.o lib/Core/Reader.o lib/Core/Resolver.o lib/Core/SymbolTable.o tools/lld/lld.o /usr/obj/powerpc64vtsc_xtoolchain-gcc/powerpc.powerpc64/usr/src/powerpc.powerpc64/lib/clang/libllvm/libllvm.a -lexecinf
o -lncursesw -lz -lpthread -lc++ -lm -lssp_nonshared -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/obj/powerpc64vtsc_xtoolchain-gcc/powerpc.powerpc64/usr/src/powerpc.powerpc64/tmp/usr/lib/crtend.o /usr/obj/pow
erpc64vtsc_xtoolchain-gcc/powerpc.powerpc64/usr/src/powerpc.powerpc64/tmp/usr/lib/crtn.o
===
Mark Millard
marklmi at
yahoo.com
(
dsl-only.net went
away in early 2018-Mar)