]> sourceware.org Git - glibc.git/commitdiff
Mark internal functions with attribute_hidden [BZ #18822]
authorH.J. Lu <hjl.tools@gmail.com>
Sun, 1 Oct 2017 22:07:06 +0000 (15:07 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Sun, 1 Oct 2017 22:07:23 +0000 (15:07 -0700)
Mark internal functions with attribute_hidden to allow direct access to
internal functions within libc.so and libc.a without using GOT nor PLT.

Size comparison of libc.so:

On x86-64:
        text    data     bss     dec     hex
Before: 1728577   20584   17088 1766249  1af369
After : 1728593   20584   17088 1766265  1af379

The only change is __gconv_release_shlib in iconv/gconv_dl.c is inlined
since it is hidden, which increases the code size of gconv_dl.os by 18
bytes.

On i686:
        text    data     bss     dec     hex
Before: 1869039   11444   11112 1891595  1cdd0b
After : 1868635   11444   11112 1891191  1cdb77

The code size is decreased by avoiding GOT/PLT for hidden functions.

[BZ #18822]
* iconv/gconv_int.h (__gconv_open): Add attribute_hidden.
(__gconv_close): Likewise.
(__gconv): Likewise.
(__gconv_find_transform): Likewise.
(__gconv_lookup_cache): Likewise.
(__gconv_compare_alias_cache): Likewise.
(__gconv_load_cache): Likewise.
(__gconv_get_path): Likewise.
(__gconv_close_transform): Likewise.
(__gconv_release_cache): Likewise.
(__gconv_find_shlib): Likewise.
(__gconv_release_shlib): Likewise.
(__gconv_get_builtin_trans): Likewise.
(__gconv_compare_alias): Likewise.
* include/dlfcn.h (_dlerror_run): Likewise.
* include/stdio.h (__fortify_fail_abort): Likewise.
* include/time.h (__tz_compute): Likewise.
(__strptime_internal): Likewise.
* intl/gettextP.h (_nl_find_domain): Likewise.
(_nl_load_domain): Likewise.
(_nl_find_msg): Likewise.
* intl/plural-exp.h (FREE_EXPRESSION): Likewise.
(EXTRACT_PLURAL_EXPRESSION): Likewise.
* locale/coll-lookup.h (__collidx_table_lookup): Likewise.
* resolv/gai_misc.h (__gai_enqueue_request): Likewise.
(__gai_find_request): Likewise.
(__gai_remove_request): Likewise.
(__gai_notify): Likewise.
(__gai_notify_only): Likewise.
* sysdeps/generic/aio_misc.h (__aio_sigqueue): Likewise.
* sysdeps/generic/ldsodefs.h (_dl_fini): Likewise.
(_dl_non_dynamic_init): Likewise.
(_dl_aux_init): Likewise.
* sysdeps/i386/machine-gmon.h (mcount_internal): Likewise.
* sysdeps/unix/sysv/linux/i386/olddirent.h (__old_getdents64):
Likewise.
* wcsmbs/wcsmbsload.h (__wcsmbs_load_conv): Likewise.
(__wcsmbs_clone_conv): Likewise.
(__wcsmbs_named_conv): Likewise.

14 files changed:
ChangeLog
iconv/gconv_int.h
include/dlfcn.h
include/stdio.h
include/time.h
intl/gettextP.h
intl/plural-exp.h
locale/coll-lookup.h
resolv/gai_misc.h
sysdeps/generic/aio_misc.h
sysdeps/generic/ldsodefs.h
sysdeps/i386/machine-gmon.h
sysdeps/unix/sysv/linux/olddirent.h
wcsmbs/wcsmbsload.h

index e9405865207ff24c9938adc28cc72ead03f2be97..f0935d1c8361df8697b5c9a14ad50a9869f67b98 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,46 @@
+2017-10-01  H.J. Lu  <hongjiu.lu@intel.com>
+
+       [BZ #18822]
+       * iconv/gconv_int.h (__gconv_open): Add attribute_hidden.
+       (__gconv_close): Likewise.
+       (__gconv): Likewise.
+       (__gconv_find_transform): Likewise.
+       (__gconv_lookup_cache): Likewise.
+       (__gconv_compare_alias_cache): Likewise.
+       (__gconv_load_cache): Likewise.
+       (__gconv_get_path): Likewise.
+       (__gconv_close_transform): Likewise.
+       (__gconv_release_cache): Likewise.
+       (__gconv_find_shlib): Likewise.
+       (__gconv_release_shlib): Likewise.
+       (__gconv_get_builtin_trans): Likewise.
+       (__gconv_compare_alias): Likewise.
+       * include/dlfcn.h (_dlerror_run): Likewise.
+       * include/stdio.h (__fortify_fail_abort): Likewise.
+       * include/time.h (__tz_compute): Likewise.
+       (__strptime_internal): Likewise.
+       * intl/gettextP.h (_nl_find_domain): Likewise.
+       (_nl_load_domain): Likewise.
+       (_nl_find_msg): Likewise.
+       * intl/plural-exp.h (FREE_EXPRESSION): Likewise.
+       (EXTRACT_PLURAL_EXPRESSION): Likewise.
+       * locale/coll-lookup.h (__collidx_table_lookup): Likewise.
+       * resolv/gai_misc.h (__gai_enqueue_request): Likewise.
+       (__gai_find_request): Likewise.
+       (__gai_remove_request): Likewise.
+       (__gai_notify): Likewise.
+       (__gai_notify_only): Likewise.
+       * sysdeps/generic/aio_misc.h (__aio_sigqueue): Likewise.
+       * sysdeps/generic/ldsodefs.h (_dl_fini): Likewise.
+       (_dl_non_dynamic_init): Likewise.
+       (_dl_aux_init): Likewise.
+       * sysdeps/i386/machine-gmon.h (mcount_internal): Likewise.
+       * sysdeps/unix/sysv/linux/i386/olddirent.h (__old_getdents64):
+       Likewise.
+       * wcsmbs/wcsmbsload.h (__wcsmbs_load_conv): Likewise.
+       (__wcsmbs_clone_conv): Likewise.
+       (__wcsmbs_named_conv): Likewise.
+
 2017-10-01  H.J. Lu  <hongjiu.lu@intel.com>
 
        [BZ #18822]
index b1433f801e66a720bae970129b3e71d992fa95fe..2afd12a977b01d8796a37f190970ffe981676e39 100644 (file)
@@ -156,10 +156,12 @@ __libc_lock_define (extern, __gconv_lock attribute_hidden)
 
 /* Return in *HANDLE decriptor for transformation from FROMSET to TOSET.  */
 extern int __gconv_open (const char *toset, const char *fromset,
-                        __gconv_t *handle, int flags);
+                        __gconv_t *handle, int flags)
+     attribute_hidden;
 
 /* Free resources associated with transformation descriptor CD.  */
-extern int __gconv_close (__gconv_t cd);
+extern int __gconv_close (__gconv_t cd)
+     attribute_hidden;
 
 /* Transform at most *INBYTESLEFT bytes from buffer starting at *INBUF
    according to rules described by CD and place up to *OUTBYTESLEFT
@@ -167,33 +169,38 @@ extern int __gconv_close (__gconv_t cd);
    conversions in *IRREVERSIBLE if this pointer is not null.  */
 extern int __gconv (__gconv_t cd, const unsigned char **inbuf,
                    const unsigned char *inbufend, unsigned char **outbuf,
-                   unsigned char *outbufend, size_t *irreversible);
+                   unsigned char *outbufend, size_t *irreversible)
+     attribute_hidden;
 
 /* Return in *HANDLE a pointer to an array with *NSTEPS elements describing
    the single steps necessary for transformation from FROMSET to TOSET.  */
 extern int __gconv_find_transform (const char *toset, const char *fromset,
                                   struct __gconv_step **handle,
-                                  size_t *nsteps, int flags);
+                                  size_t *nsteps, int flags)
+     attribute_hidden;
 
 /* Search for transformation in cache data.  */
 extern int __gconv_lookup_cache (const char *toset, const char *fromset,
                                 struct __gconv_step **handle, size_t *nsteps,
-                                int flags);
+                                int flags)
+     attribute_hidden;
 
 /* Compare the two name for whether they are after alias expansion the
    same.  This function uses the cache and fails if none is
    loaded.  */
 extern int __gconv_compare_alias_cache (const char *name1, const char *name2,
-                                       int *result);
+                                       int *result)
+     attribute_hidden;
 
 /* Free data associated with a step's structure.  */
