This is the mail archive of the gcc-patches@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]
Other format: [Raw text]

[lto] Fix merging of weak symbols


Thanks to Rafael for helping me track this one down and producing the
reduced test case.  Given a weak symbol in two object files, we were
incorrectly considering both instances to be a prevailing definition.

A test case for this is simple but requires multiple files, which we
still have not figured out, I will try to add that soon.  In the
meantime, this is tested by our internal builds and I will add the
list of testcases we should add to the LTO wiki to avoid losing track
of them.

The testcase is:

$ cat a.h
class foo
{
public:
  int bar ()
  {
    return 0;
  }
};

$ cat a.C
#include "a.h"

int
f (foo * a)
{
  return a->bar ();
}

$ cat b.C
#include "a.h"

int
g (foo * a)
{
  return a->bar ();
}

$ gcc/xgcc -Bgcc -fwhopr -c a.C
$ gcc/xgcc -Bgcc -fwhopr -c b.C
$ gcc/xgcc -Bgcc -shared -o liba.so a.o b.o -fwhopr
lto1: error: 'bar' has already been defined
collect2: gcc returned 1 exit status


Tested on x86.


Diego.


2008-10-22  Diego Novillo  <dnovillo@google.com>
            Rafael Espindola  <espindola@google.com>

        * lto-function-in.c (get_resolution): Handle weak
        definitions.
        (input_function_decl): Tidy.
        * lto/lto.c (lto_resolution_read): Tidy.
        * lto/lto-symtab.c (lto_symtab_prevailing_decl): Do not
        abort if RET is NULL.

Attachment: 20081022-fix-weak-merge.diff.txt
Description: Text document


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