* [PATCH] Hide internal printf functions [BZ #18822/21986]
@ 2017-08-21 22:04 H.J. Lu
2017-08-22 6:33 ` Andreas Schwab
0 siblings, 1 reply; 4+ messages in thread
From: H.J. Lu @ 2017-08-21 22:04 UTC (permalink / raw)
To: GNU C Library
Hide internal printf functions to allow direct access within libc.so and
libc.a without using GOT nor PLT.
Since __guess_grouping has been changed to take 2 arguments by
commit a1d84548c8aa7023cd039c85f81b831eef6d4a4c
Author: Ulrich Drepper <drepper@redhat.com>
Date: Fri Feb 11 18:50:36 2000 +0000
the third argument passed to __guess_grouping is removed.
OK for master?
H.J.
---
[BZ #18822]
[BZ #21986]
* include/printf.h (__printf_fphex): Add attribute_hidden.
(__guess_grouping): Likewise.
* stdio-common/printf_fp.c (__guess_grouping): Moved to ...
* stdio-common/printf.h (__guess_grouping): Here. New.
* stdio-common/reg-printf.c (__register_printf_specifier): Add
libc_hidden_proto and libc_hidden_def.
* stdlib/strfmon_l.c (__guess_grouping): Removed.
(__vstrfmon_l): Remove the third argument passed to
__guess_grouping.
---
include/printf.h | 4 +++-
stdio-common/printf.h | 3 +++
stdio-common/printf_fp.c | 2 --
stdio-common/reg-printf.c | 2 ++
stdlib/strfmon_l.c | 9 +--------
5 files changed, 9 insertions(+), 11 deletions(-)
diff --git a/include/printf.h b/include/printf.h
index 7b4d209c47..43695a480d 100644
--- a/include/printf.h
+++ b/include/printf.h
@@ -8,7 +8,7 @@
/* Now define the internal interfaces. */
extern int __printf_fphex (FILE *, const struct printf_info *,
- const void *const *);
+ const void *const *) attribute_hidden;
extern int __printf_fp (FILE *, const struct printf_info *,
const void *const *);
libc_hidden_proto (__printf_fp)
@@ -16,5 +16,7 @@ extern int __printf_fp_l (FILE *, locale_t, const struct printf_info *,
const void *const *);
libc_hidden_proto (__printf_fp_l)
+extern __typeof (__guess_grouping) __guess_grouping attribute_hidden;
+
# endif /* !_ISOMAC */
#endif
diff --git a/stdio-common/printf.h b/stdio-common/printf.h
index 940256445e..155dfdc7d3 100644
--- a/stdio-common/printf.h
+++ b/stdio-common/printf.h
@@ -182,6 +182,9 @@ extern int printf_size_info (const struct printf_info *__restrict
__info, size_t __n, int *__restrict __argtypes)
__THROW;
+extern unsigned int __guess_grouping (unsigned int intdig_max,
+ const char *grouping);
+
#ifdef __LDBL_COMPAT
# include <bits/printf-ldbl.h>
#endif
diff --git a/stdio-common/printf_fp.c b/stdio-common/printf_fp.c
index 3ed4037ba5..2633a02cc5 100644
--- a/stdio-common/printf_fp.c
+++ b/stdio-common/printf_fp.c
@@ -139,8 +139,6 @@ extern mp_size_t __mpn_extract_double (mp_ptr res_ptr, mp_size_t size,
extern mp_size_t __mpn_extract_long_double (mp_ptr res_ptr, mp_size_t size,
int *expt, int *is_neg,
long double value);
-extern unsigned int __guess_grouping (unsigned int intdig_max,
- const char *grouping);
static wchar_t *group_number (wchar_t *buf, wchar_t *bufend,
diff --git a/stdio-common/reg-printf.c b/stdio-common/reg-printf.c
index cbb9307795..fed5a16a7b 100644
--- a/stdio-common/reg-printf.c
+++ b/stdio-common/reg-printf.c
@@ -32,6 +32,7 @@ __libc_lock_define_initialized (static, lock)
int __register_printf_specifier (int, printf_function,
printf_arginfo_size_function);
+libc_hidden_proto (__register_printf_specifier)
int __register_printf_function (int, printf_function,
printf_arginfo_function);
@@ -72,6 +73,7 @@ __register_printf_specifier (int spec, printf_function converter,
return result;
}
+libc_hidden_def (__register_printf_specifier)
weak_alias (__register_printf_specifier, register_printf_specifier)
diff --git a/stdlib/strfmon_l.c b/stdlib/strfmon_l.c
index 98554dfe80..1df184e8b2 100644
--- a/stdlib/strfmon_l.c
+++ b/stdlib/strfmon_l.c
@@ -68,11 +68,6 @@
#define _NL_CURRENT(category, item) \
(current->values[_NL_ITEM_INDEX (item)].string)
-/* This function determines the number of digit groups in the output.
- The definition is in printf_fp.c. */
-extern unsigned int __guess_grouping (unsigned int intdig_max,
- const char *grouping, wchar_t sepchar);
-
/* We have to overcome some problems with this implementation. On the
one hand the strfmon() function is specified in XPG4 and of course
@@ -324,9 +319,7 @@ __vstrfmon_l (char *s, size_t maxsize, locale_t loc, const char *format,
extra characters this means. */
if (group && left_prec != -1)
left_prec += __guess_grouping (left_prec,
- _NL_CURRENT (LC_MONETARY, MON_GROUPING),
- *_NL_CURRENT (LC_MONETARY,
- MON_THOUSANDS_SEP));
+ _NL_CURRENT (LC_MONETARY, MON_GROUPING));
/* Now it's time to get the value. */
if (is_long_double == 1)
--
2.13.5
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Hide internal printf functions [BZ #18822/21986]
2017-08-21 22:04 [PATCH] Hide internal printf functions [BZ #18822/21986] H.J. Lu
@ 2017-08-22 6:33 ` Andreas Schwab
2017-08-22 11:31 ` H.J. Lu
0 siblings, 1 reply; 4+ messages in thread
From: Andreas Schwab @ 2017-08-22 6:33 UTC (permalink / raw)
To: H.J. Lu; +Cc: GNU C Library, H.J. Lu
On Aug 21 2017, "H.J. Lu" <hongjiu.lu@intel.com> wrote:
> diff --git a/stdio-common/printf.h b/stdio-common/printf.h
> index 940256445e..155dfdc7d3 100644
> --- a/stdio-common/printf.h
> +++ b/stdio-common/printf.h
> @@ -182,6 +182,9 @@ extern int printf_size_info (const struct printf_info *__restrict
> __info, size_t __n, int *__restrict __argtypes)
> __THROW;
>
> +extern unsigned int __guess_grouping (unsigned int intdig_max,
> + const char *grouping);
> +
This is not a public function.
Andreas.
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Hide internal printf functions [BZ #18822/21986]
2017-08-22 6:33 ` Andreas Schwab
@ 2017-08-22 11:31 ` H.J. Lu
2017-08-22 13:49 ` Andreas Schwab
0 siblings, 1 reply; 4+ messages in thread
From: H.J. Lu @ 2017-08-22 11:31 UTC (permalink / raw)
To: Andreas Schwab; +Cc: H.J. Lu, GNU C Library
[-- Attachment #1: Type: text/plain, Size: 764 bytes --]
On Mon, Aug 21, 2017 at 11:33 PM, Andreas Schwab <schwab@suse.de> wrote:
> On Aug 21 2017, "H.J. Lu" <hongjiu.lu@intel.com> wrote:
>
>> diff --git a/stdio-common/printf.h b/stdio-common/printf.h
>> index 940256445e..155dfdc7d3 100644
>> --- a/stdio-common/printf.h
>> +++ b/stdio-common/printf.h
>> @@ -182,6 +182,9 @@ extern int printf_size_info (const struct printf_info *__restrict
>> __info, size_t __n, int *__restrict __argtypes)
>> __THROW;
>>
>> +extern unsigned int __guess_grouping (unsigned int intdig_max,
>> + const char *grouping);
>> +
>
> This is not a public function.
>
Here is the updated patch to move __guess_grouping prototype to
include/printf.h. OK for master?
--
H.J.
[-- Attachment #2: 0001-Hide-internal-printf-functions-BZ-18822-21986.patch --]
[-- Type: text/x-patch, Size: 4303 bytes --]
From 9756b67d83c5436fec5d8fa17125529d4ad02ac9 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Mon, 21 Aug 2017 14:37:11 -0700
Subject: [PATCH] Hide internal printf functions [BZ #18822/21986]
Hide internal printf functions to allow direct access within libc.so and
libc.a without using GOT nor PLT.
Since __guess_grouping has been changed to take 2 arguments by
commit a1d84548c8aa7023cd039c85f81b831eef6d4a4c
Author: Ulrich Drepper <drepper@redhat.com>
Date: Fri Feb 11 18:50:36 2000 +0000
the third argument passed to __guess_grouping is removed.
[BZ #18822]
[BZ #21986]
* include/printf.h (__printf_fphex): Add attribute_hidden.
(__guess_grouping): New prototype.
* stdio-common/printf_fp.c (__guess_grouping): Removed.
* stdio-common/reg-printf.c (__register_printf_specifier): Add
libc_hidden_proto and libc_hidden_def.
* stdlib/strfmon_l.c (__guess_grouping): Removed.
(__vstrfmon_l): Remove the third argument passed to
__guess_grouping.
---
include/printf.h | 6 +++++-
stdio-common/printf_fp.c | 2 --
stdio-common/reg-printf.c | 2 ++
stdlib/strfmon_l.c | 9 +--------
4 files changed, 8 insertions(+), 11 deletions(-)
diff --git a/include/printf.h b/include/printf.h
index 7b4d209c47..d051514119 100644
--- a/include/printf.h
+++ b/include/printf.h
@@ -8,7 +8,7 @@
/* Now define the internal interfaces. */
extern int __printf_fphex (FILE *, const struct printf_info *,
- const void *const *);
+ const void *const *) attribute_hidden;
extern int __printf_fp (FILE *, const struct printf_info *,
const void *const *);
libc_hidden_proto (__printf_fp)
@@ -16,5 +16,9 @@ extern int __printf_fp_l (FILE *, locale_t, const struct printf_info *,
const void *const *);
libc_hidden_proto (__printf_fp_l)
+extern unsigned int __guess_grouping (unsigned int intdig_max,
+ const char *grouping)
+ attribute_hidden;
+
# endif /* !_ISOMAC */
#endif
diff --git a/stdio-common/printf_fp.c b/stdio-common/printf_fp.c
index 3ed4037ba5..2633a02cc5 100644
--- a/stdio-common/printf_fp.c
+++ b/stdio-common/printf_fp.c
@@ -139,8 +139,6 @@ extern mp_size_t __mpn_extract_double (mp_ptr res_ptr, mp_size_t size,
extern mp_size_t __mpn_extract_long_double (mp_ptr res_ptr, mp_size_t size,
int *expt, int *is_neg,
long double value);
-extern unsigned int __guess_grouping (unsigned int intdig_max,
- const char *grouping);
static wchar_t *group_number (wchar_t *buf, wchar_t *bufend,
diff --git a/stdio-common/reg-printf.c b/stdio-common/reg-printf.c
index cbb9307795..fed5a16a7b 100644
--- a/stdio-common/reg-printf.c
+++ b/stdio-common/reg-printf.c
@@ -32,6 +32,7 @@ __libc_lock_define_initialized (static, lock)
int __register_printf_specifier (int, printf_function,
printf_arginfo_size_function);
+libc_hidden_proto (__register_printf_specifier)
int __register_printf_function (int, printf_function,
printf_arginfo_function);
@@ -72,6 +73,7 @@ __register_printf_specifier (int spec, printf_function converter,
return result;
}
+libc_hidden_def (__register_printf_specifier)
weak_alias (__register_printf_specifier, register_printf_specifier)
diff --git a/stdlib/strfmon_l.c b/stdlib/strfmon_l.c
index 98554dfe80..1df184e8b2 100644
--- a/stdlib/strfmon_l.c
+++ b/stdlib/strfmon_l.c
@@ -68,11 +68,6 @@
#define _NL_CURRENT(category, item) \
(current->values[_NL_ITEM_INDEX (item)].string)
-/* This function determines the number of digit groups in the output.
- The definition is in printf_fp.c. */
-extern unsigned int __guess_grouping (unsigned int intdig_max,
- const char *grouping, wchar_t sepchar);
-
/* We have to overcome some problems with this implementation. On the
one hand the strfmon() function is specified in XPG4 and of course
@@ -324,9 +319,7 @@ __vstrfmon_l (char *s, size_t maxsize, locale_t loc, const char *format,
extra characters this means. */
if (group && left_prec != -1)
left_prec += __guess_grouping (left_prec,
- _NL_CURRENT (LC_MONETARY, MON_GROUPING),
- *_NL_CURRENT (LC_MONETARY,
- MON_THOUSANDS_SEP));
+ _NL_CURRENT (LC_MONETARY, MON_GROUPING));
/* Now it's time to get the value. */
if (is_long_double == 1)
--
2.13.5
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Hide internal printf functions [BZ #18822/21986]
2017-08-22 11:31 ` H.J. Lu
@ 2017-08-22 13:49 ` Andreas Schwab
0 siblings, 0 replies; 4+ messages in thread
From: Andreas Schwab @ 2017-08-22 13:49 UTC (permalink / raw)
To: H.J. Lu; +Cc: H.J. Lu, GNU C Library
On Aug 22 2017, "H.J. Lu" <hjl.tools@gmail.com> wrote:
> [BZ #18822]
> [BZ #21986]
> * include/printf.h (__printf_fphex): Add attribute_hidden.
> (__guess_grouping): New prototype.
> * stdio-common/printf_fp.c (__guess_grouping): Removed.
> * stdio-common/reg-printf.c (__register_printf_specifier): Add
> libc_hidden_proto and libc_hidden_def.
> * stdlib/strfmon_l.c (__guess_grouping): Removed.
> (__vstrfmon_l): Remove the third argument passed to
> __guess_grouping.
Ok.
Andreas.
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-08-22 13:49 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-21 22:04 [PATCH] Hide internal printf functions [BZ #18822/21986] H.J. Lu
2017-08-22 6:33 ` Andreas Schwab
2017-08-22 11:31 ` H.J. Lu
2017-08-22 13:49 ` Andreas Schwab
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).