-extern void __gconv_release_step (struct __gconv_step *step);
+extern void __gconv_release_step (struct __gconv_step *step)
+     attribute_hidden;
 
 /* Read all the configuration data and cache it.  */
 extern void __gconv_read_conf (void) attribute_hidden;
 
 /* Try to read module cache file.  */
-extern int __gconv_load_cache (void);
+extern int __gconv_load_cache (void) attribute_hidden;
 
 /* Retrieve pointer to internal cache.  */
 extern void *__gconv_get_cache (void);
@@ -205,7 +212,7 @@ extern struct gconv_module *__gconv_get_modules_db (void);
 extern void *__gconv_get_alias_db (void);
 
 /* Determine the directories we are looking in.  */
-extern void __gconv_get_path (void);
+extern void __gconv_get_path (void) attribute_hidden;
 
 /* Comparison function to search alias.  */
 extern int __gconv_alias_compare (const void *p1, const void *p2)
@@ -214,28 +221,34 @@ extern int __gconv_alias_compare (const void *p1, const void *p2)
 /* Clear reference to transformation step implementations which might
    cause the code to be unloaded.  */
 extern int __gconv_close_transform (struct __gconv_step *steps,
-                                   size_t nsteps);
+                                   size_t nsteps)
+     attribute_hidden;
 
 /* Free all resources allocated for the transformation record when
    using the cache.  */
