Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 07 Jan 2017 23:04:05 +0000
From:      bugzilla-noreply@freebsd.org
To:        freebsd-toolchain@FreeBSD.org
Subject:   [Bug 215819] head r311147's clang 3.9.1 for powerpc64: locore.o generation messed up: generates R_PPC64_ADDR16_DS instead of R_PPC64_TOC16_DS with .toc
Message-ID:  <bug-215819-29464-yMiqs9Cl8v@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-215819-29464@https.bugs.freebsd.org/bugzilla/>
References:  <bug-215819-29464@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D215819

--- Comment #3 from Mark Millard <markmi@dsl-only.net> ---
(In reply to Mark Millard from comment #0)

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 \=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
                                              -c \=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20
            -x assembler-with-cpp \=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20
                                                          -pipe  \=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20
              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 \=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20
--sysroot=3D/usr/obj/powerpc64vtsc_clang_kernel/powerpc.powerpc64/usr/src/t=
mp \=20=20
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
-B/usr/obj/powerpc64vtsc_clang_kernel/powerpc.powerpc64/usr/src/tmp/usr/bin=
 \=20=20=20
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20
              -c \                            -x assembler-with-cpp \=20=20=
=20=20=20=20=20=20=20=20
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20
            -pipe  \=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
                                                          locore64_simplifi=
ed.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=20=20=20=20=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 \=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
                                              -c \=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20
            -x assembler-with-cpp \=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20
                                                          -pipe  \=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20
              locore64_simplified.S

# /usr/local/powerpc64-freebsd/bin/objdump -r locore64_simplified.o | more=
=20=20=20=20=20=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 \=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20
--sysroot=3D/usr/obj/powerpc64vtsc_clang_kernel/powerpc.powerpc64/usr/src/t=
mp \=20=20
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
-B/usr/obj/powerpc64vtsc_clang_kernel/powerpc.powerpc64/usr/src/tmp/usr/bin=
 \=20=20=20
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20
              -c \                            -x assembler-with-cpp \=20=20=
=20=20=20=20=20=20=20=20
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20
            -pipe  \=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
                                                          locore64_simplifi=
ed.S

# /usr/local/powerpc64-freebsd/bin/objdump -r locore64_simplified.o | more=
=20=20=20=20=20=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.


The following should be a list of the places that adding @toc usage
would fix things:

# grep "@toc[^b]"
/root/sys_typescripts/typescript_make_powerpc64vtsc_nodebug_incl_clang_xtoo=
lchain_kernel-amd64-host-2017-01-03:23:48:41
| more
/usr/src/sys/powerpc/aim/locore64.S:102: Warning: assuming @toc on symbol
/usr/src/sys/powerpc/aim/trap_subr64.S:320: Warning: assuming @toc on symbol
/usr/src/sys/powerpc/aim/trap_subr64.S:797: Warning: assuming @toc on symbol
/usr/src/sys/powerpc/ofw/ofwcall64.S:104: Warning: assuming @toc on symbol
/usr/src/sys/powerpc/ofw/ofwcall64.S:108: Warning: assuming @toc on symbol
/usr/src/sys/powerpc/ofw/ofwcall64.S:116: Warning: assuming @toc on symbol
/usr/src/sys/powerpc/ofw/ofwcall64.S:226: Warning: assuming @toc on symbol
/usr/src/sys/powerpc/ofw/ofwcall64.S:228: Warning: assuming @toc on symbol
/usr/src/sys/powerpc/ofw/ofwcall64.S:235: Warning: assuming @toc on symbol
/usr/src/sys/powerpc/powerpc/swtch64.S:153: Warning: assuming @toc on symbol

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-215819-29464-yMiqs9Cl8v>