[llvm-bugs] [Bug 31574] 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
via llvm-bugs
llvm-bugs at lists.llvm.org
Sat Jan 7 14:28:21 PST 2017
https://llvm.org/bugs/show_bug.cgi?id=31574
Bug ID: 31574
Summary: 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
Product: libraries
Version: 3.9
Hardware: Macintosh
OS: FreeBSD
Status: NEW
Severity: normal
Priority: P
Component: Backend: PowerPC
Assignee: unassignedbugs at nondot.org
Reporter: markmi at dsl-only.net
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
[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 at 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*
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170107/13ce803a/attachment.html>
More information about the llvm-bugs
mailing list