-extern void __gconv_release_cache (struct __gconv_step *steps, size_t nsteps);
+extern void __gconv_release_cache (struct __gconv_step *steps, size_t nsteps)
+     attribute_hidden;
 
 /* Load shared object named by NAME.  If already loaded increment reference
    count.  */
-extern struct __gconv_loaded_object *__gconv_find_shlib (const char *name);
+extern struct __gconv_loaded_object *__gconv_find_shlib (const char *name)
+     attribute_hidden;
 
 /* Release shared object.  If no further reference is available unload
    the object.  */
-extern void __gconv_release_shlib (struct __gconv_loaded_object *handle);
+extern void __gconv_release_shlib (struct __gconv_loaded_object *handle)
+     attribute_hidden;
 
 /* Fill STEP with information about builtin module with NAME.  */
 extern void __gconv_get_builtin_trans (const char *name,
-                                      struct __gconv_step *step);
+                                      struct __gconv_step *step)
+     attribute_hidden;
 
 libc_hidden_proto (__gconv_transliterate)
 
 /* If NAME is an codeset alias expand it.  */
-extern int __gconv_compare_alias (const char *name1, const char *name2);
+extern int __gconv_compare_alias (const char *name1, const char *name2)
+     attribute_hidden;
 
 
 /* Builtin transformations.  */
index 888e84d4b8974b0631d789d97badbaa6b1623ae5..526086f1a09c9662c9d303dd99df761db4ec6814 100644 (file)
@@ -72,7 +72,8 @@ extern void *_dl_vsym (void *handle, const char *name, const char *version,
    _dl_catch_error.  Returns zero for success, nonzero for failure; and
    arranges for `dlerror' to return the error details.
    ARGS is passed as argument to OPERATE.  */
-extern int _dlerror_run (void (*operate) (void *), void *args);
+extern int _dlerror_run (void (*operate) (void *), void *args)
+    attribute_hidden;
 
 #ifdef SHARED
 # define DL_CALLER_DECL /* Nothing */
index 87e0e1079782ef1db3402c2e2672701a2d6b7eeb..7625a2a3a09c5aa535cb8ee8e797b6b5e2aa2b3d 100644 (file)
@@ -100,7 +100,7 @@ extern void __libc_message (enum __libc_message_action action,
                            const char *__fnt, ...);
 extern void __fortify_fail (const char *msg) __attribute__ ((__noreturn__));
 extern void __fortify_fail_abort (_Bool, const char *msg)
-  __attribute__ ((__noreturn__));
+  __attribute__ ((__noreturn__)) attribute_hidden;
 libc_hidden_proto (__fortify_fail)
 libc_hidden_proto (__fortify_fail_abort)
 
index 870b7eb93c9945014ef4c1f2e4c970332d579920..e8c07bbfeafa410835107560ee9435d0b2698812 100644 (file)
@@ -46,7 +46,7 @@ extern void __tzfile_default (const char *std, const char *dst,
                              long int stdoff, long int dstoff);
 extern void __tzset_parse_tz (const char *tz);
 extern void __tz_compute (time_t timer, struct tm *tm, int use_localtime)
-  __THROW;
+  __THROW attribute_hidden;
 
 /* Subroutine of `mktime'.  Return the `time_t' representation of TP and
    normalize TP, given that a `struct tm *' maps to a `time_t' as performed
@@ -89,7 +89,7 @@ extern int __getclktck (void);
 /* strptime support.  */
 extern char * __strptime_internal (const char *rp, const char *fmt,
                                   struct tm *tm, void *statep,
-                                  locale_t locparam);
+                                  locale_t locparam) attribute_hidden;
 
 extern double __difftime (time_t time1, time_t time0);
 
