学逆向论坛

找回密码
立即注册

只需一步,快速开始

发新帖

2万

积分

41

好友

1157

主题
发表于 2020-9-2 09:46:52 | 查看: 4739| 回复: 0

相关题目:

微观结构chunk
在程序的执行过程中,我们称由 malloc 申请的内存为 chunk 。
这块内存在 ptmalloc 内部用 malloc_chunk 结构体来表示。
当程序申请的 chunk 被 free 后,会被加入到相应的空闲管理列表中。
malloc_chunk 的结构如下:
/*
  This struct declaration is misleading (but accurate and necessary).
  It declares a "view" into memory allowing access to necessary
  fields at known offsets from a given base. See explanation below.
  */
  struct malloc_chunk {
  INTERNAL_SIZE_T      prev_size;  /* Size of previous chunk (if free).  */
  INTERNAL_SIZE_T      size;       /* Size in bytes, including overhead. */
  struct malloc_chunk* fd;         /* double links -- used only if free. */
  struct malloc_chunk* bk;
  /* Only used for large blocks: pointer to next larger size.  */
  struct malloc_chunk* fd_nextsize; /* double links -- used only if free. */
  struct malloc_chunk* bk_nextsize;
  };

一般来说,size_t 在 64 位中是 64 位(8B)无符号整数,32 位中是 32 位(4B)无符号整数。
  • prev_size, 如果该 chunk 的物理相邻的前一地址 chunk是空闲的话,那该字段记录的是前一个 chunk 的大小。否则,该字段可以用来存储物理相邻的前一个 chunk 的数据。这里的前一 chunk 指的是较低地址的 chunk
  • size ,该 chunk 的大小,大小必须是 2 * SIZE_SZ 的整数倍。如果申请的内存大小不是 2 * SIZE_SZ 的整数倍,会被转换满足大小的最小的 2 * SIZE_SZ 的倍数。32 位系统中,SIZE_SZ 是 4;64 位系统中,SIZE_SZ 是 8。 该字段的低三个比特位对 chunk 的大小没有影响,它们从高到低分别表示
  • NON_MAIN_ARENA,记录当前 chunk 是否不属于主线程,1 表示不属于,0 表示属于。
  • IS_MAPPED,记录当前 chunk 是否是由 mmap 分配的。
  • PREV_INUSE,记录前一个 chunk 块是否被分配。一般来说,堆中第一个被分配的内存块的 size 字段的 P 位都会被设置为 1,以便于防止访问前面的非法内存。当一个 chunk 的 size 的 P 位为 0 时,我们能通过 prev_size 字段来获取上一个 chunk 的大小以及地址。这也方便进行空闲 chunk 之间的合并。
  • fd,bk。 chunk 处于分配状态时,从 fd 字段开始是用户的数据。chunk 空闲时,会被添加到对应的空闲管理链表中,其字段的含义如下
  • fd 指向下一个(非物理相邻)空闲的 chunk
  • bk 指向上一个(非物理相邻)空闲的 chunk
  • 通过 fd 和 bk 可以将空闲的 chunk 块加入到空闲的 chunk 块链表进行统一管理
  • fd_nextsize, bk_nextsize,也是只有 chunk 空闲的时候才使用,不过其用于较大的 chunk(large chunk)。
  • fd_nextsize 指向前一个与当前 chunk 大小不同的第一个空闲块,不包含 bin 的头指针。
  • bk_nextsize 指向后一个与当前 chunk 大小不同的第一个空闲块,不包含 bin 的头指针。
  • 一般空闲的 large chunk 在 fd 的遍历顺序中,按照由大到小的顺序排列。这样做可以避免在寻找合适 chunk 时挨个遍历。
一个已经分配的 chunk 的样子如下。我们称前两个字段称为 chunk header,后面的部分称为 user data。每次 malloc 申请得到的内存指针,其实指向 user data 的起始处。(mem)
当一个 chunk 处于使用状态时,它的下一个 chunk 的 prev_size 域无效,所以下一个 chunk 的该部分也可以被当前 chunk 使用。这就是 chunk 中的空间复用。
使用时的chunk:

堆相关数据结构

堆相关数据结构
释放时的chunk:

堆相关数据结构

堆相关数据结构
可以发现,如果一个 chunk 处于 free 状态,那么会有两个位置记录其相应的大小
  • 本身的 size 字段会记录,
  • 它后面的 chunk 会记录。
