https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61577
--- Comment #194 from Peter Bisroev <peter.bisroev at groundlabs dot com> --- (In reply to dave.anglin from comment #193) > I presume that if you compile main.cc with g++, hello() becomes weak. You > could test with a second instance of hello. Yes, sorry forgot to mention that. When I compile with gcc hello() becomes weak as expected. One question though, what do you mean with the second instance of hello? > It is clear aCC doesn't support although I think HP as and ld do with some > caveats. HP's weak > support evolved from secondary definition symbols (sdef). This was never > well documented and > the use we make of these symbols on 32-bit pa came from looking at HP's > linker code. > > I'm thinking that the call to printf goes through PLT because it is resolved > in a shared library. This theory makes sense based on my testing so far. > The R_IA64_PCREL21B relocation works except for code size issues. HP ld > doesn't remove unnecessary > weak instances and for some reason it doesn't do calls to weak functions > through the PLT when they > aren't resolved in a shared library. > > So, I think we either need to use a long branch (brl) to weak functions or > we need to change the define > of MAKE_DECL_ONE_ONLY to avoid the use of weak. We can try replacing weak > functions with comdat > functions, etc. Currently, we have > > #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1) > > The latter is probably the better solution as it will result in smaller > code, but it's trickier. I'm not sure about > using brl in the 32-bit hpux runtime. > > Dave The comdat testing that I have performed in comment 181 and comment 185 by forcing the use of comdat with --enable-comdat definitely made things better as we got a significant reduction in PCREL21B linking errors. However some still remained. Is it because the use of --enable-comdat did not apply to all the code (such as libraries), or even when usage of comdat is forced, HP's ld still keeps unnecessary instances around? Thanks! --peter