From patchwork Fri Sep 1 17:59:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 22538 Received: (qmail 87882 invoked by alias); 1 Sep 2017 18:01:04 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 87819 invoked by uid 89); 1 Sep 2017 18:01:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.2 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_SOFTFAIL autolearn=ham version=3.3.2 spammy= X-HELO: mga02.intel.com X-ExtLoop1: 1 From: "H.J. Lu" To: libc-alpha@sourceware.org Subject: [PATCH 25/58] Hide internal sysinfo functions [BZ #18822] Date: Fri, 1 Sep 2017 10:59:56 -0700 Message-Id: <20170901180029.9527-26-hjl.tools@gmail.com> In-Reply-To: <20170901180029.9527-1-hjl.tools@gmail.com> References: <20170901180029.9527-1-hjl.tools@gmail.com> Hide internal sysinfo functions to allow direct access within libc.so and libc.a without using GOT nor PLT. [BZ #18822] * include/sys/sysinfo.h (__get_nprocs_conf): Add libc_hidden_proto. (__get_nprocs): Likewise. (__get_phys_pages): Likewise. (__get_avphys_pages): Likewise. (__get_child_max): Add attribute_hidden. * misc/getsysstats.c (__get_nprocs_conf): Add libc_hidden_def. (__get_nprocs): Likewise. (__get_phys_pages): Likewise. (__get_avphys_pages): Likewise. * sysdeps/mach/getsysstats.c (__get_nprocs_conf): Add libc_hidden_def. (__get_nprocs): Likewise. (__get_phys_pages): Likewise. (__get_avphys_pages): Likewise. * sysdeps/unix/sysv/linux/getsysstats.c (__get_nprocs): Add libc_hidden_def. (__get_nprocs_conf): Likewise. (__get_phys_pages): Likewise. (__get_avphys_pages): Likewise. --- include/sys/sysinfo.h | 6 +++++- misc/getsysstats.c | 4 ++++ sysdeps/mach/getsysstats.c | 4 ++++ sysdeps/unix/sysv/linux/getsysstats.c | 4 ++++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/include/sys/sysinfo.h b/include/sys/sysinfo.h index c33eae2883..7388356a19 100644 --- a/include/sys/sysinfo.h +++ b/include/sys/sysinfo.h @@ -7,18 +7,22 @@ /* Return number of configured processors. */ extern int __get_nprocs_conf (void); +libc_hidden_proto (__get_nprocs_conf) /* Return number of available processors. */ extern int __get_nprocs (void); +libc_hidden_proto (__get_nprocs) /* Return number of physical pages of memory in the system. */ extern long int __get_phys_pages (void); +libc_hidden_proto (__get_phys_pages) /* Return number of available physical pages of memory in the system. */ extern long int __get_avphys_pages (void); +libc_hidden_proto (__get_avphys_pages) /* Return maximum number of processes this real user ID can have. */ -extern long int __get_child_max (void); +extern long int __get_child_max (void) attribute_hidden; # endif /* !_ISOMAC */ #endif /* sys/sysinfo.h */ diff --git a/misc/getsysstats.c b/misc/getsysstats.c index d25770ec52..cbad87a3a2 100644 --- a/misc/getsysstats.c +++ b/misc/getsysstats.c @@ -26,6 +26,7 @@ __get_nprocs_conf (void) /* We don't know how to determine the number. Simply return always 1. */ return 1; } +libc_hidden_def (__get_nprocs_conf) weak_alias (__get_nprocs_conf, get_nprocs_conf) link_warning (get_nprocs_conf, "warning: get_nprocs_conf will always return 1") @@ -38,6 +39,7 @@ __get_nprocs (void) /* We don't know how to determine the number. Simply return always 1. */ return 1; } +libc_hidden_def (__get_nprocs) weak_alias (__get_nprocs, get_nprocs) link_warning (get_nprocs, "warning: get_nprocs will always return 1") @@ -50,6 +52,7 @@ __get_phys_pages (void) __set_errno (ENOSYS); return -1; } +libc_hidden_def (__get_phys_pages) weak_alias (__get_phys_pages, get_phys_pages) stub_warning (get_phys_pages) @@ -62,6 +65,7 @@ __get_avphys_pages (void) __set_errno (ENOSYS); return -1; } +libc_hidden_def (__get_avphys_pages) weak_alias (__get_avphys_pages, get_avphys_pages) stub_warning (get_avphys_pages) diff --git a/sysdeps/mach/getsysstats.c b/sysdeps/mach/getsysstats.c index 0dacab0300..3aabd61382 100644 --- a/sysdeps/mach/getsysstats.c +++ b/sysdeps/mach/getsysstats.c @@ -39,6 +39,7 @@ __get_nprocs_conf (void) return hbi.max_cpus; } +libc_hidden_def (__get_nprocs_conf) weak_alias (__get_nprocs_conf, get_nprocs_conf) /* Return the number of processors currently available on the system. */ @@ -58,6 +59,7 @@ __get_nprocs (void) return hbi.avail_cpus; } +libc_hidden_def (__get_nprocs) weak_alias (__get_nprocs, get_nprocs) /* Return the number of physical pages on the system. */ @@ -77,6 +79,7 @@ __get_phys_pages (void) return hbi.memory_size / __vm_page_size; } +libc_hidden_def (__get_phys_pages) weak_alias (__get_phys_pages, get_phys_pages) /* Return the number of available physical pages */ @@ -102,4 +105,5 @@ __get_avphys_pages (void) return vs.free_count; } +libc_hidden_def (__get_avphys_pages) weak_alias (__get_avphys_pages, get_avphys_pages) diff --git a/sysdeps/unix/sysv/linux/getsysstats.c b/sysdeps/unix/sysv/linux/getsysstats.c index d02c86d739..c245b3c662 100644 --- a/sysdeps/unix/sysv/linux/getsysstats.c +++ b/sysdeps/unix/sysv/linux/getsysstats.c @@ -226,6 +226,7 @@ __get_nprocs (void) return result; } +libc_hidden_def (__get_nprocs) weak_alias (__get_nprocs, get_nprocs) @@ -279,6 +280,7 @@ __get_nprocs_conf (void) return result; } +libc_hidden_def (__get_nprocs_conf) weak_alias (__get_nprocs_conf, get_nprocs_conf) @@ -320,6 +322,7 @@ __get_phys_pages (void) __sysinfo (&info); return sysinfo_mempages (info.totalram, info.mem_unit); } +libc_hidden_def (__get_phys_pages) weak_alias (__get_phys_pages, get_phys_pages) long int @@ -330,4 +333,5 @@ __get_avphys_pages (void) __sysinfo (&info); return sysinfo_mempages (info.freeram, info.mem_unit); } +libc_hidden_def (__get_avphys_pages) weak_alias (__get_avphys_pages, get_avphys_pages)