Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 11 Jan 2017 01:15:38 -0800
From:      Mark Millard <markmi@dsl-only.net>
To:        Roman Divacky <rdivacky@vlakno.cz>
Cc:        FreeBSD PowerPC ML <freebsd-ppc@freebsd.org>, FreeBSD Toolchain <freebsd-toolchain@freebsd.org>
Subject:   /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
Message-ID:  <7139F615-8F18-4EDC-9051-5FFEC0C4057F@dsl-only.net>

next in thread | raw e-mail | index | archive | help
[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@FBSDG5L:/usr/obj/powerpc64vtsc_clang_altbinutils_kernel/powerpc.power=
pc64/usr/src/sys/GENERIC64vtsc-NODBG  powerpc powerpc64 1200019 1200019

(System built using WITH_LLD=3D but WITHOUT_LLD_AS_LD=3D )
(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=3Dlld 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=3Dgdb -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=3Dgnustep -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 !=3D 0) {
                relalim =3D (const Elf_Rela *)((char *)obj->pltrela +
                    obj->pltrelasize);
                for (rela =3D obj->pltrela;  rela < relalim;  rela++) {
                        assert(ELF_R_TYPE(rela->r_info) =3D=3D =
R_PPC_JMP_SLOT);
       =20
                        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=3Dgdb -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=3Dgnustep -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.)


=46rom 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.

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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?7139F615-8F18-4EDC-9051-5FFEC0C4057F>