How does the libhugetlbfs library replace the memory allocation process with huge pages?

34 Views Asked by At

According to the document, "libhugetlbfs can be used to make an existing application use hugepages for all its malloc() calls". And it is done through LD_PRELOAD environment variable.

LD_PRELOAD=libhugetlbfs.so HUGETLB_MORECORE=yes ./a.out

According to this article, this is done by using LD_PRELOAD to override dynamically linked functions with the same name. But I couldn't find a function named malloc in the source code of libhugetlbfs (https://github.com/search?q=repo%3Alibhugetlbfs%2Flibhugetlbfs+malloc&type=code&p=1).

How does it hook and override the origin malloc?

0

There are 0 best solutions below