This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


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

Re: An optimization bug in egcs 1.0.2?


> 
> 
> The code calls memcpy with overlapping objects.  That is undefined in
> ANSI C; use memmove instead.  (It also subtracts pointers to void so
> the authors presumably didn't care about ANSI C, but the misuse of
> memcpy is a real problem.)

It is from the dynamic linker in glibc 2. memcpy is safe there.
memcpy is used for optimization.

> 
> There may also be a bug in egcs in addition to the bug in the code.
> Can you generate a standalone test case with annotated assembly code?

I don't think there is a question on egcs. I don't want to spend
any more time on it since it has been fixed in glibc 2. If you really
want to look into it, I can do it when I find time.

> 
> 
> > if (imap->l_global)
> >   {
> >    /* This object is in the global scope list.  Remove it.  */
> >    struct link_map **tail = _dl_global_scope_end;
> >    do
> >      --tail;
> >     while (*tail != imap);
> >     --_dl_global_scope_end;
> >     memcpy (tail, tail + 1,
> >       (void *) _dl_global_scope_end -  (void *) tail);
> >     _dl_global_scope_end[0] = NULL;
> >     _dl_global_scope_end[1] = NULL;
> >   }
> 


-- 
H.J. Lu (hjl@gnu.org)


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