From 605566974c09e7323ec1fdcb249d20296e8eab43 Mon Sep 17 00:00:00 2001 From: David Chisnall Date: Thu, 5 Aug 2021 10:13:59 +0100 Subject: [PATCH] Force global pagemaps into BSS (#364) Also add a check that the test programs are under about ten megabytes (they're currently around one on platforms that put inline statics full of zeroes into BSS and around 270 on ones that don't). Fixes #339 --- .github/workflows/main.yml | 3 +++ src/ds/defines.h | 8 ++++++++ src/mem/pagemap.h | 1 + 3 files changed, 12 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3906c69..dbb1709 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -66,6 +66,9 @@ jobs: - name: Build working-directory: ${{github.workspace}}/build run: NINJA_STATUS="%p [%f:%s/%t] %o/s, %es" ninja + - name: Test file size of binaries is sane + working-directory: ${{github.workspace}}/build + run: "ls -l func-first_operation-1 ; [ $(ls -l func-first_operation-1 | awk '{ print $5}') -lt 10000000 ]" # If the tests are enabled for this job, run them - name: Test if: ${{ matrix.build-only != 'yes' }} diff --git a/src/ds/defines.h b/src/ds/defines.h index ca2289e..53d362b 100644 --- a/src/ds/defines.h +++ b/src/ds/defines.h @@ -44,6 +44,14 @@ # endif #endif +#ifdef __APPLE__ +# define SNMALLOC_FORCE_BSS __attribute__((section("__DATA,__bss"))) +#elif defined(__ELF__) +# define SNMALLOC_FORCE_BSS __attribute__((section(".bss"))) +#else +# define SNMALLOC_FORCE_BSS +#endif + #ifndef __has_builtin # define __has_builtin(x) 0 #endif diff --git a/src/mem/pagemap.h b/src/mem/pagemap.h index 5f0972c..25050ec 100644 --- a/src/mem/pagemap.h +++ b/src/mem/pagemap.h @@ -464,6 +464,7 @@ namespace snmalloc * The global pagemap variable. The name of this symbol will include the * type of `T` and `U`. */ + SNMALLOC_FORCE_BSS inline static T global_pagemap; public: