Skip to content

Commit 6055669

Browse files
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
1 parent aec5ac0 commit 6055669

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

.github/workflows/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ jobs:
6666
- name: Build
6767
working-directory: ${{github.workspace}}/build
6868
run: NINJA_STATUS="%p [%f:%s/%t] %o/s, %es" ninja
69+
- name: Test file size of binaries is sane
70+
working-directory: ${{github.workspace}}/build
71+
run: "ls -l func-first_operation-1 ; [ $(ls -l func-first_operation-1 | awk '{ print $5}') -lt 10000000 ]"
6972
# If the tests are enabled for this job, run them
7073
- name: Test
7174
if: ${{ matrix.build-only != 'yes' }}

src/ds/defines.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@
4444
# endif
4545
#endif
4646

47+
#ifdef __APPLE__
48+
# define SNMALLOC_FORCE_BSS __attribute__((section("__DATA,__bss")))
49+
#elif defined(__ELF__)
50+
# define SNMALLOC_FORCE_BSS __attribute__((section(".bss")))
51+
#else
52+
# define SNMALLOC_FORCE_BSS
53+
#endif
54+
4755
#ifndef __has_builtin
4856
# define __has_builtin(x) 0
4957
#endif

src/mem/pagemap.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,7 @@ namespace snmalloc
464464
* The global pagemap variable. The name of this symbol will include the
465465
* type of `T` and `U`.
466466
*/
467+
SNMALLOC_FORCE_BSS
467468
inline static T global_pagemap;
468469

469470
public:

0 commit comments

Comments
 (0)