一般情况下,物理相邻的两个空闲 chunk 会被合并为一个 chunk 。堆管理器会通过 prev_size 字段以及 size 字段合并两个物理相邻的空闲 chunk 块。
bin概述
ptmalloc 采用分箱式方法对空闲的 chunk 进行管理。
首先,它会根据空闲的 chunk 的大小以及使用状态将 chunk 初步分为 4 类:fast bins,small bins,large bins,unsorted bin,相似大小的 chunk 会用双向链表链接起来。
对于 small bins,large bins,unsorted bin 来说,ptmalloc 将它们维护在同一个数组中。这些 bin 对应的数据结构在 malloc_state 中,如下
#define NBINS 128
  /* Normal bins packed as described above */
  mchunkptr bins[ NBINS * 2 - 2 ];

一个 bin 相当于一个 chunk 链表,存储头节点 chunk 的时候仅仅只需要存储头节点 chunk 的 fd 和 bk,而其中的 prev_size 与 size 字段被重用为另一个 bin 的头节点的 fd 与 bk,这样可以节省空间,并提高可用性。(具体怎么重用没咋看懂,总之,bin 表头的 chunk 头节点 的 prev_size 与 size 字段不能随便修改,因为这两个字段是其它 bin 表头 chunk 的 fd 和 bk 字段。)
数组中的 bin 依次介绍如下:
  • 第一个为 unsorted bin,字如其面,这里面的 chunk 没有进行排序,存储的 chunk 比较杂。
  • 索引从 2 到 63 的 bin 称为 small bin,同一个 small bin 链表中的 chunk 的大小相同。两个相邻索引的 small bin 链表中的 chunk 大小相差的字节数为2 个机器字长,即 32 位相差 8 字节,64 位相差 16 字节。
  • small bins 后面的 bin 被称作 large bins。large bins 中的每一个 bin 都包含一定范围内的 chunk,其中的 chunk 按 fd 指针的顺序从大到小排列。相同大小的 chunk 同样按照最近使用顺序排列。
此外,ptmalloc 为了提高分配的速度,会把一些小的 chunk 放到 fast bins 的容器内。而且,fastbin 容器中的 chunk 的使用标记总是被置位的,所以不满足上面的原则。
bin通用宏:
typedef struct malloc_chunk *mbinptr;
  /* addressing -- note that bin_at(0) does not exist */
  #define bin_at(m, i)                                                           \
  (mbinptr)(((char *) &((m)->bins[ ((i) -1) * 2 ])) -                        \
  offsetof(struct malloc_chunk, fd))
  /* analog of ++bin */
  //获取下一个bin的地址
  #define next_bin(b) ((mbinptr)((char *) (b) + (sizeof(mchunkptr) << 1)))
  /* Reminders about list directionality within bins */
  // 这两个宏可以用来遍历bin
  // 获取 bin 的位于链表头的 chunk
  #define first(b) ((b)->fd)
  // 获取 bin 的位于链表尾的 chunk
  #define last(b) ((b)->bk)