index 8fcfb5bef8f17a16decc25ad3e5c1a77b896c61c..75b203ab52f5f897370c50e1407e4102436a1866 100644 (file)
@@ -251,19 +251,23 @@ extern const char *_nl_locale_name_default (void);
 
 struct loaded_l10nfile *_nl_find_domain (const char *__dirname, char *__locale,
                                         const char *__domainname,
-                                        struct binding *__domainbinding);
+                                        struct binding *__domainbinding)
+     attribute_hidden;
 void _nl_load_domain (struct loaded_l10nfile *__domain,
-                     struct binding *__domainbinding);
+                     struct binding *__domainbinding)
+     attribute_hidden;
 
 #ifdef IN_LIBGLOCALE
 char *_nl_find_msg (struct loaded_l10nfile *domain_file,
                    struct binding *domainbinding, const char *encoding,
                    const char *msgid,
-                   size_t *lengthp);
+                   size_t *lengthp)
+     attribute_hidden;
 #else
 char *_nl_find_msg (struct loaded_l10nfile *domain_file,
                    struct binding *domainbinding, const char *msgid,
-                   int convert, size_t *lengthp);
+                   int convert, size_t *lengthp)
+     attribute_hidden;
 #endif
 
 /* The internal variables in the standalone libintl.a must have different
index 4833fcdf35b97e3a9b68c424fb0822b5be96163f..a4ffff9f9184a8ab36a63f9cc437b64391c4c25d 100644 (file)
@@ -101,12 +101,13 @@ struct parse_args
 # define EXTRACT_PLURAL_EXPRESSION extract_plural_expression
 #endif
 
-extern void FREE_EXPRESSION (struct expression *exp);
+extern void FREE_EXPRESSION (struct expression *exp) attribute_hidden;
 extern int PLURAL_PARSE (struct parse_args *arg);
 extern const struct expression GERMANIC_PLURAL attribute_hidden;
 extern void EXTRACT_PLURAL_EXPRESSION (const char *nullentry,
                                       const struct expression **pluralp,
-                                      unsigned long int *npluralsp);
+                                      unsigned long int *npluralsp)
+     attribute_hidden;
 
 #if !defined (_LIBC) && !defined (IN_LIBINTL) && !defined (IN_LIBGLOCALE)
 extern unsigned long int plural_eval (const struct expression *pexp,
index d1c488dcf59c12ce32d230f21aa6c57beeff67f8..9e20d393291ebbc535ae35b3d9a8072176b43c30 100644 (file)
@@ -19,7 +19,9 @@
 #include <stdint.h>
 
 /* Lookup in a table of int32_t, with default value 0.  */
-extern int32_t __collidx_table_lookup (const char *table, uint32_t wc);
+extern int32_t __collidx_table_lookup (const char *table, uint32_t wc)
+     attribute_hidden;
 
 /* Lookup in a table of uint32_t, with default value 0xffffffff.  */
-extern uint32_t __collseq_table_lookup (const char *table, uint32_t wc);
+extern uint32_t __collseq_table_lookup (const char *table, uint32_t wc)
+     attribute_hidden;
index 95d14ed54f96d1cf7945af1a217b1516ce89a093..efadf130106949504c9c1d6cf9c6625a3fc852bb 100644 (file)
@@ -75,19 +75,24 @@ extern pthread_mutex_t __gai_requests_mutex;
 
 
 /* Enqueue request.  */
-extern struct requestlist *__gai_enqueue_request (struct gaicb *gaicbp);
+extern struct requestlist *__gai_enqueue_request (struct gaicb *gaicbp)
+     attribute_hidden;
 
 /* Find request on wait list.  */
-extern struct requestlist *__gai_find_request (const struct gaicb *gaicbp);
+extern struct requestlist *__gai_find_request (const struct gaicb *gaicbp)
+     attribute_hidden;
 
 /* Remove request from waitlist.  */
-extern int __gai_remove_request (struct gaicb *gaicbp);
+extern int __gai_remove_request (struct gaicb *gaicbp)
+     attribute_hidden;
 
 /* Notify initiator of request and tell this everybody listening.  */
-extern void __gai_notify (struct requestlist *req);
+extern void __gai_notify (struct requestlist *req)
+     attribute_hidden;
 
 /* Notify initiator of request.  */
-extern int __gai_notify_only (struct sigevent *sigev, pid_t caller_pid);
+extern int __gai_notify_only (struct sigevent *sigev, pid_t caller_pid)
+     attribute_hidden;
 
 /* Send the signal.  */
 extern int __gai_sigqueue (int sig, const union sigval val, pid_t caller_pid);
