Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 7 Jan 2017 14:07:33 -0800
From:      Mark Millard <markmi@dsl-only.net>
To:        Roman Divacky <rdivacky@vlakno.cz>, Ed Maste <emaste@freebsd.org>
Cc:        Justin Hibbits <chmeeedalf@gmail.com>, Nathan Whitehorn <nwhitehorn@freebsd.org>, FreeBSD Toolchain <freebsd-toolchain@freebsd.org>, FreeBSD PowerPC ML <freebsd-ppc@freebsd.org>
Subject:   Re: clang 3.9.0 buildkernel on old powerpc64's vs. trying to build hwpmc_e500.o and the like. . . [Actually .__start code failure vs. working and R_PPC64_ADDR16_DS vs. R_PPC64_TOC16_DS]
Message-ID:  <2B5FDD60-4D8B-4803-B59C-3C569BA36E68@dsl-only.net>
In-Reply-To: <20170107085126.GA82107@vlakno.cz>
References:  <D3DE2D12-9885-4154-B680-6DA5A8B62A56@dsl-only.net> <D9C54972-8D21-4D55-A707-4FFC2BDCD9FE@dsl-only.net> <20161207190057.GA58950@vlakno.cz> <E1376C20-C1BD-418D-81C6-CDDE479342CA@dsl-only.net> <CE88C1F4-B9BD-4D45-8DF0-F1079C3257A5@dsl-only.net> <20161208185541.GA33364@vlakno.cz> <E49F7EE4-7A62-4601-98DC-4C4791B7158D@dsl-only.net> <20161208221452.GA42380@vlakno.cz> <20161212210922.GA27403@vlakno.cz> <613BB28B-46F1-4959-B576-C8AD42A21200@dsl-only.net> <20170107085126.GA82107@vlakno.cz>

next in thread | previous in thread | raw e-mail | index | archive | help
On 2017-Jan-7, at 12:51 AM, Roman Divacky <rdivacky at vlakno.cz> wrote:

> That's a great progress. Can you produce minimal self contained test =
case that
> exhibits this bug? And submit it to llvm bugzilla?
>=20
> Also, clang3.9 defaults to using it's own internal asm, what happens =
if you
> add -no-integrated-as to CFLAGS and recompile the kernel? That should =
remove
> this llvm assembly problem. Does it boot?
>=20
> Thanks Mark, really great progress.
>=20
> Roman

In attempting this I found how to control the behavior based on
the assembler notation @toc being missing vs. being present.

If llvm should change is strongly tied to llvm's criteria for
gcc compatibility relative to filling-in/defaulting omitted
@toc's in the assembler notation.

FreeBSD has the option of always being explicit with @toc in order
to avoid differences in handling of omitted notation.

So I've no clue if FreebSD wants to claim that a llvm change
is a requirement for using clang as the powerpc64 system compiler.

[The issue of the distinction is submittable to llvm either way.]

Details. . .

For:

        .section ".toc","aw"
tmpstk.L: .tc tmpstk[TC],tmpstk
. . .
        /* Set up the stack pointer */
        ld      %r1,tmpstk.L(%r2)

using devel/powerpc64-gcc gets:

# /usr/local/bin/powerpc64-unknown-freebsd12.0-gcc \                     =
                                                                         =
                                                                         =
                                                      -c \               =
                                                                         =
                                                                         =
                                                                         =
                                   -x assembler-with-cpp \               =
                                                                         =
                                                                         =
                                                                         =
                -pipe  \                                                 =
                                                                         =
                                                                         =
                                                                      =
locore64_simplified.S
locore64_simplified.S: Assembler messages:
locore64_simplified.S:80: Warning: assuming @toc on symbol

and produces (with R_PPC64_TOC16_DS for .toc):

# /usr/local/powerpc64-freebsd/bin/objdump -r locore64_simplified.o

locore64_simplified.o:     file format elf64-powerpc-freebsd

RELOCATION RECORDS FOR [.text]:
OFFSET           TYPE              VALUE=20
0000000000000028 R_PPC64_REL64     __tocbase+0x0000000000008000
0000000000000046 R_PPC64_TOC16_DS  .toc


RELOCATION RECORDS FOR [.toc]:
OFFSET           TYPE              VALUE=20
0000000000000000 R_PPC64_ADDR64    tmpstk


RELOCATION RECORDS FOR [.opd]:
OFFSET           TYPE              VALUE=20
0000000000000000 R_PPC64_ADDR64    .__start
0000000000000008 R_PPC64_TOC       *ABS*


By contrast clang is silent (cross compiler used):

# =
/usr/obj/powerpc64vtsc_clang_kernel/powerpc.powerpc64/usr/src/tmp/usr/bin/=
cc \                                                                     =
                                                                         =
                                                   -target =
powerpc64-unknown-freebsd12.0 \                                          =
                                                                         =
                                                                         =
                                              =
--sysroot=3D/usr/obj/powerpc64vtsc_clang_kernel/powerpc.powerpc64/usr/src/=
tmp \                                                                    =
                                                                         =
                                                       =
