looking for malloc in shared library

  c++, linux, malloc

I have been trying to find references to malloc in a shared library, but I got results which I don’t fully understand. I have two libraries which are pretty similar, in one of them I see malloc referenced:

readelf -Ws mylib.so | grep malloc
   72: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND [email protected]_2.2.5 (2)
53916: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND malloc

The other doesn’t have it, all good so far. But if I compile with debug symbols and do readelf --debug-dump=info, I see malloc being referenced all over the place in both libs:

<1><31f72b>: Abbrev Number: 222 (DW_TAG_subprogram)
   <31f72d>   DW_AT_name        : (indirect string, offset: 0x2236cc4): malloc
   <31f731>   DW_AT_decl_file   : 319
   <31f733>   DW_AT_decl_line   : 539
   <31f735>   DW_AT_type        : <0x70ad>
   <31f739>   DW_AT_declaration : 1
   <31f739>   DW_AT_external    : 1

How to interpret this, is the lib statically linked against glibc?

Another question: any suggestion on a good way to trace heap allocations? They don’t have to be done via malloc I guess?

Source: Windows Questions C++

LEAVE A COMMENT