index c0622b2ab6d6bd45af3fc72962c6f35d8b645bc1..d5a0297673c82529f68fc1e8d22c3c9829a4a454 100644 (file)
@@ -40,7 +40,8 @@ typedef union
 
 
 /* Send the signal.  */
-extern int __aio_sigqueue (int sig, const union sigval val, pid_t caller_pid);
+extern int __aio_sigqueue (int sig, const union sigval val, pid_t caller_pid)
+     attribute_hidden;
 
 
 #endif /* aio_misc.h */
index 1a4449eeb3bdb144238f2b5cbd884469589e8f4e..5efae2d96dc9901094c2cecb05651515ab71e65b 100644 (file)
@@ -954,7 +954,7 @@ extern void _dl_init (struct link_map *main_map, int argc, char **argv,
 
 /* Call the finalizer functions of all shared objects whose
    initializer functions have completed.  */
-extern void _dl_fini (void);
+extern void _dl_fini (void) attribute_hidden;
 
 /* Sort array MAPS according to dependencies of the contained objects.  */
 extern void _dl_sort_fini (struct link_map **maps, size_t nmaps, char *used,
@@ -1123,10 +1123,12 @@ extern struct link_map *_dl_find_dso_for_object (const ElfW(Addr) addr);
 rtld_hidden_proto (_dl_find_dso_for_object)
 
 /* Initialization which is normally done by the dynamic linker.  */
-extern void _dl_non_dynamic_init (void);
+extern void _dl_non_dynamic_init (void)
+     attribute_hidden;
 
 /* Used by static binaries to check the auxiliary vector.  */
-extern void _dl_aux_init (ElfW(auxv_t) *av);
+extern void _dl_aux_init (ElfW(auxv_t) *av)
+     attribute_hidden;
 
 
 __END_DECLS
index 3e90b8c0c7cb5908d9b2d067325f3a677d576da4..81e168e4e6e2974dc9499c985fbcbd1570c6868f 100644 (file)
@@ -30,7 +30,7 @@
 #define mcount_internal __mcount_internal
 
 extern void mcount_internal (u_long frompc, u_long selfpc)
-  __attribute__ ((regparm (2)));
+  __attribute__ ((regparm (2))) attribute_hidden;
 
 #define _MCOUNT_DECL(frompc, selfpc)                \
   __attribute__ ((regparm (2)))                            \
index 0b4c81da0e96ccad960c96fc5c460dad158b0b61..5510ab209592bad282e0cb42e008df59ea252d63 100644 (file)
@@ -34,7 +34,8 @@ extern struct __old_dirent64 *__old_readdir64 (DIR *__dirp);
 libc_hidden_proto (__old_readdir64);
 extern int __old_readdir64_r (DIR *__dirp, struct __old_dirent64 *__entry,
                          struct __old_dirent64 **__result);
-extern __ssize_t __old_getdents64 (int __fd, char *__buf, size_t __nbytes);
+extern __ssize_t __old_getdents64 (int __fd, char *__buf, size_t __nbytes)
+       attribute_hidden;
 int __old_scandir64 (const char * __dir,
                     struct __old_dirent64 *** __namelist,
                     int (*__selector) (const struct __old_dirent64 *),
index 7efe2c1f81cc54f4639a82ae9b906f8d69d145d8..57fad5307735c31cb557f9510f89d7718cbe3d0c 100644 (file)
@@ -37,13 +37,16 @@ struct gconv_fcts
 extern const struct gconv_fcts __wcsmbs_gconv_fcts_c attribute_hidden;
 
 /* Load conversion functions for the currently selected locale.  */
-extern void __wcsmbs_load_conv (struct __locale_data *new_category);
+extern void __wcsmbs_load_conv (struct __locale_data *new_category)
+     attribute_hidden;
 
 /* Clone the current `__wcsmbs_load_conv' value.  */
-extern void __wcsmbs_clone_conv (struct gconv_fcts *copy);
+extern void __wcsmbs_clone_conv (struct gconv_fcts *copy)
+     attribute_hidden;
 
 /* Find the conversion functions for converting to and from NAME.  */
-extern int __wcsmbs_named_conv (struct gconv_fcts *copy, const char *name);
+extern int __wcsmbs_named_conv (struct gconv_fcts *copy, const char *name)
+     attribute_hidden;
 
 /* Function used for the `private.cleanup' hook.  */
 extern void _nl_cleanup_ctype (struct __locale_data *) attribute_hidden;
This page took 0.104308 seconds and 5 git commands to generate.