fast bin
ptmalloc 中专门设计了 fast bin,对应的变量就是 malloc state 中的 fastbinsY
为了更加高效地利用 fast bin,glibc 采用单向链表对其中的每个 bin 进行组织,并且每个 bin 采取 LIFO 策略。
默认情况下(32 位系统为例), fastbin 中默认支持最大的 chunk 的数据空间大小为 64 字节。
定义如下:
#define NFASTBINS (fastbin_index(request2size(MAX_FAST_SIZE)) + 1)
  #ifndef DEFAULT_MXFAST
  #define DEFAULT_MXFAST (64 * SIZE_SZ / 4)
  #endif
  /* The maximum fastbin request size we support */
  #define MAX_FAST_SIZE (80 * SIZE_SZ / 4)
  /*
  Since the lowest 2 bits in max_fast don't matter in size comparisons,
  they are used as flags.
  */
  /*
  FASTCHUNKS_BIT held in max_fast indicates that there are probably
  some fastbin chunks. It is set true on entering a chunk into any
  fastbin, and cleared only in malloc_consolidate.
  The truth value is inverted so that have_fastchunks will be true
  upon startup (since statics are zero-filled), simplifying
  initialization checks.
  */
  //判断分配区是否有 fast bin chunk,1表示没有
  #define FASTCHUNKS_BIT (1U)
  #define have_fastchunks(M) (((M)->flags & FASTCHUNKS_BIT) == 0)
  #define clear_fastchunks(M) catomic_or(&(M)->flags, FASTCHUNKS_BIT)
  #define set_fastchunks(M) catomic_and(&(M)->flags, ~FASTCHUNKS_BIT)
  /*
  NONCONTIGUOUS_BIT indicates that MORECORE does not return contiguous
  regions.  Otherwise, contiguity is exploited in merging together,
  when possible, results from consecutive MORECORE calls.
  The initial value comes from MORECORE_CONTIGUOUS, but is
  changed dynamically if mmap is ever used as an sbrk substitute.
  */
  // MORECORE是否返回连续的内存区域。
  // 主分配区中的MORECORE其实为sbr(),默认返回连续虚拟地址空间
  // 非主分配区使用mmap()分配大块虚拟内存,然后进行切分来模拟主分配区的行为
  // 而默认情况下mmap映射区域是不保证虚拟地址空间连续的,所以非主分配区默认分配非连续虚拟地址空间。
  #define NONCONTIGUOUS_BIT (2U)
  #define contiguous(M) (((M)->flags & NONCONTIGUOUS_BIT) == 0)
  #define noncontiguous(M) (((M)->flags & NONCONTIGUOUS_BIT) != 0)
  #define set_noncontiguous(M) ((M)->flags |= NONCONTIGUOUS_BIT)
  #define set_contiguous(M) ((M)->flags &= ~NONCONTIGUOUS_BIT)
  /* ARENA_CORRUPTION_BIT is set if a memory corruption was detected on the
  arena.  Such an arena is no longer used to allocate chunks.  Chunks
  allocated in that arena before detecting corruption are not freed.  */
  #define ARENA_CORRUPTION_BIT (4U)
  #define arena_is_corrupt(A) (((A)->flags & ARENA_CORRUPTION_BIT))
  #define set_arena_corrupt(A) ((A)->flags |= ARENA_CORRUPTION_BIT)
  /*
  Set value of max_fast.
  Use impossibly small value if 0.
  Precondition: there are no existing fastbin chunks.
  Setting the value clears fastchunk bit but preserves noncontiguous bit.
  */
  #define set_max_fast(s)                                                        \
  global_max_fast =                                                          \
  (((s) == 0) ? SMALLBIN_WIDTH : ((s + SIZE_SZ) & ~MALLOC_ALIGN_MASK))
  #define get_max_fast() global_max_fast

ptmalloc 默认情况下会调用 set_max_fast(s) 将全局变量 global_max_fast 设置为 DEFAULT_MXFAST,也就是设置 fast bins 中 chunk 的最大值。当 MAX_FAST_SIZE 被设置为 0 时,系统就不会支持 fastbin 。而把这个值改成很大的数(例如使用unsorted bin attck),所有被释放的chunk都会链入fastbin了。
需要特别注意的是,fastbin 范围的 chunk 的 inuse 始终被置为 1。因此它们不会和其它被释放的 chunk 合并。
small bin
small bins 中每个 chunk 的大小与其所在的 bin 的 index 的关系为:chunk_size = 2 * SIZE_SZ *index,具体如下:
small bins 中一共有 62 个循环双向链表,每个链表中存储的 chunk 大小都一致。
small bins 中每个 bin 对应的链表采用 FIFO 的规则
相关宏:
#define NSMALLBINS 64
  #define SMALLBIN_WIDTH MALLOC_ALIGNMENT
  // 是否需要对small bin的下标进行纠正
  #define SMALLBIN_CORRECTION (MALLOC_ALIGNMENT > 2 * SIZE_SZ)
  #define MIN_LARGE_SIZE ((NSMALLBINS - SMALLBIN_CORRECTION) * SMALLBIN_WIDTH)
  //判断chunk的大小是否在small bin范围内
  #define in_smallbin_range(sz)                                                  \
  ((unsigned long) (sz) < (unsigned long) MIN_LARGE_SIZE)
  // 根据chunk的大小得到small bin对应的索引。
  #define smallbin_index(sz)                                                     \
  ((SMALLBIN_WIDTH == 16 ? (((unsigned) (sz)) >> 4)                          \
  : (((unsigned) (sz)) >> 3)) +                       \
  SMALLBIN_CORRECTION)

