<html>
<head>
<base href="https://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - FreeBSD head -r311147's clang 3.9.1 targeting powerpc handles assembler notation with omitted @toc notation differently than gcc/binutils's assembler does: R_PPC64_ADDR16_DS vs. R_PPC64_TOC16_DS"
href="https://llvm.org/bugs/show_bug.cgi?id=31574">31574</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>FreeBSD head -r311147's clang 3.9.1 targeting powerpc handles assembler notation with omitted @toc notation differently than gcc/binutils's assembler does: R_PPC64_ADDR16_DS vs. R_PPC64_TOC16_DS
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>3.9
</td>
</tr>
<tr>
<th>Hardware</th>
<td>Macintosh
</td>
</tr>
<tr>
<th>OS</th>
<td>FreeBSD
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Backend: PowerPC
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>markmi@dsl-only.net
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>[lib/Target/PowerpC is a guess on my part.]
For the same locore64.S source for FreeBSD head (and likely stable/11)
clang 3.9.1 is producing (objdump output shown):
0000000000000046 R_PPC64_ADDR16_DS .toc
but using devel/powerpc64-gcc and devel/powerpc64-bintuils
produces:
0000000000000046 R_PPC64_TOC16_DS .toc
(Actually I'm experimenting with making a
simplified code example now.)
The R_PPC64_ADDR16_DS lead to "0(r2)" in the kernel
code where the R_PPC64_TOC16_DS leads to the correct
"-32760(r2)". (There are other examples.) Thus the
kernel does not boot.
It turns out that this is based on a lack of @toc notation
in the assembler source and how that is handled in the
different toolchains.
Details. . .
For:
.section ".toc","aw"
tmpstk.L: .tc tmpstk[TC],tmpstk
. . .
/* Set up the stack pointer */
ld %r1,tmpstk.L(%r2)
using the devel/powerpc64-gcc and devel/powerpc64-binutils
ports 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
0000000000000028 R_PPC64_REL64 __tocbase+0x0000000000008000
0000000000000046 R_PPC64_TOC16_DS .toc
RELOCATION RECORDS FOR [.toc]:
OFFSET TYPE VALUE
0000000000000000 R_PPC64_ADDR64 tmpstk
RELOCATION RECORDS FOR [.opd]:
OFFSET TYPE VALUE
0000000000000000 R_PPC64_ADDR64 .__start
0000000000000008 R_PPC64_TOC *ABS*
By contrast clang 3.9.1 is silent (cross compiler used):
# /usr/obj/powerpc64vtsc_clang_kernel/powerpc.powerpc64/usr/src/tmp/usr/bin/cc
\ -target
powerpc64-unknown-freebsd12.0 \
--sysroot=/usr/obj/powerpc64vtsc_clang_kernel/powerpc.powerpc64/usr/src/tmp \
-B/usr/obj/powerpc64vtsc_clang_kernel/powerpc.powerpc64/usr/src/tmp/usr/bin \
-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
locore64_simplified.o: file format elf64-powerpc-freebsd
RELOCATION RECORDS FOR [.text]:
OFFSET TYPE VALUE
0000000000000028 R_PPC64_REL64 __tocbase+0x0000000000008000
0000000000000046 R_PPC64_ADDR16_DS .toc
RELOCATION RECORDS FOR [.toc]:
OFFSET TYPE VALUE
0000000000000000 R_PPC64_ADDR64 tmpstk
RELOCATION RECORDS FOR [.opd]:
OFFSET TYPE VALUE
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 toolchains 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
locore64_simplified.o: file format elf64-powerpc-freebsd
RELOCATION RECORDS FOR [.text]:
OFFSET TYPE VALUE
0000000000000028 R_PPC64_REL64 __tocbase+0x0000000000008000
0000000000000046 R_PPC64_TOC16_DS .toc
RELOCATION RECORDS FOR [.toc]:
OFFSET TYPE VALUE
0000000000000000 R_PPC64_ADDR64 tmpstk
RELOCATION RECORDS FOR [.opd]:
OFFSET TYPE VALUE
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=/usr/obj/powerpc64vtsc_clang_kernel/powerpc.powerpc64/usr/src/tmp \
-B/usr/obj/powerpc64vtsc_clang_kernel/powerpc.powerpc64/usr/src/tmp/usr/bin \
-c \
-x assembler-with-cpp \
-pipe \
locore64_simplified.S
# /usr/local/powerpc64-freebsd/bin/objdump -r locore64_simplified.o | more
locore64_simplified.o: file format elf64-powerpc-freebsd
RELOCATION RECORDS FOR [.text]:
OFFSET TYPE VALUE
0000000000000028 R_PPC64_REL64 __tocbase+0x0000000000008000
0000000000000046 R_PPC64_TOC16_DS .toc
RELOCATION RECORDS FOR [.toc]:
OFFSET TYPE VALUE
0000000000000000 R_PPC64_ADDR64 tmpstk
RELOCATION RECORDS FOR [.opd]:
OFFSET TYPE VALUE
0000000000000000 R_PPC64_ADDR64 .__start
0000000000000008 R_PPC64_TOC *ABS*</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>