bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bug in linker for Win32.


From: Nick Clifton
Subject: Re: Bug in linker for Win32.
Date: Tue, 16 Dec 2003 11:48:18 +0000
User-agent: Gnus/5.1001 (Gnus v5.10.1) Emacs/21.2 (gnu/linux)

Hi Eric,

>            Anyways, as best I can tell it was the comment formatting that
>    was out of spec.  I have fixed that plus the problem of obj files
>    getting renamed.  If there is something else I am missing, feel free
>    to let me know, or point me at the current coding standard.

I think I an has already pointed out most of the formatting problems
to you.  I had a go at applying your patch and tidying it up slightly
and this is what I ended up with:

  {
    int is_ms_arch = 0;
    bfd *cur_arch = 0;
    lang_input_statement_type *is2;
    lang_input_statement_type *is3;

    /* Careful - this is a shell script.  Watch those dollar signs! */
    /* Microsoft import libraries have every member named the same,
       and not in the right order for us to link them correctly.  We
       must detect these and rename the members so that they'll link
       correctly.  There are three types of objects: the head, the
       thunks, and the sentinel(s).  The head is easy; it's the one
       with idata2.  We assume that the sentinels won't have relocs,
       and the thunks will.  It's easier than checking the symbol
       table for external references.  */
    LANG_FOR_EACH_INPUT_STATEMENT (is)
      {
        if (is->the_bfd->my_archive)
          {
            char *pnt;
            bfd *arch = is->the_bfd->my_archive;

            if (cur_arch != arch)
              {
                cur_arch = arch;
                is_ms_arch = 1;

                for (is3 = is;
                     is3 && is3->the_bfd->my_archive == arch;
                     is3 = (lang_input_statement_type *) is3->next)
                  {
                    /* A MS dynamic import library can also contain static
                       members, so look for the first element with a .dll
                       extension, and use that for the remainder of the
                       comparisons.  */
                    pnt = strrchr (is3->the_bfd->filename, '.');
                    if (pnt != NULL && strcmp (pnt, ".dll") != 0)
                      continue;
                  }

                /* OK, found one.  Now look to see if the remaining
                   (dynamic import) members use the same name.  */
                for (is2 = is;
                     is2 && is2->the_bfd->my_archive == arch;
                     is2 = (lang_input_statement_type *) is2->next)
                  {
                    /* Skip static members, ie anything with a .obj
                       extension.  */
                    pnt = strrchr (is2->the_bfd->filename, '.');
                    if (pnt != NULL && strcmp (pnt, ".obj") == 0)
                      continue;

                    if (strcmp (is3->the_bfd->filename,
                                is2->the_bfd->filename))
                      {
                        is_ms_arch = 0;
                        break;
                      }
                  }

                if (is3 == NULL)
                  is_ms_arch = 0;
              }

            /* This fragment might have come from an .obj file in a Microsoft
               import, and not an actual import record. If this is the case,
               then leave the filename alone.  */
            pnt = strrchr (is->the_bfd->filename, '.');

            if (is_ms_arch && (strcmp (pnt, ".dll") == 0))
              {

There appeared to be a bit of confusion with an extra "break"
statement at the end of your patch, but I think that I have done the
right thing.  (BTW your mailer is wrapping text at column 80 which is
breaking up the integrity of the patch).

Whilst doing this it occurred to me that the code could be tightened
up if we can be sure that *all* dynamic members of the library will
have the .dll extension.  Can we make this assumption?  If so then the
second part of the name scanning code could be changed to:

                /* OK, found one.  Now look to see if the remaining
                   (dynamic import) members use the same name.  */
                for (is2 = is3 ? is3->next ? NULL;
                     is2 && is2->the_bfd->my_archive == arch;
                     is2 = (lang_input_statement_type *) is2->next)
                  {
                    /* Skip static members, ie anything that does not
                       have the .dll extension.  */
                    pnt = strrchr (is2->the_bfd->filename, '.');
                    if (pnt == NULL || strcmp (pnt, ".dll"))
                      continue;

                    if (strcmp (is3->the_bfd->filename,
                                is2->the_bfd->filename))
                      {
                        is_ms_arch = 0;
                        break;
                      }
                  }

ie starting with the element after the one found at is3, and skipping
everything that does not have a .dll extension.

What do you think ?

Cheers
        Nick
        





reply via email to

[Prev in Thread] Current Thread [Next in Thread]