large bin
large bins 中一共包括 63 个 bin,每个 bin 中的 chunk 的大小不一致,而是处于一定区间范围内。此外,这 63 个 bin 被分成了 6 组,每组 bin 中的 chunk 大小之间的公差一致,具体如下:
以 32 位平台的 large bin 为例,第一个 large bin 的起始 chunk 大小为 512 字节,位于第一组,所以该 bin 可以存储的 chunk 的大小范围为 [512,512+64)。
宏:
#define largebin_index_32(sz)                                                  \
  (((((unsigned long) (sz)) >> 6) <= 38)                                     \
  ? 56 + (((unsigned long) (sz)) >> 6)                                  \
  : ((((unsigned long) (sz)) >> 9) <= 20)                               \
  ? 91 + (((unsigned long) (sz)) >> 9)                            \
  : ((((unsigned long) (sz)) >> 12) <= 10)                        \
  ? 110 + (((unsigned long) (sz)) >> 12)                    \
  : ((((unsigned long) (sz)) >> 15) <= 4)                   \
  ? 119 + (((unsigned long) (sz)) >> 15)              \
  : ((((unsigned long) (sz)) >> 18) <= 2)             \
  ? 124 + (((unsigned long) (sz)) >> 18)        \
  : 126)
  #define largebin_index_32_big(sz)                                              \
  (((((unsigned long) (sz)) >> 6) <= 45)                                     \
  ? 49 + (((unsigned long) (sz)) >> 6)                                  \
  : ((((unsigned long) (sz)) >> 9) <= 20)                               \
  ? 91 + (((unsigned long) (sz)) >> 9)                            \
  : ((((unsigned long) (sz)) >> 12) <= 10)                        \
  ? 110 + (((unsigned long) (sz)) >> 12)                    \
  : ((((unsigned long) (sz)) >> 15) <= 4)                   \
  ? 119 + (((unsigned long) (sz)) >> 15)              \
  : ((((unsigned long) (sz)) >> 18) <= 2)             \
  ? 124 + (((unsigned long) (sz)) >> 18)        \
  : 126)
  // XXX It remains to be seen whether it is good to keep the widths of
  // XXX the buckets the same or whether it should be scaled by a factor
  // XXX of two as well.
  #define largebin_index_64(sz)                                                  \
  (((((unsigned long) (sz)) >> 6) <= 48)                                     \
  ? 48 + (((unsigned long) (sz)) >> 6)                                  \
  : ((((unsigned long) (sz)) >> 9) <= 20)                               \
  ? 91 + (((unsigned long) (sz)) >> 9)                            \
  : ((((unsigned long) (sz)) >> 12) <= 10)                        \
  ? 110 + (((unsigned long) (sz)) >> 12)                    \
  : ((((unsigned long) (sz)) >> 15) <= 4)                   \
  ? 119 + (((unsigned long) (sz)) >> 15)              \
  : ((((unsigned long) (sz)) >> 18) <= 2)             \
  ? 124 + (((unsigned long) (sz)) >> 18)        \
  : 126)
  #define largebin_index(sz)                                                     \
  (SIZE_SZ == 8 ? largebin_index_64(sz) : MALLOC_ALIGNMENT == 16             \
  ? largebin_index_32_big(sz)    \
  : largebin_index_32(sz))

unsorted bin
glibc描述:
/*
  Unsorted chunks
  All remainders from chunk splits, as well as all returned chunks,
  are first placed in the "unsorted" bin. They are then placed
  in regular bins after malloc gives them ONE chance to be used before
  binning. So, basically, the unsorted_chunks list acts as a queue,
  with chunks being placed on it in free (and malloc_consolidate),
  and taken off (to be either used or placed in bins) in malloc.
  The NON_MAIN_ARENA flag is never set for unsorted chunks, so it
  does not have to be taken into account in size comparisons.
  */

  • 当一个较大的 chunk 被分割成两半后,如果剩下的部分大于 MINSIZE,就会被放到 unsorted bin 中。
  • 释放一个不属于 fast bin 的 chunk,并且该 chunk 不和 top chunk 紧邻时,该 chunk 会被首先放到 unsorted bin 中。
