https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61577

--- Comment #187 from Peter Bisroev <peter.bisroev at groundlabs dot com> ---
(In reply to dave.anglin from comment #183)
> On 2020-02-15 12:49 a.m., peter.bisroev at groundlabs dot com wrote:
> > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61577
> >
> > --- Comment #180 from Peter Bisroev <peter.bisroev at groundlabs dot com> 
> > ---
> > (In reply to dave.anglin from comment #177)
> >> On 2020-02-13 6:01 p.m., peter.bisroev at groundlabs dot com wrote:
> >>> I have tried playing around with weak using aCC, however even though it 
> >>> accepts
> >>> both attribute and pragma (and complains if you misspell "weak"), both 
> >>> compiler
> >>> and linker seem to ignore it. But I might have made some mistake there, 
> >>> will
> >>> double check tonight.
> >> Did you look at .s output?  You could also test a simple program with a 
> >> weak
> >> function
> >> in two objects.
> > Sorry Dave, not 100% sure what kind of test you are talking about. Something
> > like this?
> > ----------
> > // func0.cpp
> >
> > int func0(int) __attribute__((weak));
> > int func0(int arg) {
> >     return arg + 1;
> > }
> >
> > // main.cpp
> >
> > int func0(int) __attribute__((weak));
> > int func0(int arg) {
> >     return arg + 10;
> > }
> >
> > int main(int argc, char * argv[]) {
> >     return func0(argc);
> > }
> > ----------
> >
> Yes.  Does it link okay?

Hi Dave,

No it does not link, the error I get is "ld: Duplicate symbol "func0(int)" in
files test0.o and func0.o". However it links perfectly fine when compiled with
GCC.

I have attached the results of the test above and another basic C++ one using
an inline virtual method in attachment 47847. In there you will find three
directories for results with aCC, gcc 4-7-4 and gcc 4.7.4 built with
--enable-comdat.

Additionally, in each directory you will find a build.log of how exactly was
the test built, as well as *.objdump disassembly and other info and *.readelf
dumps.

I have not had a chance to look through these in great detail, will do this
later today, but some things I've noticed (not sure how important they are
yet):
- aCC seems to use PCREL21BI relocations while GCC PCREL21B.
- When objdumping C++ test1 for comdat enabled gcc, I get "objdump: test1
symbol number 48 references nonexistent SHT_SYMTAB_SHNDX section". 

Will come back to this a little later today.

Thanks!
--peter

Reply via email to