/usr/bin/ld.lld on powerpc64: produces a.out for which: ld-elf.so.1: assert failed: /usr/src/libexec/rtld-elf/powerpc64/reloc.c:374

Mark Millard markmi at dsl-only.net
Wed Jan 11 09:15:42 UTC 2017


[Note that the /usr/bin/ld.lld here was built via buildworld
on the powerpc64 machine: native build, not a cross build.]

Roman Divacky had suggested:

From: Roman Divacky <rdivacky at vlakno.cz>
Date: January 8, 2017 at 6:41:33 AM PST

> Would you be interested in trying lld? It has some support for ppc/ppc64, which
> is probably quite incomplete but it would be nice to know what exactly is
> missing.


Here it goes for using lld to link a trivial program on a powerpc64
machine targeting a powerpc64 machine. . .

# uname -apKU
FreeBSD FBSDG5L 12.0-CURRENT FreeBSD 12.0-CURRENT #0 r311147M: Tue Jan 10 19:58:19 PST 2017     root at FBSDG5L:/usr/obj/powerpc64vtsc_clang_altbinutils_kernel/powerpc.powerpc64/usr/src/sys/GENERIC64vtsc-NODBG  powerpc powerpc64 1200019 1200019

(System built using WITH_LLD= but WITHOUT_LLD_AS_LD= )
(System built using devel/powerpc64-binutils , not the
bootstrap system binutils. Could have been devel/binutils
since it was on powerpc64 for the build.)
(The system ld fails for as.full linking during buildworld.)

# more main.c
int main ()
{
    return 0;
}

# clang -v -fuse-ld=lld main.c
FreeBSD clang version 3.9.1 (tags/RELEASE_391/final 289601) (based on LLVM 3.9.1)
Target: powerpc64-unknown-freebsd12.0
Thread model: posix
InstalledDir: /usr/bin
 "/usr/bin/clang" -cc1 -triple powerpc64-unknown-freebsd12.0 -emit-obj -mrelax-all -disable-free -main-file-name main.c -mrelocation-model static -mthread-model posix -mdisable-fp-elim -masm-verbose -mconstructor-aliases -target-cpu ppc64 -mfloat-abi hard -v -v -v -dwarf-column-info -debugger-tuning=gdb -resource-dir /usr/bin/../lib/clang/3.9.1 -fdebug-compilation-dir /root/c_tests -ferror-limit 19 -fmessage-length 200 -fno-signed-char -fobjc-runtime=gnustep -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/main-0d483e.o -x c main.c
clang -cc1 version 3.9.1 based upon LLVM 3.9.1 default target powerpc64-unknown-freebsd12.0
#include "..." search starts here:
#include <...> search starts here:
 /usr/bin/../lib/clang/3.9.1/include
 /usr/include
End of search list.
 "/usr/bin/ld.lld" --eh-frame-hdr -dynamic-linker /libexec/ld-elf.so.1 --enable-new-dtags -o a.out /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtbegin.o -L/usr/lib /tmp/main-0d483e.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/crtend.o /usr/lib/crtn.o

# ./a.out
ld-elf.so.1: assert failed: /usr/src/libexec/rtld-elf/powerpc64/reloc.c:374
Abort trap (core dumped)

It stopped at the assert in:

int
reloc_plt(Obj_Entry *obj)
{
        const Elf_Rela *relalim;
        const Elf_Rela *rela;

        if (obj->pltrelasize != 0) {
                relalim = (const Elf_Rela *)((char *)obj->pltrela +
                    obj->pltrelasize);
                for (rela = obj->pltrela;  rela < relalim;  rela++) {
                        assert(ELF_R_TYPE(rela->r_info) == R_PPC_JMP_SLOT);
        
                        if (reloc_plt_object(obj, rela) < 0) {
                                return (-1);
                        }
                }
        }

        return (0);
}


By contrast:

# clang -v main.c
FreeBSD clang version 3.9.1 (tags/RELEASE_391/final 289601) (based on LLVM 3.9.1)
Target: powerpc64-unknown-freebsd12.0
Thread model: posix
InstalledDir: /usr/bin
 "/usr/bin/clang" -cc1 -triple powerpc64-unknown-freebsd12.0 -emit-obj -mrelax-all -disable-free -main-file-name main.c -mrelocation-model static -mthread-model posix -mdisable-fp-elim -masm-verbose -mconstructor-aliases -target-cpu ppc64 -mfloat-abi hard -v -dwarf-column-info -debugger-tuning=gdb -resource-dir /usr/bin/../lib/clang/3.9.1 -fdebug-compilation-dir /root/c_tests -ferror-limit 19 -fmessage-length 200 -fno-signed-char -fobjc-runtime=gnustep -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/main-895416.o -x c main.c
clang -cc1 version 3.9.1 based upon LLVM 3.9.1 default target powerpc64-unknown-freebsd12.0
#include "..." search starts here:
#include <...> search starts here:
 /usr/bin/../lib/clang/3.9.1/include
 /usr/include
End of search list.
 "/usr/bin/ld" --eh-frame-hdr -dynamic-linker /libexec/ld-elf.so.1 --enable-new-dtags -o a.out /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtbegin.o -L/usr/lib /tmp/main-895416.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/crtend.o /usr/lib/crtn.o

# ./a.out

(No failure.)


From what I've seen on the lists it appears that powerpc64's lld
effort may well have not even started yet so getting even this
far might be good news.

I'm not sure it is considered far enough along to classify this
as an error yet: it may be as expected.

As for the ordering: tier-1 and near tier-1 that is modern (armv6,
possibly arm64?) likely comes before tier-2. I've no clue for
mips family vs. powerpc family.

===
Mark Millard
markmi at dsl-only.net



More information about the freebsd-ppc mailing list