此外,Unsorted Bin 在使用的过程中,采用的遍历顺序是 FIFO 。
top chunk
程序第一次进行 malloc 的时候,heap 会被分为两块,一块给用户,剩下的那块就是 top chunk。
其实,所谓的 top chunk 就是处于当前堆的物理地址最高的 chunk。
这个 chunk 不属于任何一个 bin,它的作用在于当所有的 bin 都无法满足用户请求的大小时,如果其大小不小于指定的大小,就进行分配,并将剩下的部分作为新的 top chunk。否则,就对 heap 进行扩展后再进行分配。在 main arena 中通过 sbrk 扩展 heap,而在 thread arena 中通过 mmap 分配新的 heap。
需要注意的是,top chunk 的 prev_inuse 比特位始终为 1,否则其前面的 chunk 就会被合并到 top chunk 中。
last remainder
在用户使用 malloc 请求分配内存时,ptmalloc2 找到的 chunk 可能并不和申请的内存大小一致,这时候就将分割之后的剩余部分称之为 last remainder chunk ,unsort bin 也会存这一块。top chunk 分割剩下的部分不会作为 last remainder.
宏观结构arena
对于不同系统,arena 数量的约束如下:
For 32 bit systems:      Number of arena = 2 * number of cores.
For 64 bit systems:      Number of arena = 8 * number of cores.
不是每一个线程都会有对应的 arena,当线程数大于核数的二倍(超线程技术)时,就必然有线程处于等待状态,所以没有必要为每个线程分配一个 arena。
与 thread 不同的是,main_arena 并不在申请的 heap 中,而是一个全局变量,在 libc.so 的数据段。
heap_info
程序刚开始执行时,每个线程是没有 heap 区域的。当其申请内存时,就需要一个结构来记录对应的信息,而 heap_info 的作用就是这个。
此外,一般申请的 heap 是不连续的,因此需要记录不同 heap 之间的链接结构。
该数据结构是专门为从 Memory Mapping Segment 处申请的内存准备的,即为非主线程准备的。
主线程可以通过 sbrk() 函数扩展 program break location 获得(直到触及 Memory Mapping Segment),只有一个 heap,没有 heap_info 数据结构。
heap_info 的主要结构如下:
#define HEAP_MIN_SIZE (32 * 1024)
  #ifndef HEAP_MAX_SIZE
  # ifdef DEFAULT_MMAP_THRESHOLD_MAX
  #  define HEAP_MAX_SIZE (2 * DEFAULT_MMAP_THRESHOLD_MAX)
  # else
  #  define HEAP_MAX_SIZE (1024 * 1024) /* must be a power of two */
  # endif
  #endif
  /* HEAP_MIN_SIZE and HEAP_MAX_SIZE limit the size of mmap()ed heaps
  that are dynamically created for multi-threaded programs.  The
  maximum size must be a power of two, for fast determination of
  which heap belongs to a chunk.  It should be much larger than the
  mmap threshold, so that requests with a size just below that
  threshold can be fulfilled without creating too many heaps.  */
  /***************************************************************************/
  /* A heap is a single contiguous memory region holding (coalesceable)
  malloc_chunks.  It is allocated with mmap() and always starts at an
  address aligned to HEAP_MAX_SIZE.  */
  typedef struct _heap_info
  {
  mstate ar_ptr; /* Arena for this heap. */
  struct _heap_info *prev; /* Previous heap. */
  size_t size;   /* Current size in bytes. */
  size_t mprotect_size; /* Size in bytes that has been mprotected
  PROT_READ|PROT_WRITE.  */
  /* Make sure the following data is properly aligned, particularly
  that sizeof (heap_info) + 2 * SIZE_SZ is a multiple of
  MALLOC_ALIGNMENT. */
  char pad[-6 * SIZE_SZ & MALLOC_ALIGN_MASK];
  } heap_info;

该结构主要是描述堆的基本信息,包括
  • 堆对应的 arena 的地址
  • 由于一个线程申请一个堆之后,可能会使用完,之后就必须得再次申请。因此,一个线程可能会有多个堆。prev 即记录了上一个 heap_info 的地址。这里可以看到每个堆的 heap_info 是通过单向链表进行链接的。
  • size 表示当前堆的大小
  • 最后一部分确保对齐
