This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Glibc 2.5 - dlsym issue in threaded app.


> -----Original Message-----
> From: patofiero@gmail.com [mailto:patofiero@gmail.com] On Behalf Of
> Carlos O'Donell
>
> The GLIBC version checks are completely unnecessary. Create a static
> buffer of N bytes, and return references to this buffer on a first
> come first serve basis, clearly the first calloc call is going to be
> in the resolution of the next calloc call.

There already was a code with 16 bytes from another guys
who worked on this a long time ago.
I spent some time to get to the bottleneck of the problem.
Anyway, now I have:

...
const int extra_mem_size = 20;
static char extra_mem[extra_mem_size];
...

//-----------------------------------------------------------------------------

void * calloc(size_t num, size_t sz)
{
        static bool memUsed; // Counting on default initialization to 0

        if (!memUsed)
        {
                if(sz > extra_mem_size) {
                        printf("ERROR: calloc static buffer issue!!!\n");
                        printf("Check size of dl_action_result structure.\n");
                        abort();
                }

                memUsed = true;
                memset(extra_mem, 0, sz);
                return (void *) extra_mem;
        };
...

Thanks for your hints.

V.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]