public inbox for glibc-bugs@sourceware.org help / color / mirror / Atom feed
From: "mikpe at it dot uu.se" <sourceware-bugzilla@sourceware.org> To: glibc-bugs@sourceware.org Subject: [Bug dynamic-link/15128] New: dynamic loader may clobber floating-point parameters on AArch64 Date: Sat, 09 Feb 2013 17:03:00 -0000 [thread overview] Message-ID: <bug-15128-131@http.sourceware.org/bugzilla/> (raw) http://sourceware.org/bugzilla/show_bug.cgi?id=15128 Bug #: 15128 Summary: dynamic loader may clobber floating-point parameters on AArch64 Product: glibc Version: 2.17 Status: NEW Severity: normal Priority: P2 Component: dynamic-link AssignedTo: unassigned@sourceware.org ReportedBy: mikpe@it.uu.se Classification: Unclassified If glibc-2.17 is compiled for aarch64 with -O3 in CFLAGS, then gcc (from aarch64-4.7-branch of GCC svn) will convert some memory stores in the dynamic loader to use vector registers and vector instructions. Vector registers alias the FP registers. The code path into the dynamic loader does not preserve the application's FP registers, so those vector instructions may clobber FP arguments in the call being resolved. As the following test case shows, at least printf and log10 are broken by this: genericarmv8_195_cat aarch64-fp-bug.c #include <errno.h> #include <math.h> #include <stdio.h> double x = 100.0; int main(void) { double y; errno = 0; y = log10(x); printf("log10(%f) = %f, errno = %d\n", x, y, errno); return 0; } genericarmv8_196_gcc -O aarch64-fp-bug.c -lm ; ./a.out log10(0.000000) = -inf, errno = 34 genericarmv8_197_gcc -static -O aarch64-fp-bug.c -lm ; ./a.out log10(100.000000) = 2.000000, errno = 0 When debugging the test case I found that the FP argument to log10 was clobbered by a fragment like the following in _dl_lookup_symbol_x: 1094: 910303b8 add x24, x29, #0xc0 ... 10a0: 4f000400 movi v0.4s, #0x0 10a4: f90073a2 str x2, [x29,#224] 10a8: 4c007f00 st1 {v0.2d}, [x24] When compiled at -O2 or with -mgeneral-regs-only that code is 10a4: f9006fa2 str x2, [x29,#216] 10a8: f90063bf str xzr, [x29,#192] 10ac: f90067bf str xzr, [x29,#200] Further inspection of the object files in the elf directory showed v0 being clobbered in six of them (dl-addr, dl-libc, dl-load, dl-lookup, dl-reloc, and rtld), and also in the memset that gets linked in there. Compiling glibc with -O2 appears to avoid the problem, but it's a blunt and possibly incomplete solution. -mgeneral-regs-only is guaranteed to avoid the problem, but that also prevents FP code, so it can't be used for all of glibc. My current solution is to add -mgeneral-regs-only to the seven files listed above via CFLAGS overrides in the aarch64-specific Makefile. Doing that runs into BZ 15005 however, so the fix for that is also needed. I don't have a copyright assignment, but the patch is small: elf/Makefile | 4 ++-- ports/sysdeps/aarch64/Makefile | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) Does this sound Ok? Is there a better way to fix this issue? -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
next reply other threads:[~2013-02-09 17:03 UTC|newest] Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top 2013-02-09 17:03 mikpe at it dot uu.se [this message] 2013-02-09 17:04 ` [Bug dynamic-link/15128] " mikpe at it dot uu.se 2013-02-11 5:00 ` bugdal at aerifal dot cx 2013-02-11 7:21 ` Ondřej Bílka 2013-02-11 7:21 ` neleai at seznam dot cz 2013-02-11 9:09 ` mikpe at it dot uu.se 2013-02-11 13:36 ` bugdal at aerifal dot cx 2013-02-11 15:13 ` mikpe at it dot uu.se 2013-02-11 21:38 ` bugdal at aerifal dot cx 2013-02-13 9:32 ` mikpe at it dot uu.se 2013-02-20 18:12 ` carlos at redhat dot com 2013-02-24 18:11 ` amonakov at gmail dot com 2013-02-24 18:13 ` amonakov at gmail dot com 2013-02-25 8:06 ` aj at suse dot de 2013-05-21 12:59 ` marcus.shawcroft at linaro dot org 2013-10-02 22:15 ` neleai at seznam dot cz 2013-12-18 12:08 ` cvs-commit at gcc dot gnu.org 2013-12-19 14:04 ` cvs-commit at gcc dot gnu.org 2013-12-19 14:10 ` marcus.shawcroft at linaro dot org 2014-06-13 18:52 ` fweimer at redhat dot com 2015-07-31 12:33 ` cvs-commit at gcc dot gnu.org 2015-08-01 15:55 ` cvs-commit at gcc dot gnu.org 2015-08-01 22:23 ` cvs-commit at gcc dot gnu.org 2015-08-01 22:25 ` cvs-commit at gcc dot gnu.org 2015-08-02 3:55 ` cvs-commit at gcc dot gnu.org 2015-08-02 12:33 ` cvs-commit at gcc dot gnu.org 2015-08-02 13:57 ` cvs-commit at gcc dot gnu.org 2015-08-02 17:41 ` cvs-commit at gcc dot gnu.org 2015-08-02 17:43 ` cvs-commit at gcc dot gnu.org 2015-08-03 4:47 ` cvs-commit at gcc dot gnu.org 2015-08-03 4:50 ` cvs-commit at gcc dot gnu.org 2015-08-03 17:21 ` cvs-commit at gcc dot gnu.org 2015-08-03 19:32 ` cvs-commit at gcc dot gnu.org 2015-08-03 21:25 ` cvs-commit at gcc dot gnu.org 2015-08-03 21:36 ` cvs-commit at gcc dot gnu.org 2015-08-05 14:34 ` cvs-commit at gcc dot gnu.org 2015-08-05 14:35 ` cvs-commit at gcc dot gnu.org 2015-08-07 22:45 ` jsweval at arxan dot com 2015-08-19 12:19 ` cvs-commit at gcc dot gnu.org 2015-08-24 13:19 ` cvs-commit at gcc dot gnu.org 2015-08-25 11:31 ` cvs-commit at gcc dot gnu.org 2015-08-25 11:53 ` cvs-commit at gcc dot gnu.org 2023-12-08 9:28 ` liqingqing3 at huawei dot com 2023-12-08 10:37 ` fweimer at redhat dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-15128-131@http.sourceware.org/bugzilla/ \ --to=sourceware-bugzilla@sourceware.org \ --cc=glibc-bugs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).