malloc_state
该结构用于管理堆,记录每个 arena 当前申请的内存的具体状态,比如说是否有空闲 chunk,有什么大小的空闲 chunk 等等。无论是 thread arena 还是 main arena,它们都只有一个 malloc state 结构。由于 thread 的 arena 可能有多个,malloc state 结构会在最新申请的 arena 中。
注意,main arena 的 malloc_state 并不是 heap segment 的一部分,而是一个全局变量,存储在 libc.so 的数据段。
其结构如下:
struct malloc_state {
  /* Serialize access.  */
  __libc_lock_define(, mutex);
  /* Flags (formerly in max_fast).  */
  int flags;
  /* Fastbins */
  mfastbinptr fastbinsY[ NFASTBINS ];
  /* Base of the topmost chunk -- not otherwise kept in a bin */
  mchunkptr top;
  /* The remainder from the most recent split of a small request */
  mchunkptr last_remainder;
  /* Normal bins packed as described above */
  mchunkptr bins[ NBINS * 2 - 2 ];
  /* Bitmap of bins, help to speed up the process of determinating if a given bin is definitely empty.*/
  unsigned int binmap[ BINMAPSIZE ];
  /* Linked list, points to the next arena */
  struct malloc_state *next;
  /* Linked list for free arenas.  Access to this field is serialized
  by free_list_lock in arena.c.  */
  struct malloc_state *next_free;
  /* Number of threads attached to this arena.  0 if the arena is on
  the free list.  Access to this field is serialized by
  free_list_lock in arena.c.  */
  INTERNAL_SIZE_T attached_threads;
  /* Memory allocated from the system in this arena.  */
  INTERNAL_SIZE_T system_mem;
  INTERNAL_SIZE_T max_system_mem;
  };

  • __libc_lock_define(, mutex);
  • 该变量用于控制程序串行访问同一个分配区,当一个线程获取了分配区之后,其它线程要想访问该分配区,就必须等待该线程分配完成后才能够使用。
  • flags
  • flags 记录了分配区的一些标志,比如 bit0 记录了分配区是否有 fast bin chunk ,bit1 标识分配区是否能返回连续的虚拟地址空间。具体如下
/*
  FASTCHUNKS_BIT held in max_fast indicates that there are probably
  some fastbin chunks. It is set true on entering a chunk into any
  fastbin, and cleared only in malloc_consolidate.
  The truth value is inverted so that have_fastchunks will be true
  upon startup (since statics are zero-filled), simplifying
  initialization checks.
  */
  #define FASTCHUNKS_BIT (1U)
  #define have_fastchunks(M) (((M)->flags & FASTCHUNKS_BIT) == 0)
  #define clear_fastchunks(M) catomic_or(&(M)->flags, FASTCHUNKS_BIT)
  #define set_fastchunks(M) catomic_and(&(M)->flags, ~FASTCHUNKS_BIT)
  /*
  NONCONTIGUOUS_BIT indicates that MORECORE does not return contiguous
  regions.  Otherwise, contiguity is exploited in merging together,
  when possible, results from consecutive MORECORE calls.
  The initial value comes from MORECORE_CONTIGUOUS, but is
  changed dynamically if mmap is ever used as an sbrk substitute.
  */
  #define NONCONTIGUOUS_BIT (2U)
  #define contiguous(M) (((M)->flags & NONCONTIGUOUS_BIT) == 0)
  #define noncontiguous(M) (((M)->flags & NONCONTIGUOUS_BIT) != 0)
  #define set_noncontiguous(M) ((M)->flags |= NONCONTIGUOUS_BIT)
  #define set_contiguous(M) ((M)->flags &= ~NONCONTIGUOUS_BIT)
  /* ARENA_CORRUPTION_BIT is set if a memory corruption was detected on the
  arena.  Such an arena is no longer used to allocate chunks.  Chunks
  allocated in that arena before detecting corruption are not freed.  */
  #define ARENA_CORRUPTION_BIT (4U)
  #define arena_is_corrupt(A) (((A)->flags & ARENA_CORRUPTION_BIT))
  #define set_arena_corrupt(A) ((A)->flags |= ARENA_CORRUPTION_BIT)

  • fastbinsY[NFASTBINS]
  • 存放每个 fast chunk 链表头部的指针
  • top
  • 指向分配区的 top chunk
  • last_reminder
  • 最新的 chunk 分割之后剩下的那部分
  • bins
  • 用于存储 unstored bin,small bins 和 large bins 的 chunk 链表。
  • binmap
  • ptmalloc 用一个 bit 来标识某一个 bin 中是否包含空闲 chunk 。


温馨提示:
1.如果您喜欢这篇帖子,请给作者点赞评分,点赞会增加帖子的热度,评分会给作者加学币。(评分不会扣掉您的积分,系统每天都会重置您的评分额度)。
2.回复帖子不仅是对作者的认可,还可以获得学币奖励,请尊重他人的劳动成果,拒绝做伸手党!
3.发广告、灌水回复等违规行为一经发现直接禁言,如果本帖内容涉嫌违规,请点击论坛底部的举报反馈按钮,也可以在【投诉建议】板块发帖举报。
论坛交流群:672619046

小黑屋|手机版|站务邮箱|学逆向论坛 ( 粤ICP备2021023307号 )|网站地图

GMT+8, 2024-4-27 02:42 , Processed in 0.130226 second(s), 40 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表