[PATCH] ld/gold: Use mallinfo2 over mallinfo if available

Khem Raj raj.khem@gmail.com
Fri Mar 19 08:21:20 GMT 2021


On Fri, Mar 19, 2021 at 12:55 AM Martin Liška <mliska@suse.cz> wrote:
>
> On 3/18/21 11:09 PM, Khem Raj via Binutils wrote:
> > mallinfo has been deprecated in recently glibc releases raising
> > deprecated-declarations when used, mallinfo2 has been introduced instead
> > which could be used ahead of mallinfo provided platform supports it
>
> Hello.
>
> I support the change as the old mallinfo overflows at 2GB memory.
>
> ... snip...
> >
> > -#ifdef HAVE_MALLINFO
> > +#ifdef HAVE_MALLINFO2
> > +      struct mallinfo2 m = mallinfo2();
> > +      fprintf(stderr, _("%s: total space allocated by malloc: %lld bytes\n"),
> > +           program_name, static_cast<long long>(m.arena));
> > +#elif defined(HAVE_MALLINFO)
> >         struct mallinfo m = mallinfo();
> >         fprintf(stderr, _("%s: total space allocated by malloc: %lld bytes\n"),
> >             program_name, static_cast<long long>(m.arena));
> >
>
> What about making it more compact and not repeating the fprintf?

ok will send v2

> We have the following in the GCC compiler:
>
> #ifdef HAVE_MALLINFO2
>    #define MALLINFO_FN mallinfo2
> #else
>    #define MALLINFO_FN mallinfo
> #endif
> ...
>   fprintf (stderr, " {heap " PRsa (0) "}", SIZE_AMOUNT (MALLINFO_FN ().arena));
>
> Cheers,
> Martin


More information about the Binutils mailing list