summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorJason Evans <jasone@canonware.com>2017-05-04 18:20:43 (GMT)
committerJason Evans <jasone@canonware.com>2017-05-12 06:06:54 (GMT)
commit909f0482e479c1914a1bd528bf7ade702ed6415c (patch)
tree40130e7b19179c6e190be11dc8a9133fa2efffdd /include
parenta4ae9707daee680a6fa0575646849fa8ef0bfad1 (diff)
downloadjemalloc-909f0482e479c1914a1bd528bf7ade702ed6415c.zip
jemalloc-909f0482e479c1914a1bd528bf7ade702ed6415c.tar.gz
jemalloc-909f0482e479c1914a1bd528bf7ade702ed6415c.tar.bz2
Automatically generate private symbol name mangling macros.
Rather than using a manually maintained list of internal symbols to drive name mangling, add a compilation phase to automatically extract the list of internal symbols. This resolves #677.
Diffstat (limited to 'include')
-rw-r--r--include/jemalloc/internal/jemalloc_internal_defs.h.in12
-rw-r--r--include/jemalloc/internal/jemalloc_preamble.h.in8
-rwxr-xr-xinclude/jemalloc/internal/private_namespace.sh2
-rwxr-xr-xinclude/jemalloc/internal/private_symbols.sh51
-rw-r--r--include/jemalloc/internal/private_symbols.txt609
5 files changed, 71 insertions, 611 deletions
diff --git a/include/jemalloc/internal/jemalloc_internal_defs.h.in b/include/jemalloc/internal/jemalloc_internal_defs.h.in
index bccee16..78ddd37 100644
--- a/include/jemalloc/internal/jemalloc_internal_defs.h.in
+++ b/include/jemalloc/internal/jemalloc_internal_defs.h.in
@@ -9,6 +9,18 @@
#undef JEMALLOC_CPREFIX
/*
+ * Define overrides for non-standard allocator-related functions if they are
+ * present on the system.
+ */
+#undef JEMALLOC_OVERRIDE___LIBC_CALLOC
+#undef JEMALLOC_OVERRIDE___LIBC_FREE
+#undef JEMALLOC_OVERRIDE___LIBC_MALLOC
+#undef JEMALLOC_OVERRIDE___LIBC_MEMALIGN
+#undef JEMALLOC_OVERRIDE___LIBC_REALLOC
+#undef JEMALLOC_OVERRIDE___LIBC_VALLOC
+#undef JEMALLOC_OVERRIDE___POSIX_MEMALIGN
+
+/*
* JEMALLOC_PRIVATE_NAMESPACE is used as a prefix for all library-private APIs.
* For shared libraries, symbol visibility mechanisms prevent these symbols
* from being exported, but for static libraries, naming collisions are a real
diff --git a/include/jemalloc/internal/jemalloc_preamble.h.in b/include/jemalloc/internal/jemalloc_preamble.h.in
index bc0ca64..9e9225e 100644
--- a/include/jemalloc/internal/jemalloc_preamble.h.in
+++ b/include/jemalloc/internal/jemalloc_preamble.h.in
@@ -38,7 +38,13 @@
* want the inclusion of hooks to happen early, so that we hook as much as
* possible.
*/
-#include "jemalloc/internal/private_namespace.h"
+#ifndef JEMALLOC_NO_PRIVATE_NAMESPACE
+# ifndef JEMALLOC_JET
+# include "jemalloc/internal/private_namespace.h"
+# else
+# include "jemalloc/internal/private_namespace_jet.h"
+# endif
+#endif
#include "jemalloc/internal/hooks.h"
static const bool config_debug =
diff --git a/include/jemalloc/internal/private_namespace.sh b/include/jemalloc/internal/private_namespace.sh
index 820862f..6ef1346 100755
--- a/include/jemalloc/internal/private_namespace.sh
+++ b/include/jemalloc/internal/private_namespace.sh
@@ -1,5 +1,5 @@
#!/bin/sh
-for symbol in `cat $1` ; do
+for symbol in `cat "$@"` ; do
echo "#define ${symbol} JEMALLOC_N(${symbol})"
done
diff --git a/include/jemalloc/internal/private_symbols.sh b/include/jemalloc/internal/private_symbols.sh
new file mode 100755
index 0000000..442a259
--- /dev/null
+++ b/include/jemalloc/internal/private_symbols.sh
@@ -0,0 +1,51 @@
+#!/bin/sh
+#
+# Generate private_symbols[_jet].awk.
+#
+# Usage: private_symbols.sh <sym_prefix> <sym>*
+#
+# <sym_prefix> is typically "" or "_".
+
+sym_prefix=$1
+shift
+
+cat <<EOF
+#!/usr/bin/env awk -f
+
+BEGIN {
+ sym_prefix = "${sym_prefix}"
+ split("\\
+EOF
+
+for public_sym in "$@" ; do
+ cat <<EOF
+ ${sym_prefix}${public_sym} \\
+EOF
+done
+
+cat <<"EOF"
+ ", exported_symbol_names)
+ # Store exported symbol names as keys in exported_symbols.
+ for (i in exported_symbol_names) {
+ exported_symbols[exported_symbol_names[i]] = 1
+ }
+}
+
+# Process 'nm -a <c_source.o>' output.
+#
+# Handle lines like:
+# 0000000000000008 D opt_junk
+# 0000000000007574 T malloc_initialized
+(NF == 3 && $2 ~ /^[ABCDGRSTVW]$/ && !($3 in exported_symbols) && $3 ~ /^[A-Za-z0-9_]+$/) {
+ print substr($3, 1+length(sym_prefix), length($3)-length(sym_prefix))
+}
+
+# Process 'dumpbin /SYMBOLS <c_source.obj>' output.
+#
+# Handle lines like:
+# 353 00008098 SECT4 notype External | opt_junk
+# 3F1 00000000 SECT7 notype () External | malloc_initialized
+($3 ~ /^SECT[0-9]+/ && $(NF-2) == "External" && !($NF in exported_symbols)) {
+ print $NF
+}
+EOF
diff --git a/include/jemalloc/internal/private_symbols.txt b/include/jemalloc/internal/private_symbols.txt
deleted file mode 100644
index eb9b301..0000000
--- a/include/jemalloc/internal/private_symbols.txt
+++ /dev/null
@@ -1,609 +0,0 @@
-a0dalloc
-a0malloc
-arena_aalloc
-arena_alloc_junk_small
-arena_basic_stats_merge
-arena_bin_index
-arena_bin_info
-arena_boot
-arena_choose
-arena_choose_hard
-arena_choose_impl
-arena_cleanup
-arena_dalloc
-arena_dalloc_bin_junked_locked
-arena_dalloc_junk_small
-arena_dalloc_no_tcache
-arena_dalloc_promoted
-arena_dalloc_small
-arena_decay
-arena_decay_tick
-arena_decay_ticks
-arena_dirty_decay_time_default_get
-arena_dirty_decay_time_default_set
-arena_dirty_decay_time_get
-arena_dirty_decay_time_set
-arena_muzzy_decay_time_default_get
-arena_muzzy_decay_time_default_set
-arena_muzzy_decay_time_get
-arena_muzzy_decay_time_set
-arena_destroy
-arena_dss_prec_get
-arena_dss_prec_set
-arena_extent_alloc_large
-arena_extent_dalloc_large_prep
-arena_extent_ralloc_large_expand
-arena_extent_ralloc_large_shrink
-arena_extent_sn_next
-arena_extents_dirty_dalloc
-arena_get
-arena_ichoose
-arena_ind_get
-arena_init
-arena_internal_add
-arena_internal_get
-arena_internal_sub
-arena_malloc
-arena_malloc_hard
-arena_migrate
-arena_new
-arena_nthreads_dec
-arena_nthreads_get
-arena_nthreads_inc
-arena_palloc
-arena_postfork_child
-arena_postfork_parent
-arena_prefork0
-arena_prefork1
-arena_prefork2
-arena_prefork3
-arena_prefork4
-arena_prefork5
-arena_prefork6
-arena_prof_accum
-arena_prof_promote
-arena_prof_tctx_get
-arena_prof_tctx_reset
-arena_prof_tctx_set
-arena_ralloc
-arena_ralloc_no_move
-arena_reset
-arena_salloc
-arena_sdalloc
-arena_sdalloc_no_tcache
-arena_set
-arena_slab_regind
-arena_stats_init
-arena_stats_mapped_add
-arena_stats_merge
-arena_tcache_fill_small
-arena_tdata_get
-arena_tdata_get_hard
-arena_vsalloc
-arenas
-arenas_tdata_cleanup
-b0get
-base_alloc
-base_boot
-base_delete
-base_extent_alloc
-base_extent_hooks_get
-base_extent_hooks_set
-base_ind_get
-base_new
-base_postfork_child
-base_postfork_parent
-base_prefork
-base_stats_get
-bitmap_ffu
-bitmap_full
-bitmap_get
-bitmap_info_init
-bitmap_init
-bitmap_set
-bitmap_sfu
-bitmap_size
-bitmap_unset
-bootstrap_calloc
-bootstrap_free
-bootstrap_malloc
-bt_init
-bt2gctx_mtx
-buferror
-ckh_count
-ckh_delete
-ckh_insert
-ckh_iter
-ckh_new
-ckh_pointer_hash
-ckh_pointer_keycomp
-ckh_remove
-ckh_search
-ckh_string_hash
-ckh_string_keycomp
-ctl_boot
-ctl_bymib
-ctl_byname
-ctl_nametomib
-ctl_postfork_child
-ctl_postfork_parent
-ctl_prefork
-decay_ticker_get
-dss_prec_names
-extent_ad_comp
-extent_addr_get
-extent_addr_randomize
-extent_addr_set
-extent_alloc
-extent_alloc_cache
-extent_alloc_dss
-extent_alloc_mmap
-extent_alloc_wrapper
-extent_arena_get
-extent_arena_set
-extent_base_get
-extent_before_get
-extent_boot
-extent_binit
-extent_bsize_get
-extent_bsize_set
-extent_commit_wrapper
-extent_committed_get
-extent_committed_set
-extent_dalloc
-extent_dalloc_gap
-extent_dalloc_mmap
-extent_dalloc_wrapper
-extent_decommit_wrapper
-extent_destroy_wrapper
-extent_dss_boot
-extent_dss_mergeable
-extent_dss_prec_get
-extent_dss_prec_set
-extent_ead_comp
-extent_esn_comp
-extent_esn_get
-extent_esn_set
-extent_esnead_comp
-extent_heap_empty
-extent_heap_first
-extent_heap_insert
-extent_heap_new
-extent_heap_remove
-extent_heap_remove_first
-extent_hooks_default
-extent_hooks_get
-extent_hooks_set
-extent_in_dss
-extent_init
-extent_last_get
-extent_list_append
-extent_list_first
-extent_list_init
-extent_list_last
-extent_list_remove
-extent_list_replace
-extent_merge_wrapper
-extent_nfree_dec
-extent_nfree_get
-extent_nfree_inc
-extent_nfree_set
-extent_past_get
-extent_prof_tctx_get
-extent_prof_tctx_set
-extent_purge_forced_wrapper
-extent_purge_lazy_wrapper
-extent_size_get
-extent_size_quantize_ceil
-extent_size_quantize_floor
-extent_size_set
-extent_slab_data_get
-extent_slab_data_get_const
-extent_slab_get
-extent_slab_set
-extent_sn_comp
-extent_sn_get
-extent_sn_set
-extent_snad_comp
-extent_split_wrapper
-extent_state_get
-extent_state_set
-extent_szind_get
-extent_szind_get_maybe_invalid
-extent_szind_set
-extent_usize_get
-extent_zeroed_get
-extent_zeroed_set
-extents_alloc
-extents_dalloc
-extents_evict
-extents_init
-extents_npages_get
-extents_prefork
-extents_postfork_child
-extents_postfork_parent
-extents_rtree
-extents_state_get
-ffs_llu
-ffs_lu
-ffs_u
-ffs_u32
-ffs_u64
-ffs_zu
-get_errno
-hash
-hash_fmix_32
-hash_fmix_64
-hash_get_block_32
-hash_get_block_64
-hash_rotl_32
-hash_rotl_64
-hash_x64_128
-hash_x86_128
-hash_x86_32
-hooks_arena_new_hook
-hooks_libc_hook
-iaalloc
-ialloc
-iallocztm
-iarena_cleanup
-idalloc
-idalloctm
-iealloc
-index2size
-index2size_compute
-index2size_lookup
-index2size_tab
-ipalloc
-ipalloct
-ipallocztm
-iralloc
-iralloct
-iralloct_realign
-isalloc
-isdalloct
-isthreaded
-ivsalloc
-ixalloc
-jemalloc_postfork_child
-jemalloc_postfork_parent
-jemalloc_prefork
-large_dalloc
-large_dalloc_finish
-large_dalloc_junk
-large_dalloc_maybe_junk
-large_dalloc_prep_junked_locked
-large_malloc
-large_palloc
-large_prof_tctx_get
-large_prof_tctx_reset
-large_prof_tctx_set
-large_ralloc
-large_ralloc_no_move
-large_salloc
-lg_floor
-lg_prof_sample
-malloc_cprintf
-malloc_getcpu
-malloc_initialized
-malloc_mutex_prof_data_reset
-malloc_mutex_assert_not_owner
-malloc_mutex_assert_owner
-malloc_mutex_boot
-malloc_mutex_init
-malloc_mutex_lock
-malloc_mutex_lock_final
-malloc_mutex_lock_slow
-malloc_mutex_postfork_child
-malloc_mutex_postfork_parent
-malloc_mutex_prefork
-malloc_mutex_trylock
-malloc_mutex_trylock_final
-malloc_mutex_unlock
-malloc_printf
-malloc_slow
-malloc_snprintf
-malloc_strtoumax
-malloc_tsd_boot0
-malloc_tsd_boot1
-malloc_tsd_cleanup_register
-malloc_tsd_dalloc
-malloc_tsd_malloc
-malloc_vcprintf
-malloc_vsnprintf
-malloc_write
-mutex_owner_stats_update
-narenas_auto
-narenas_total_get
-ncpus
-nhbins
-nstime_add
-nstime_compare
-nstime_copy
-nstime_divide
-nstime_idivide
-nstime_imultiply
-nstime_init
-nstime_init2
-nstime_monotonic
-nstime_msec
-nstime_ns
-nstime_nsec
-nstime_sec
-nstime_subtract
-nstime_update
-opt_abort
-opt_dirty_decay_time
-opt_muzzy_decay_time
-opt_dss
-opt_junk
-opt_junk_alloc
-opt_junk_free
-opt_lg_prof_interval
-opt_lg_prof_sample
-opt_lg_tcache_max
-opt_narenas
-opt_prof
-opt_prof_accum
-opt_prof_active
-opt_prof_final
-opt_prof_gdump
-opt_prof_leak
-opt_prof_prefix
-opt_prof_thread_active_init
-opt_stats_print
-opt_tcache
-opt_utrace
-opt_xmalloc
-opt_zero
-pages_boot
-pages_commit
-pages_decommit
-pages_huge
-pages_map
-pages_nohuge
-pages_purge_forced
-pages_purge_lazy
-pages_unmap
-percpu_arena_choose
-percpu_arena_ind_limit
-percpu_arena_update
-pind2sz
-pind2sz_compute
-pind2sz_lookup
-pind2sz_tab
-pow2_ceil_u32
-pow2_ceil_u64
-pow2_ceil_zu
-prng_lg_range_u32
-prng_lg_range_u64
-prng_lg_range_zu
-prng_range_u32
-prng_range_u64
-prng_range_zu
-prng_state_next_u32
-prng_state_next_u64
-prng_state_next_zu
-prof_accum_add
-prof_accum_cancel
-prof_accum_init
-prof_active
-prof_active_get
-prof_active_get_unlocked
-prof_active_set
-prof_alloc_prep
-prof_alloc_rollback
-prof_backtrace
-prof_boot0
-prof_boot1
-prof_boot2
-prof_bt_count
-prof_cnt_all
-prof_dump_header
-prof_dump_open
-prof_free
-prof_free_sampled_object
-prof_gdump
-prof_gdump_get
-prof_gdump_get_unlocked
-prof_gdump_set
-prof_gdump_val
-prof_idump
-prof_interval
-prof_lookup
-prof_malloc
-prof_malloc_sample_object
-prof_mdump
-prof_postfork_child
-prof_postfork_parent
-prof_prefork0
-prof_prefork1
-prof_realloc
-prof_reset
-prof_sample_accum_update
-prof_sample_threshold_update
-prof_tctx_get
-prof_tctx_reset
-prof_tctx_set
-prof_tdata_cleanup
-prof_tdata_count
-prof_tdata_get
-prof_tdata_init
-prof_tdata_reinit
-prof_thread_active_get
-prof_thread_active_init_get
-prof_thread_active_init_set
-prof_thread_active_set
-prof_thread_name_get
-prof_thread_name_set
-psz2ind
-psz2u
-rtree_clear
-rtree_ctx_data_init
-rtree_delete
-rtree_extent_read
-rtree_extent_szind_read
-rtree_leaf_alloc
-rtree_leaf_dalloc
-rtree_leaf_elm_acquire
-rtree_leaf_elm_bits_extent_get
-rtree_leaf_elm_bits_locked_get
-rtree_leaf_elm_bits_read
-rtree_leaf_elm_bits_slab_get
-rtree_leaf_elm_bits_szind_get
-rtree_leaf_elm_extent_read
-rtree_leaf_elm_extent_write
-rtree_leaf_elm_lookup
-rtree_leaf_elm_lookup_hard
-rtree_leaf_elm_release
-rtree_leaf_elm_slab_read
-rtree_leaf_elm_slab_write
-rtree_leaf_elm_szind_read
-rtree_leaf_elm_szind_slab_update
-rtree_leaf_elm_szind_write
-rtree_leaf_elm_witness_access
-rtree_leaf_elm_witness_acquire
-rtree_leaf_elm_witness_release
-rtree_leaf_elm_write
-rtree_leafkey
-rtree_new
-rtree_node_alloc
-rtree_node_dalloc
-rtree_read
-rtree_subkey
-rtree_szind_read
-rtree_szind_slab_read
-rtree_szind_slab_update
-rtree_write
-s2u
-s2u_compute
-s2u_lookup
-sa2u
-set_errno
-size2index
-size2index_compute
-size2index_lookup
-size2index_tab
-spin_adaptive
-stats_print
-tcache_alloc_easy
-tcache_alloc_large
-tcache_alloc_small
-tcache_alloc_small_hard
-tcache_arena_associate
-tcache_arena_reassociate
-tcache_bin_flush_large
-tcache_bin_flush_small
-tcache_bin_info
-tcache_boot
-tcache_cleanup
-tcache_create_explicit
-tcache_dalloc_large
-tcache_dalloc_small
-tcache_data_init
-tcache_enabled_get
-tcache_enabled_set
-tcache_event
-tcache_event_hard
-tcache_flush
-tcache_get
-tcache_maxclass
-tcache_prefork
-tcache_postfork_child
-tcache_postfork_parent
-tcache_salloc
-tcache_stats_merge
-tcaches
-tcaches_create
-tcaches_destroy
-tcaches_flush
-tcaches_get
-ticker_copy
-ticker_init
-ticker_read
-ticker_tick
-ticker_ticks
-tsd_arena_get
-tsd_arena_set
-tsd_arenap_get
-tsd_arenas_tdata_bypassp_get
-tsd_arenas_tdata_get
-tsd_arenas_tdata_set
-tsd_arenas_tdatap_get
-tsd_boot
-tsd_boot0
-tsd_boot1
-tsd_booted
-tsd_booted_get
-tsd_cleanup
-tsd_cleanup_wrapper
-tsd_fetch
-tsd_fetch_impl
-tsd_fetch_slow
-tsd_get
-tsd_get_allocates
-tsd_iarena_get
-tsd_iarena_set
-tsd_iarenap_get
-tsd_initialized
-tsd_init_check_recursion
-tsd_init_finish
-tsd_init_head
-tsd_narenas_tdata_get
-tsd_narenas_tdata_set
-tsd_narenas_tdatap_get
-tsd_reentrancy_level_get
-tsd_reentrancy_level_set
-tsd_reentrancy_levelp_get
-tsd_slow_update
-tsd_wrapper_get
-tsd_wrapper_set
-tsd_nominal
-tsd_prof_tdata_get
-tsd_prof_tdata_set
-tsd_prof_tdatap_get
-tsd_rtree_ctx
-tsd_rtree_ctxp_get
-tsd_rtree_leaf_elm_witnessesp_get
-tsd_set
-tsd_tcache_enabled_get
-tsd_tcache_enabled_set
-tsd_tcache_enabledp_get
-tsd_tcache_get
-tsd_tcache_set
-tsd_tcachep_get
-tsd_thread_allocated_get
-tsd_thread_allocated_set
-tsd_thread_allocatedp_get
-tsd_thread_deallocated_get
-tsd_thread_deallocated_set
-tsd_thread_deallocatedp_get
-tsd_tls
-tsd_tsd
-tsd_tsdn
-tsd_witness_fork_get
-tsd_witness_fork_set
-tsd_witness_forkp_get
-tsd_witnessesp_get
-tsdn_fetch
-tsdn_null
-tsdn_rtree_ctx
-tsdn_tsd
-witness_assert_depth
-witness_assert_depth_to_rank
-witness_assert_lockless
-witness_assert_not_owner
-witness_assert_owner
-witness_depth_error
-witness_init
-witness_lock
-witness_lock_error
-witness_not_owner_error
-witness_owner
-witness_owner_error
-witness_postfork_child
-witness_postfork_parent
-witness_prefork
-witness_unlock
-witnesses_cleanup
-zone_register