summaryrefslogtreecommitdiffstats
path: root/libexec/rtld-elf/malloc.c
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2015-04-12 06:43:13 +0000
committerkib <kib@FreeBSD.org>2015-04-12 06:43:13 +0000
commit0fe937192c3bb4e05e924beb5bbc3749efc648cc (patch)
tree36e00068b47674fb72266f689791afffb4a5cc8e /libexec/rtld-elf/malloc.c
parent9455179208fbe2ed5512b0ef6072dfe964829752 (diff)
downloadFreeBSD-src-0fe937192c3bb4e05e924beb5bbc3749efc648cc.zip
FreeBSD-src-0fe937192c3bb4e05e924beb5bbc3749efc648cc.tar.gz
MFC r264346 (by alc):
Pass MAP_ALIGNED_SUPER to allocate the whole dso region if its text is large enough for the superpage mapping.
Diffstat (limited to 'libexec/rtld-elf/malloc.c')
-rw-r--r--libexec/rtld-elf/malloc.c29
1 files changed, 9 insertions, 20 deletions
diff --git a/libexec/rtld-elf/malloc.c b/libexec/rtld-elf/malloc.c
index 8e34362..9f7dbe0 100644
--- a/libexec/rtld-elf/malloc.c
+++ b/libexec/rtld-elf/malloc.c
@@ -139,25 +139,14 @@ botch(s)
/* Debugging stuff */
#define TRACE() rtld_printf("TRACE %s:%d\n", __FILE__, __LINE__)
-extern int pagesize;
-
-static int
-rtld_getpagesize(void)
-{
- int mib[2];
- size_t size;
-
- if (pagesize != 0)
- return (pagesize);
-
- mib[0] = CTL_HW;
- mib[1] = HW_PAGESIZE;
- size = sizeof(pagesize);
- if (sysctl(mib, 2, &pagesize, &size, NULL, 0) == -1)
- return (-1);
- return (pagesize);
-
-}
+/*
+ * The array of supported page sizes is provided by the user, i.e., the
+ * program that calls this storage allocator. That program must initialize
+ * the array before making its first call to allocate storage. The array
+ * must contain at least one page size. The page sizes must be stored in
+ * increasing order.
+ */
+extern size_t *pagesizes;
void *
malloc(nbytes)
@@ -173,7 +162,7 @@ malloc(nbytes)
* align break pointer so all data will be page aligned.
*/
if (pagesz == 0) {
- pagesz = n = rtld_getpagesize();
+ pagesz = n = pagesizes[0];
if (morepages(NPOOLPAGES) == 0)
return NULL;
op = (union overhead *)(pagepool_start);
OpenPOWER on IntegriCloud