-B/usr/obj/powerpc64vtsc_clang_kernel/powerpc.powerpc64/usr/src/tmp/usr/bi=
n \                                                                      =
                                                                         =
                                                     -c \                =
                                                                         =
                                                                         =
                                                                         =
                                  -x assembler-with-cpp \                =
                                                                         =
                                                                         =
                                                                         =
               -pipe  \                                                  =
                                                                         =
                                                                         =
                                                                     =
locore64_simplified.S

and produces code with R_PPC64_ADDR16_DS for the .toc instead:

# /usr/local/powerpc64-freebsd/bin/objdump -r locore64_simplified.o | =
more                                                                     =
                                                                         =
                                                        =20
locore64_simplified.o:     file format elf64-powerpc-freebsd

RELOCATION RECORDS FOR [.text]:
OFFSET           TYPE              VALUE=20
0000000000000028 R_PPC64_REL64     __tocbase+0x0000000000008000
0000000000000046 R_PPC64_ADDR16_DS  .toc


RELOCATION RECORDS FOR [.toc]:
OFFSET           TYPE              VALUE=20
0000000000000000 R_PPC64_ADDR64    tmpstk


RELOCATION RECORDS FOR [.opd]:
OFFSET           TYPE              VALUE=20
0000000000000000 R_PPC64_ADDR64    .__start
0000000000000008 R_PPC64_TOC       *ABS*



But for:

        .section ".toc","aw"
tmpstk.L: .tc tmpstk[TC],tmpstk
. . .
        /* Set up the stack pointer */
        ld      %r1,tmpstk.L@toc(%r2)

(note the @toc notation) both compilers agree and use
R_PPC64_TOC16_DS for the .toc:

# /usr/local/bin/powerpc64-unknown-freebsd12.0-gcc \                     =
                                                                         =
                                                                         =
                                                      -c \               =
                                                                         =
                                                                         =
                                                                         =
                                   -x assembler-with-cpp \               =
                                                                         =
                                                                         =
                                                                         =
                -pipe  \                                                 =
                                                                         =
                                                                         =
                                                                      =
locore64_simplified.S

# /usr/local/powerpc64-freebsd/bin/objdump -r locore64_simplified.o | =
more                                                                     =
                                                                         =
                                                        =20
locore64_simplified.o:     file format elf64-powerpc-freebsd

RELOCATION RECORDS FOR [.text]:
OFFSET           TYPE              VALUE=20
0000000000000028 R_PPC64_REL64     __tocbase+0x0000000000008000
0000000000000046 R_PPC64_TOC16_DS  .toc


RELOCATION RECORDS FOR [.toc]:
OFFSET           TYPE              VALUE=20
0000000000000000 R_PPC64_ADDR64    tmpstk


RELOCATION RECORDS FOR [.opd]:
OFFSET           TYPE              VALUE=20
0000000000000000 R_PPC64_ADDR64    .__start
0000000000000008 R_PPC64_TOC       *ABS*


# =
/usr/obj/powerpc64vtsc_clang_kernel/powerpc.powerpc64/usr/src/tmp/usr/bin/=
cc \                                                                     =
                                                                         =
                                                   -target =
powerpc64-unknown-freebsd12.0 \                                          =
                                                                         =
                                                                         =
                                              =
--sysroot=3D/usr/obj/powerpc64vtsc_clang_kernel/powerpc.powerpc64/usr/src/=
tmp \                                                                    =
                                                                         =
                                                       =
-B/usr/obj/powerpc64vtsc_clang_kernel/powerpc.powerpc64/usr/src/tmp/usr/bi=
n \                                                                      =
                                                                         =
                                                     -c \                =
                                                                         =
                                                                         =
                                                                         =
                                  -x assembler-with-cpp \                =
                                                                         =
                                                                         =
                                                                         =
               -pipe  \                                                  =
                                                                         =
                                                                         =
                                                                     =
locore64_simplified.S

# /usr/local/powerpc64-freebsd/bin/objdump -r locore64_simplified.o | =
more                                                                     =
                                                                         =
                                                        =20
locore64_simplified.o:     file format elf64-powerpc-freebsd

RELOCATION RECORDS FOR [.text]:
OFFSET           TYPE              VALUE=20
0000000000000028 R_PPC64_REL64     __tocbase+0x0000000000008000
0000000000000046 R_PPC64_TOC16_DS  .toc


RELOCATION RECORDS FOR [.toc]:
OFFSET           TYPE              VALUE=20
0000000000000000 R_PPC64_ADDR64    tmpstk


RELOCATION RECORDS FOR [.opd]:
OFFSET           TYPE              VALUE=20
0000000000000000 R_PPC64_ADDR64    .__start
0000000000000008 R_PPC64_TOC       *ABS*



I omitted "-f -gdwarf-2" to simplify things but with such
clang complains about:

locore64_simplified.S:36:2: warning: DWARF2 only supports one section =
per compilation unit
 .section ".toc","aw"
 ^
locore64_simplified.S:47:2: warning: DWARF2 only supports one section =
per compilation unit
 .section ".opd","aw"
 ^

(buildkernel gets such messages.)


I expect I can simplify the .S code more than I have so far but
I figured I'd report the discovery of the choice FreeBSD needs
to make for powerpc64 for if llvm changes are to be required
vs. not.

=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?2B5FDD60-4D8B-4803-B59C-3C569BA36E68>