From: Nick Clifton <nickc@redhat.com>
To: Jakub Jelinek <jakub@redhat.com>, Jeff Law <law@redhat.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: RFA: PR 68913: Provide weak version of __fread_chk for PR61886 test
Date: Fri, 08 Jan 2016 12:01:00 -0000 [thread overview]
Message-ID: <568FA50C.9070601@redhat.com> (raw)
In-Reply-To: <20160107174159.GH18720@tucnak.redhat.com>
Hi Guys,
OK - how about this reformulation of the pr61886 test ?
The patch changes references to __fread_chk with references to just
fread, which I assume will be present in all target runtime libraries.
I had to add some preprocessor trickery in order to ensure that
__USER_LABEL_PREFIX__ is correctly prepended to the assembler name of
the functions, but other than that the test remains the same. No linker
funny business this time.
I have tested this patch with an x86_64 native (whose C runtime does
include __fread_chk), an ARM cross compiler (using newlib, which does
not provide __fread_chk) and with a V850 cross compiler (which uses
newlib and which also defines __USER_LABEL_PREFIX to "_"). Prior to
Honza's r231548 patch all three toolchains fail this patched test.
Using today#s latest and greatest mainline gcc sources, all three
toolchains pass the patched test.
OK to apply ?
Cheers
Nick
gcc/testsuite/ChangeLog
2016-01-08 Nick Clifton <nickc@redhat.com>
PR target/68913
* gcc.dg/lto/pr61886_0.c: Rename the external function called
to fread so that it will be found in all target runtimes.
Index: gcc/testsuite/gcc.dg/lto/pr61886_0.c
===================================================================
--- gcc/testsuite/gcc.dg/lto/pr61886_0.c (revision 232157)
+++ gcc/testsuite/gcc.dg/lto/pr61886_0.c (working copy)
@@ -4,12 +4,15 @@
typedef __SIZE_TYPE__ size_t;
typedef struct _IO_FILE FILE;
-extern size_t __fread_chk (void *__restrict __ptr, size_t __ptrlen,
size_t __size, size_t __n, FILE *__restrict __stream) __asm__ (""
"__fread_chk") __attribute__ ((__warn_unused_result__));
-extern size_t __fread_chk_warn (void *__restrict __ptr, size_t
__ptrlen, size_t __size, size_t __n, FILE *__restrict __stream) __asm__
("" "__fread_chk") __attribute__ ((__warn_unused_result__))
__attribute__((__warning__ ("fread called with bigger size * nmemb than
length " "of destination buffer")));
+#define STRING1(a) #a
+#define STRING2(a) STRING1(a)
+extern size_t fread (void *__restrict __ptr, size_t __ptrlen, size_t
__size, size_t __n, FILE *__restrict __stream) __asm__
(STRING2(__USER_LABEL_PREFIX__) "fread") __attribute__
((__warn_unused_result__));
+extern size_t fread_warn (void *__restrict __ptr, size_t __ptrlen,
size_t __size, size_t __n, FILE *__restrict __stream) __asm__
(STRING2(__USER_LABEL_PREFIX__) "fread") __attribute__
((__warn_unused_result__)) __attribute__((__warning__ ("fread called
with bigger size * nmemb than length " "of destination buffer")));
+
extern __inline __attribute__ ((__always_inline__)) __attribute__
((__gnu_inline__)) __attribute__ ((__artificial__)) __attribute__
((__warn_unused_result__))
size_t
-fread (void *__restrict __ptr, size_t __size, size_t __n,
+local_fread (void *__restrict __ptr, size_t __size, size_t __n,
FILE *__restrict __stream)
{
if (__builtin_object_size (__ptr, 0) != (size_t) -1)
@@ -17,9 +20,9 @@
if (!__builtin_constant_p (__size)
|| !__builtin_constant_p (__n)
|| (__size | __n) >= (((size_t) 1) << (8 * sizeof (size_t) /
2)))
- return __fread_chk (__ptr, __builtin_object_size (__ptr, 0),
__size, __n, __stream);
+ return fread (__ptr, __builtin_object_size (__ptr, 0), __size,
__n, __stream);
if (__size * __n > __builtin_object_size (__ptr, 0))
- return __fread_chk_warn (__ptr, __builtin_object_size (__ptr,
0), __size, __n, __stream);
+ return fread_warn (__ptr, __builtin_object_size (__ptr, 0),
__size, __n, __stream);
}
}
@@ -28,6 +31,6 @@
int main ()
{
char file_contents[4096];
- /* We shouldn't get this resolved to a call to __fread_chk_warn. */
- return fread (file_contents, 1, nmemb, fp);
+ /* We shouldn't get this resolved to a call to fread_warn. */
+ return local_fread (file_contents, 1, nmemb, fp);
}
next prev parent reply other threads:[~2016-01-08 12:01 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-18 17:07 Nick Clifton
2015-12-21 19:59 ` Jeff Law
2015-12-22 9:54 ` Nick Clifton
2016-01-05 19:20 ` Jeff Law
2016-01-07 13:37 ` Nick Clifton
2016-01-07 13:45 ` Rainer Orth
2016-01-07 14:06 ` Nick Clifton
2016-01-07 14:15 ` Rainer Orth
2016-01-07 16:00 ` Jeff Law
2016-01-07 16:47 ` Andreas Schwab
2016-01-07 17:31 ` Nick Clifton
2016-01-07 17:42 ` Jakub Jelinek
2016-01-07 21:04 ` Nick Clifton
2016-01-08 12:01 ` Nick Clifton [this message]
2016-01-09 0:10 ` Jeff Law
2016-01-08 23:27 ` Jeff Law
2016-01-07 13:42 Dominique d'Humières
2016-01-07 14:00 ` Nick Clifton
2016-01-07 14:05 ` Dominique d'Humières
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=568FA50C.9070601@redhat.com \
--to=nickc@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
--cc=law@redhat.com \
/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: link
Be 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).