Bug 13229 - V2 of getsymbol linker plugin interface is not supported by GNU LD
Summary: V2 of getsymbol linker plugin interface is not supported by GNU LD
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.24
: P2 normal
Target Milestone: ---
Assignee: Alan Modra
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-27 23:52 UTC by Jan Hubicka
Modified: 2011-10-25 02:54 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
proposed patch (2.13 KB, patch)
2011-09-29 11:09 UTC, Alan Modra
Details | Diff
Revised patch with testsuite update (3.98 KB, patch)
2011-09-30 04:43 UTC, Alan Modra
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Hubicka 2011-09-27 23:52:22 UTC
Carry added gold plugin support for IRONLY_EXP resolution. It would be really cool to add gnu LD support soon.
Comment 1 Alan Modra 2011-09-29 11:09:08 UTC
Created attachment 5951 [details]
proposed patch

Jan, can you test that this behaves correctly?
Comment 2 Alan Modra 2011-09-29 11:12:59 UTC
Oh, and ignore the ld testsuite failures.  The plugin tests need updating.
Comment 3 Alan Modra 2011-09-30 04:43:57 UTC
Created attachment 5953 [details]
Revised patch with testsuite update

The previous patch had a missing break..
Comment 4 hubicka 2011-09-30 16:31:05 UTC
Hi,
I can build Mozilla with GNU LD with resulting binary being about the same size as gold's so it seems to be all fine.
Also the TLS problems are gone.

Thanks a lot!
Honza
Comment 5 hubicka 2011-09-30 17:10:55 UTC
> Hi,
> I can build Mozilla with GNU LD with resulting binary being about the same size
> as gold's so it seems to be all fine.
> Also the TLS problems are gone.

Actually I got fooled by gold sitting earlier on the search path.
Link still fails with the following error:
/abuild/jh/trunk-install/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../x86_64-unknown-linux-gnu/bin/ld: libxul.so: hidden symbol `_mm_load_si128' isn't defined
/abuild/jh/trunk-install/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../x86_64-unknown-linux-gnu/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status

It is curious becaue _mm_load_si128 is always inline and it should not be used.  Also it is not used by any of the linker plugin output,
it however appears in the original symbol tables as undefined symbol:
jh@evans:/abuild/jh/build-mozilla-new14/toolkit/library> grep _mm_load_si128 *.s
jh@evans:/abuild/jh/build-mozilla-new14/toolkit/library> grep _mm_load_si128 ./-lm.res
172 6129b4c0 UNDEF _Z14_mm_load_si128PKU8__vectorx
178 590a071d UNDEF _Z14_mm_load_si128PKU8__vectorx
557 7620c055 UNDEF _Z14_mm_load_si128PKU8__vectorx
974 314cd963 UNDEF _mm_load_si128

I guess Gold is just tolerant here and I would say that GNU LD should be too.
I will work out how this symbol appears in the symbol table.

IRONLY/IRONLY_EXP split seems to work as expected, so this is probably unrelated problem.

Honza

> 
> Thanks a lot!
> Honza
> 
> -- 
> Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
> ------- You are receiving this mail because: -------
> You reported the bug.
Comment 6 hubicka 2011-10-01 13:14:11 UTC
> I guess Gold is just tolerant here and I would say that GNU LD should be too.
> I will work out how this symbol appears in the symbol table.
Filled in as PR13244.

Honza
Comment 7 hubicka 2011-10-01 13:50:13 UTC
> http://sourceware.org/bugzilla/show_bug.cgi?id=13229
> 
> --- Comment #6 from hubicka at ucw dot cz 2011-10-01 13:14:11 UTC ---
> > I guess Gold is just tolerant here and I would say that GNU LD should be too.
> > I will work out how this symbol appears in the symbol table.
> Filled in as PR13244.
And built Mozilla with patch solving PR13244 at GCC side.  libxul builds and it is about
2% bigger than gold variant. I guess it is the gold's removal of equivalent functions.

So the patch works as expected.  What is the minimal binutils version supporting the V2 API?
(I would like to add info into gcc changes.html)

Honza
Comment 8 hubicka 2011-10-01 14:23:01 UTC
Hi,
the following is a diff from GNU LD to Gold build.  I previously complained
about RESOLVED_DYN/UNDEF difference. It is harmless since internall for GCC it
does not make difference if something is undef or resolved externally. 

However I am concerned about:

-2178 cf6ad577 PREVAILING_DEF NSModule
+2178 cf6ad577 PREVAILING_DEF_IRONLY_EXP NSModule

I would expect that both implementations ought to agree on this one way or another?

What makes build to fail is
2448 9647e1fd PREVAILING_DEF _ZTV17gfxUnknownSurface
_ZTV17gfxUnknownSurface then reffer to 
1091 9647e1fd UNDEF _ZN11gfxASurface13BeginPrintingERK9nsAStringS2_

I think source is incorrect and rely on fact that all references to _ZTV17gfxUnknownSurface
are optimized, but still we ought to be able to do so given that we do so even at -O0.

Honza

--- ./-lm.res	2011-10-01 15:58:24.000000000 +0200
+++ a.res	2011-10-01 15:58:15.000000000 +0200
@@ -1,5 +1,5 @@
 27
-nsModule.o 75
+/abuild/jh/build-mozilla-new14-gnu-ld/browser/components/build/nsModule.o 75
 324 cf6ad577 PREVAILING_DEF_IRONLY _ZN12nsAutoRefCntC2Ev
 344 cf6ad577 PREVAILING_DEF_IRONLY _ZN12nsAutoRefCntC1Ev
 349 cf6ad577 PREVAILING_DEF_IRONLY _ZN13nsCOMPtr_baseC2EP11nsISupports
@@ -48,7 +48,7 @@
 1714 cf6ad577 PREVAILING_DEF_IRONLY _ZN8nsCOMPtrI25nsIPrivateBrowsingServiceEC2Ev
 1723 cf6ad577 PREVAILING_DEF_IRONLY _ZN8nsCOMPtrI25nsIPrivateBrowsingServiceEC1Ev
 1727 cf6ad577 RESOLVED_IR _ZN7mozilla7browser15AboutRedirector6CreateEP11nsISupportsRK4nsIDPPv
-225 cf6ad577 RESOLVED_DYN __cxa_pure_virtual
+225 cf6ad577 UNDEF __cxa_pure_virtual
 1737 cf6ad577 RESOLVED_DYN moz_xmalloc
 1754 cf6ad577 RESOLVED_IR _ZN22nsOperaProfileMigratorC1Ev
 816 cf6ad577 RESOLVED_IR _ZN17nsProfileMigrator6AddRefEv
@@ -68,14 +68,14 @@
 1197 cf6ad577 PREVAILING_DEF_IRONLY _ZTV17nsIContentSniffer
 1223 cf6ad577 PREVAILING_DEF_IRONLY _ZTV18nsIRequestObserver
 1250 cf6ad577 PREVAILING_DEF_IRONLY _ZTV17nsIStreamListener
-2178 cf6ad577 PREVAILING_DEF NSModule
+2178 cf6ad577 PREVAILING_DEF_IRONLY_EXP NSModule
 792 cf6ad577 RESOLVED_IR _ZTV17nsProfileMigrator
 1075 cf6ad577 RESOLVED_IR _ZTVN7mozilla7browser17DirectoryProviderE
 1559 cf6ad577 RESOLVED_IR _ZTV31nsPrivateBrowsingServiceWrapper
 498 cf6ad577 RESOLVED_IR _ZTV19nsGNOMEShellService
 904 cf6ad577 RESOLVED_IR _ZTVN7mozilla7browser15AboutRedirectorE
 1284 cf6ad577 RESOLVED_IR _ZTV13nsFeedSniffer
-../feeds/src/nsFeedSniffer.o 117
+/abuild/jh/build-mozilla-new14-gnu-ld/browser/components/build/../feeds/src/nsFeedSniffer.o 117
 561 78bede03 PREVAILING_DEF_IRONLY _ZN13nsFeedSniffer6AddRefEv
 674 78bede03 PREVAILING_DEF_IRONLY _ZThn8_N13nsFeedSniffer6AddRefEv
 612 78bede03 PREVAILING_DEF_IRONLY _ZN13nsFeedSniffer14OnStartRequestEP10nsIRequestP11nsISupports
@@ -164,7 +164,7 @@
 1453 78bede03 PREVAILING_DEF_IRONLY _ZN15nsGetterAddRefsI6nsIURIEcvPPS0_Ev
 590 78bede03 PREVAILING_DEF_IRONLY _ZN13nsFeedSniffer22GetMIMETypeFromContentEP10nsIRequestPKhjR10nsACString
 735 78bede03 RESOLVED_IR _ZN10nsACString17DefaultComparatorEPKcS1_j
-1140 78bede03 RESOLVED_DYN __cxa_pure_virtual
+1140 78bede03 UNDEF __cxa_pure_virtual
 1460 78bede03 RESOLVED_IR _ZNK10nsACString12BeginReadingEv
 1469 78bede03 RESOLVED_IR _ZNK10nsACString4FindEPKcPFiS1_S1_jE
 1487 78bede03 RESOLVED_IR _Z16NS_TableDrivenQIPvPK12QITableEntryRK4nsIDPS_
@@ -193,7 +193,7 @@
 1719 78bede03 PREVAILING_DEF_IRONLY _ZN18nsIRequestObserver11COMTypeInfoIiE4kIIDE
 1735 78bede03 PREVAILING_DEF_IRONLY _ZN11nsISupports11COMTypeInfoIiE4kIIDE
 1172 78bede03 RESOLVED_IR _ZTV28nsCreateInstanceByContractID
-../privatebrowsing/src/nsPrivateBrowsingServiceWrapper.o 50
+/abuild/jh/build-mozilla-new14-gnu-ld/browser/components/build/../privatebrowsing/src/nsPrivateBrowsingServiceWrapper.o 50
 384 313f401 PREVAILING_DEF_IRONLY _ZN31nsPrivateBrowsingServiceWrapper6AddRefEv
 513 313f401 PREVAILING_DEF_IRONLY _ZThn8_N31nsPrivateBrowsingServiceWrapper6AddRefEv
 366 313f401 PREVAILING_DEF_IRONLY _ZN31nsPrivateBrowsingServiceWrapper14QueryInterfaceERK4nsIDPPv
@@ -244,7 +244,7 @@
 896 313f401 PREVAILING_DEF_IRONLY _ZN17nsIJSContextStack11COMTypeInfoIiE4kIIDE
 870 313f401 PREVAILING_DEF_IRONLY _ZN11nsIObserver11COMTypeInfoIiE4kIIDE
 888 313f401 PREEMPTED_IR _ZN11nsISupports11COMTypeInfoIiE4kIIDE
-../about/AboutRedirector.o 88
+/abuild/jh/build-mozilla-new14-gnu-ld/browser/components/build/../about/AboutRedirector.o 88
 551 468bb758 PREEMPTED_IR _ZN7mozilla7browser15AboutRedirectorD2Ev
 412 468bb758 PREEMPTED_IR _ZN7mozilla7browser15AboutRedirectorD1Ev
 316 468bb758 PREVAILING_DEF_IRONLY _ZN7mozilla7browser15AboutRedirector6AddRefEv
@@ -311,7 +311,7 @@
 991 468bb758 PREVAILING_DEF_IRONLY _ZN15nsGetterAddRefsI12nsIPrincipalEcvPPS0_Ev
 379 468bb758 PREVAILING_DEF_IRONLY _ZN7mozilla7browser15AboutRedirector10NewChannelEP6nsIURIPP10nsIChannel
 539 468bb758 RESOLVED_IR _ZN10nsACString17DefaultComparatorEPKcS1_j
-244 468bb758 RESOLVED_DYN __cxa_pure_virtual
+244 468bb758 UNDEF __cxa_pure_virtual
 998 468bb758 RESOLVED_IR _Z16NS_TableDrivenQIPvPK12QITableEntryRK4nsIDPS_
 1016 468bb758 RESOLVED_DYN moz_free
 1027 468bb758 RESOLVED_DYN NS_CStringContainerInit
@@ -333,7 +333,7 @@
 1240 468bb758 PREVAILING_DEF_IRONLY _ZN24nsIScriptSecurityManager11COMTypeInfoIiE4kIIDE
 1204 468bb758 PREVAILING_DEF_IRONLY _ZN14nsIAboutModule11COMTypeInfoIiE4kIIDE
 1215 468bb758 PREEMPTED_IR _ZN11nsISupports11COMTypeInfoIiE4kIIDE
-../dirprovider/DirectoryProvider.o 133
+/abuild/jh/build-mozilla-new14-gnu-ld/browser/components/build/../dirprovider/DirectoryProvider.o 133
 588 d66887c1 PREVAILING_DEF_IRONLY _ZN7mozilla7browser17DirectoryProvider6AddRefEv
 686 d66887c1 PREVAILING_DEF_IRONLY _ZN7mozilla7browser17DirectoryProvider19AppendingEnumerator6AddRefEv
 706 d66887c1 PREVAILING_DEF_IRONLY _ZN7mozilla7browser17DirectoryProvider19AppendingEnumerator15HasMoreElementsEPi
@@ -437,7 +437,7 @@
 1433 d66887c1 PREVAILING_DEF_IRONLY _ZN15nsGetterAddRefsI19nsISimpleEnumeratorEcvPPS0_Ev
 1440 d66887c1 PREVAILING_DEF_IRONLY _ZN15nsGetterAddRefsI19nsISimpleEnumeratorEcvPPvEv
 639 d66887c1 PREVAILING_DEF_IRONLY _ZN7mozilla7browser17DirectoryProvider8GetFilesEPKcPP19nsISimpleEnumerator
-241 d66887c1 RESOLVED_DYN __cxa_pure_virtual
+241 d66887c1 UNDEF __cxa_pure_virtual
 1452 d66887c1 RESOLVED_IR _Z16NS_TableDrivenQIPvPK12QITableEntryRK4nsIDPS_
 1470 d66887c1 RESOLVED_DYN moz_free
 1481 d66887c1 RESOLVED_IR _ZN13nsCOMPtr_base16begin_assignmentEv
@@ -467,7 +467,7 @@
 1728 d66887c1 PREVAILING_DEF_IRONLY _ZN28nsIDirectoryServiceProvider211COMTypeInfoIiE4kIIDE
 1706 d66887c1 PREEMPTED_IR _ZN11nsISupports11COMTypeInfoIiE4kIIDE
 557 d66887c1 PREVAILING_DEF_IRONLY _ZTVN7mozilla7browser17DirectoryProviderE
-../shell/src/nsGNOMEShellService.o 276
+/abuild/jh/build-mozilla-new14-gnu-ld/browser/components/build/../shell/src/nsGNOMEShellService.o 276
 1038 9647e1fd PREVAILING_DEF _ZN11gfxASurface21GetRotateForLandscapeEv
 1241 9647e1fd PREVAILING_DEF _ZN11gfxASurface17GetAsImageSurfaceEv
 1253 9647e1fd PREVAILING_DEF _ZNK11gfxASurface22GetDefaultContextFlagsEv
@@ -676,7 +676,7 @@
 941 9647e1fd PREVAILING_DEF_IRONLY _ZN19nsGNOMEShellService25GetDesktopBackgroundColorEPj
 908 9647e1fd PREVAILING_DEF_IRONLY _ZN19nsGNOMEShellService20SetDesktopBackgroundEP13nsIDOMElementi
 1026 9647e1fd RESOLVED_IR _ZN10nsACString17DefaultComparatorEPKcS1_j
-2016 9647e1fd RESOLVED_DYN __cxa_pure_virtual
+2016 9647e1fd UNDEF __cxa_pure_virtual
 1091 9647e1fd UNDEF _ZN11gfxASurface13BeginPrintingERK9nsAStringS2_
 1105 9647e1fd RESOLVED_DYN _ZN11gfxASurface11EndPrintingEv
 1111 9647e1fd RESOLVED_DYN _ZN11gfxASurface13AbortPrintingEv
@@ -744,7 +744,7 @@
 3538 9647e1fd PREEMPTED_IR _ZN11nsISupports11COMTypeInfoIiE4kIIDE
 2046 9647e1fd RESOLVED_IR _ZTV28nsCreateInstanceByContractID
 1072 9647e1fd RESOLVED_DYN _ZTV11gfxASurface
-../migration/src/nsProfileMigrator.o 148
+/abuild/jh/build-mozilla-new14-gnu-ld/browser/components/build/../migration/src/nsProfileMigrator.o 148
 538 34dc8a7b PREVAILING_DEF_IRONLY _ZN17nsProfileMigrator6AddRefEv
 519 34dc8a7b PREVAILING_DEF_IRONLY _ZN17nsProfileMigrator14QueryInterfaceERK4nsIDPPv
 547 34dc8a7b PREVAILING_DEF_IRONLY _ZN17nsProfileMigrator7ReleaseEv
@@ -856,7 +856,7 @@
 1446 34dc8a7b PREVAILING_DEF_IRONLY _ZN15nsGetterAddRefsI17nsIToolkitProfileEcvPPS0_Ev
 1453 34dc8a7b PREVAILING_DEF_IRONLY _ZN17nsProfileMigrator22ImportRegistryProfilesERK10nsACString
 559 34dc8a7b PREVAILING_DEF_IRONLY _ZN17nsProfileMigrator6ImportEv
-680 34dc8a7b RESOLVED_DYN __cxa_pure_virtual
+680 34dc8a7b UNDEF __cxa_pure_virtual
 1465 34dc8a7b RESOLVED_IR _Z16NS_TableDrivenQIPvPK12QITableEntryRK4nsIDPS_
 1483 34dc8a7b RESOLVED_DYN moz_free
 1492 34dc8a7b RESOLVED_DYN NS_CStringSetData
@@ -893,7 +893,7 @@
 1758 34dc8a7b PREVAILING_DEF_IRONLY _ZN18nsIProfileMigrator11COMTypeInfoIiE4kIIDE
 1769 34dc8a7b PREEMPTED_IR _ZN11nsISupports11COMTypeInfoIiE4kIIDE
 712 34dc8a7b RESOLVED_IR _ZTV28nsCreateInstanceByContractID
-../migration/src/nsBrowserProfileMigratorUtils.o 219
+/abuild/jh/build-mozilla-new14-gnu-ld/browser/components/build/../migration/src/nsBrowserProfileMigratorUtils.o 219
 630 34dc8a7b PREVAILING_DEF_IRONLY _ZNK9nsAString6LengthEv
 644 34dc8a7b PREVAILING_DEF_IRONLY _ZN9nsAString7ReplaceEjjRKS_
 673 34dc8a7b PREEMPTED_IR _ZN9nsAStringD2Ev
@@ -1067,7 +1067,7 @@
 2127 34dc8a7b PREVAILING_DEF_IRONLY _Z19ImportBookmarksHTMLP7nsIFileiiPKt
 2146 34dc8a7b PREVAILING_DEF_IRONLY _Z19InitializeBookmarksP7nsIFile
 618 34dc8a7b RESOLVED_IR _ZN10nsACString17DefaultComparatorEPKcS1_j
-1257 34dc8a7b RESOLVED_DYN __cxa_pure_virtual
+1257 34dc8a7b UNDEF __cxa_pure_virtual
 2154 34dc8a7b RESOLVED_DYN NS_StringGetData
 2168 34dc8a7b RESOLVED_DYN NS_StringSetDataRange
 2188 34dc8a7b RESOLVED_DYN NS_CStringGetData
@@ -1113,7 +1113,7 @@
 2709 34dc8a7b PREVAILING_DEF_IRONLY _ZN22nsINavBookmarksService11COMTypeInfoIiE4kIIDE
 2728 34dc8a7b PREEMPTED_IR _ZN7nsIFile11COMTypeInfoIiE4kIIDE
 1287 34dc8a7b RESOLVED_IR _ZTV28nsCreateInstanceByContractID
-../migration/src/nsOperaProfileMigrator.o 404
+/abuild/jh/build-mozilla-new14-gnu-ld/browser/components/build/../migration/src/nsOperaProfileMigrator.o 404
 373 b60a107f PREVAILING_DEF_IRONLY _ZN22nsOperaProfileMigrator6AddRefEv
 590 b60a107f PREVAILING_DEF_IRONLY _ZThn8_N22nsOperaProfileMigrator6AddRefEv
 1428 b60a107f PREVAILING_DEF_IRONLY _ZN22nsOperaProfileMigrator17SetCookieBehaviorEPvP13nsIPrefBranch
@@ -1439,7 +1439,7 @@
 1101 b60a107f PREVAILING_DEF_IRONLY _ZN21nsOperaCookieMigratorD1Ev
 1107 b60a107f PREVAILING_DEF_IRONLY _ZN21nsOperaCookieMigratorD0Ev
 1413 b60a107f RESOLVED_IR _ZN9nsAString17DefaultComparatorEPKtS1_j
-191 b60a107f RESOLVED_DYN __cxa_pure_virtual
+191 b60a107f UNDEF __cxa_pure_virtual
 3831 b60a107f RESOLVED_IR _ZN13nsCOMPtr_baseD2Ev
 3839 b60a107f RESOLVED_DYN moz_free
 3848 b60a107f RESOLVED_IR _Z16NS_TableDrivenQIPvPK12QITableEntryRK4nsIDPS_
@@ -1552,7 +1552,7 @@
 1360 d63746fe RESOLVED_DYN PL_strlen
 1367 d63746fe RESOLVED_DYN PL_strcmp
 1378 d63746fe RESOLVED_IR bufio_Open
-1383 d63746fe RESOLVED_DYN __xstat
+1383 d63746fe UNDEF __xstat
 1465 d63746fe RESOLVED_IR bufio_Seek
 1474 d63746fe RESOLVED_IR bufio_Tell
 1478 d63746fe RESOLVED_IR bufio_SetBufferSize
@@ -1566,7 +1566,7 @@
 1545 d63746fe RESOLVED_DYN PL_strdup
 1552 d63746fe RESOLVED_DYN PR_snprintf
 1561 d63746fe RESOLVED_IR vr_findGlobalRegName
-1564 d63746fe RESOLVED_DYN getenv
+1564 d63746fe UNDEF getenv
 1574 d63746fe PREVAILING_DEF_IRONLY globalRegName
 1582 d63746fe RESOLVED_IR vr_lock
 1584 d63746fe RESOLVED_IR bGlobalRegistry
@@ -1600,7 +1600,7 @@
 706 df71332f RESOLVED_DYN PL_strcat
 714 df71332f RESOLVED_DYN PL_strcpy
 719 df71332f RESOLVED_IR NR_RegSetEntry
-728 df71332f RESOLVED_DYN strtol
+728 df71332f UNDEF strtol
 741 df71332f RESOLVED_IR NR_RegGetKey
 748 df71332f RESOLVED_DYN PL_strncmp
 760 df71332f RESOLVED_IR NR_RegAddKey
@@ -1617,7 +1617,7 @@
 861 df71332f RESOLVED_IR vr_findVerRegName
 864 df71332f RESOLVED_IR NR_RegPack
 870 df71332f RESOLVED_IR NR_RegDeleteKey
-891 df71332f RESOLVED_DYN __xstat
+891 df71332f UNDEF __xstat
 971 df71332f RESOLVED_DYN PL_strdup
 978 df71332f RESOLVED_IR NR_RegEnumEntries
 987 df71332f RESOLVED_IR NR_RegDeleteEntry
@@ -1628,7 +1628,7 @@
 ../../../dist/lib/libmozreg_s.a@0x2f9ea 13
 182 40d20a0c PREVAILING_DEF_IRONLY vr_findGlobalRegName
 186 40d20a0c PREVAILING_DEF_IRONLY vr_findVerRegName
-189 40d20a0c RESOLVED_DYN getenv
+189 40d20a0c UNDEF getenv
 200 40d20a0c RESOLVED_DYN PL_strlen
 213 40d20a0c RESOLVED_DYN PR_Malloc
 220 40d20a0c RESOLVED_DYN PL_strcpy
@@ -1648,17 +1648,17 @@
 396 e1f83884 PREVAILING_DEF_IRONLY bufio_Write
 406 e1f83884 PREVAILING_DEF_IRONLY bufio_Flush
 410 e1f83884 PREVAILING_DEF_IRONLY bufio_SetBufferSize
-429 e1f83884 RESOLVED_DYN fseek
-435 e1f83884 RESOLVED_DYN fread
+429 e1f83884 UNDEF fseek
+435 e1f83884 UNDEF fread
 459 e1f83884 RESOLVED_DYN PR_SetError
 470 e1f83884 RESOLVED_DYN __errno_location
-477 e1f83884 RESOLVED_DYN fclose
+477 e1f83884 UNDEF fclose
 481 e1f83884 RESOLVED_DYN PR_Free
-488 e1f83884 RESOLVED_DYN ftell
+488 e1f83884 UNDEF ftell
 492 e1f83884 RESOLVED_DYN PR_Malloc
 499 e1f83884 RESOLVED_DYN PR_Calloc
-507 e1f83884 RESOLVED_DYN fopen
-513 e1f83884 RESOLVED_DYN fflush
+507 e1f83884 UNDEF fopen
+513 e1f83884 UNDEF fflush
 ../../../dist/lib/libxpcomglue_s.a@0xb04a 44
 441 4437ac9d PREVAILING_DEF_IRONLY _ZN23nsSimpleArrayEnumerator6AddRefEv
 360 4437ac9d PREVAILING_DEF_IRONLY _ZN20nsCOMArrayEnumerator6AddRefEv
@@ -1693,7 +1693,7 @@
 674 4437ac9d PREVAILING_DEF_IRONLY _Z21NS_NewArrayEnumeratorPP19nsISimpleEnumeratorRK15nsCOMArray_base
 685 4437ac9d PREVAILING_DEF_IRONLY _ZN8nsCOMPtrI8nsIArrayEC2EPS0_
 695 4437ac9d PREVAILING_DEF_IRONLY _ZN8nsCOMPtrI8nsIArrayEC1EPS0_
-241 4437ac9d RESOLVED_DYN __cxa_pure_virtual
+241 4437ac9d UNDEF __cxa_pure_virtual
 701 4437ac9d RESOLVED_IR _Z16NS_TableDrivenQIPvPK12QITableEntryRK4nsIDPS_
 719 4437ac9d RESOLVED_DYN moz_free
 730 4437ac9d RESOLVED_IR _ZN13nsCOMPtr_baseD2Ev
@@ -1868,7 +1868,7 @@
 938 786b304f PREVAILING_DEF_IRONLY _Z21NS_NewUnionEnumeratorPP19nsISimpleEnumeratorS0_S0_
 952 786b304f PREEMPTED_IR _ZN8nsCOMPtrI19nsISimpleEnumeratorEC2EPS0_
 962 786b304f PREEMPTED_IR _ZN8nsCOMPtrI19nsISimpleEnumeratorEC1EPS0_
-249 786b304f RESOLVED_DYN __cxa_pure_virtual
+249 786b304f UNDEF __cxa_pure_virtual
 970 786b304f RESOLVED_IR _Z16NS_TableDrivenQIPvPK12QITableEntryRK4nsIDPS_
 988 786b304f RESOLVED_DYN moz_free
 1000 786b304f RESOLVED_DYN moz_xmalloc
@@ -1955,7 +1955,7 @@
 1242 203ab2c1 RESOLVED_IR PL_DHashTableInit
 1259 203ab2c1 RESOLVED_DYN NS_CStringContainerInit
 1272 203ab2c1 RESOLVED_DYN NS_CStringContainerFinish
-1280 203ab2c1 RESOLVED_DYN fclose
+1280 203ab2c1 UNDEF fclose
 1286 203ab2c1 RESOLVED_DYN moz_free
 1294 203ab2c1 RESOLVED_IR PL_DHashTableEnumerate
 1310 203ab2c1 RESOLVED_IR PL_DHashTableOperate
@@ -1963,10 +1963,10 @@
 1369 203ab2c1 RESOLVED_DYN moz_xmalloc
 1382 203ab2c1 RESOLVED_IR _Z9NS_strtokPKcPPc
 1396 203ab2c1 RESOLVED_IR _Z10NS_strspnpPKcS0_
-1407 203ab2c1 RESOLVED_DYN fread
-1422 203ab2c1 RESOLVED_DYN fseek
-1433 203ab2c1 RESOLVED_DYN ftell
-1438 203ab2c1 RESOLVED_DYN fopen
+1407 203ab2c1 UNDEF fread
+1422 203ab2c1 UNDEF fseek
+1433 203ab2c1 UNDEF ftell
+1438 203ab2c1 UNDEF fopen
 1447 203ab2c1 RESOLVED_IR _ZNK10nsACString12BeginReadingEv
 1464 203ab2c1 PREVAILING_DEF_IRONLY _ZZN12nsTHashtableI17nsBaseHashtableETI16nsDepCharHashKey9nsAutoPtrIN11nsINIParser8INIValueEEEE4InitEjE4sOps
 ../../../dist/lib/libxpcomglue_s.a@0x69878 1
@@ -2280,6 +2280,6 @@
 391 d2d2e06f RESOLVED_DYN NS_Alloc
 541 d2d2e06f PREVAILING_DEF_IRONLY _ZN17nsLowerUpperUtils12kUpper2LowerE
 558 d2d2e06f PREVAILING_DEF_IRONLY _ZN17nsLowerUpperUtils12kLower2UpperE
-562 d2d2e06f RESOLVED_DYN stderr
+562 d2d2e06f UNDEF stderr
 ../../../dist/lib/libxpcomglue_s.a@0x7953e 1
 234 f4996d86 PREVAILING_DEF_IRONLY NS_QuickSort
Comment 9 Jan Hubicka 2011-10-01 15:19:27 UTC
OK,
I now understand the problem.  It is partly GNU LD issue.
What happens is

1) nsGNOMEShellService includes header that define gfxUnknownSurface.
   The class is obviously uunused but it has virtual destructor and thus GCC
   decides to keep it around until after interprocedural optimization for
   possible devirtualization.
   Note that even with -O0 the class goes trivially away. This is stupid but should not affect code quality
2) Other shared library, libxul.so also included some modules that use&define gfxUnknownSurface. It is linked with LTO info and resolution is:

11903 34650d5e PREVAILING_DEF_IRONLY_EXP _ZTV17gfxUnknownSurface

This consequentely makes GCC to privatize it and rename it to static  _ZTV17gfxUnknownSurface.local.<somerandomnumbers>
jh@evans:/abuild/jh/build-mozilla-new14-gnu-ld/toolkit/library> grep _ZTV17gfxUnknownSurface *.s
libxul.so.ltrans18.s:   leaq    16+_ZTV17gfxUnknownSurface.local.102757(%rip), %rax
libxul.so.ltrans18.s:   .hidden _ZTV17gfxUnknownSurface.local.102757
libxul.so.ltrans23.s:   .hidden _ZTV17gfxUnknownSurface.local.102757
libxul.so.ltrans23.s:   .globl  _ZTV17gfxUnknownSurface.local.102757
libxul.so.ltrans23.s:   .type   _ZTV17gfxUnknownSurface.local.102757, @object
libxul.so.ltrans23.s:   .size   _ZTV17gfxUnknownSurface.local.102757, 144
libxul.so.ltrans23.s:_ZTV17gfxUnknownSurface.local.102757:

3) Despite the fact that original _ZTV17gfxUnknownSurface has been fully optimized out from libxul.so, GNU LD incorrectly assigns a dynamic linker entry for it:
jh@evans:/abuild/jh/build-mozilla-new14-gnu-ld/toolkit/library> nm -D libxul.so| grep _ZTV17gfxUnknownSurface
0000000000000000 W _ZTV17gfxUnknownSurface

4) Finally at a time we link the new shared library -llibxul is used.  This makes linker to notice dynamic linker entry for _ZTV17gfxUnknownSurface and consequentely it changes prevailance info to PREVAILING_DEF as quoted above.
This makes GCC to no longer optimize the symbol out and finally we die on undefined reference.

So in addition to your patch, I think there are two bugs:

1) GNU LD should not produce dynamic linker entries for PREVAILING_DEF_IRONLY_EXP that has been optimized out.  This is very important since in C++ code this is a mjority and size of linker table would grow a lot
2) The class is probably by some .h trickery hidden visibility for libxul and default visibility for the other library. Is it correct for gold&GNU LD to make the resolution PREVAILING_DEF because the symbol is mentioned but not used by some other shared library here?
Comment 10 Jan Hubicka 2011-10-01 15:51:57 UTC
I was wrong about .h trickery. It is default visibility in both libraries, but because libxul do not link with any library that would (mistakely) export it, it gets optimized out there.

Please also look at http://sourceware.org/bugzilla/show_bug.cgi?id=13245

Your current implementation agrees with Gold on IRONLY_EXP and dynamic linking, but I would really love this to be changed.  We have quite good potential or reducing dynamic linking tables by hidding all COMDAT functions that we know don't need to be unified at runtime (that is most of them).
Comment 11 H.J. Lu 2011-10-05 17:22:58 UTC
(In reply to comment #9)
> 1) GNU LD should not produce dynamic linker entries for
> PREVAILING_DEF_IRONLY_EXP that has been optimized out.  This is very important
> since in C++ code this is a mjority and size of linker table would grow a lot

From include/plugin-api.h:

  /* This is the prevailing definition of the symbol, with no
     references from regular objects.  It is only referenced from IR
     code, but the symbol is exported and may be referenced from
     a dynamic object (not seen at link time).  */
  LDPR_PREVAILING_DEF_IRONLY_EXP

It looks like it should be made dynamic since it is exported.
Do you have a stand-alone testcase for this?
Comment 12 hubicka 2011-10-05 20:49:35 UTC
> 
>   /* This is the prevailing definition of the symbol, with no
>      references from regular objects.  It is only referenced from IR
>      code, but the symbol is exported and may be referenced from
>      a dynamic object (not seen at link time).  */
>   LDPR_PREVAILING_DEF_IRONLY_EXP
> 
> It looks like it should be made dynamic since it is exported.
> Do you have a stand-alone testcase for this?

What is causing the problem are LDPR_PREVAILING_DEF_IRONLY_EXP symbols
that are completely optimized out (i.e. not appearing in the output from
linker plugin, just in the LTO symbol table).
The follwing should work in C++

inline void test (void)
{
  call_something();
}
void test2 (void)
{
  test();
}

and compile with -flto -fuse-linker-plugin -fno-early-inlining -O3.
Late inliner wil linline test into test2, but test's symbol will still
appear in the symbol table (with V2 get_symbol API)

Honza
Comment 13 H.J. Lu 2011-10-05 21:41:29 UTC
(In reply to comment #12)

> The follwing should work in C++
> 
> inline void test (void)
> {
>   call_something();
> }
> void test2 (void)
> {
>   test();
> }
> 
> and compile with -flto -fuse-linker-plugin -fno-early-inlining -O3.
> Late inliner wil linline test into test2, but test's symbol will still
> appear in the symbol table (with V2 get_symbol API)

I can't reproduce it.
Comment 14 Jan Hubicka 2011-10-06 19:09:55 UTC
Hmm, reproducing the situation is harder with the COMDAT hack in your compiler.
Here is testcase that reproduces w/o GCC patch.

With BFD and patch for V2 API:

jh@evans:/abuild/jh/trunk-3/build-inst7/gcc> cat t.C
int call_something (int);
inline void optimize_me_out (void)                                                                                                                                                   
{ 
  call_something(0);
}
__attribute__ ((visibility("hidden")))
int optimize_me_out2 (int param)                                                                                                                                                     
{ 
  if ((void *)optimize_me_out != (void *)call_something)
    return call_something(0);                                                                                                                                                        
}
void test2 (void)
{ 
  optimize_me_out();                                                                                                                                                                 
}
jh@evans:/abuild/jh/trunk-3/build-inst7/gcc> /abuild/jh/trunk-install/bin/g++ -O2 t.C  --shared -fPIC -o t.so -flto -fuse-linker-plugin -fno-early-inlining
jh@evans:/abuild/jh/trunk-3/build-inst7/gcc> nm -D t.so |grep optimize
0000000000000000 W _Z15optimize_me_outv

With gold and V2 API:

jh@evans:/abuild/jh/trunk-3/build-inst7/gcc> /abuild/jh/trunk-install/bin/g++ -O2 t.C  --shared -fPIC -o t.so -flto -fuse-linker-plugin -fno-early-inlining
jh@evans:/abuild/jh/trunk-3/build-inst7/gcc> nm -D t.so |grep optimize
jh@evans:/abuild/jh/trunk-3/build-inst7/gcc>
Comment 15 H.J. Lu 2011-10-07 00:02:05 UTC
elf_link_output_extsym shouldn't output any plugin symbols.
Comment 16 H.J. Lu 2011-10-07 16:47:06 UTC
(In reply to comment #15)
> elf_link_output_extsym shouldn't output any plugin symbols.

A patch is posed at

http://sourceware.org/ml/binutils/2011-10/msg00034.html

It also fixes PR 13244.
Comment 17 Alan Modra 2011-10-08 07:48:34 UTC
This was the v2 implementation commit, which didn't appear here because I typoed the pr number.
http://sourceware.org/ml/binutils-cvs/2011-10/msg00019.html

This one didn't appear here because I omitted the pr number.  oops again.
http://sourceware.org/ml/binutils-cvs/2011-10/msg00027.html
Comment 18 Sourceware Commits 2011-10-08 07:50:24 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	amodra@sourceware.org	2011-10-08 07:50:19

Modified files:
	bfd            : ChangeLog elflink.c 

Log message:
	PR ld/13229
	PR ld/13244
	* elflink.c (elf_link_add_object_symbols): Don't make IR symbols
	dynamic.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/ChangeLog.diff?cvsroot=src&r1=1.5482&r2=1.5483
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elflink.c.diff?cvsroot=src&r1=1.423&r2=1.424
Comment 19 Alan Modra 2011-10-08 07:58:47 UTC
Fixed mainline
Comment 20 Sourceware Commits 2011-10-25 02:51:26 UTC
CVSROOT:	/cvs/src
Module name:	src
Branch: 	binutils-2_22-branch
Changes by:	amodra@sourceware.org	2011-10-25 02:51:22

Modified files:
	ld             : ChangeLog plugin.c testplug.c 
	ld/testsuite   : ChangeLog 
	ld/testsuite/ld-plugin: plugin-1.d plugin-10.d plugin-11.d 
	                        plugin-2.d plugin-3.d plugin-4.d 
	                        plugin-5.d plugin-6.d plugin-7.d 
	                        plugin-8.d plugin-9.d 

Log message:
	PR ld/13229
	Apply mainline patches
	ld/
	2011-10-06  Alan Modra  <amodra@gmail.com>
	* plugin.c (tv_header_tags): Add LDPT_GET_SYMBOLS_V2.
	(set_tv_header): Handle it.  Adjust LDPT_GET_SYMBOLS.  Return void.
	(get_symbols): Add def_ironly_exp param.  Return that value for
	syms exported from shared libs.
	(get_symbols_v1, get_symbols_v2): New wrapper functions.
	* testplug.c: Update for above changes.
	ld/testsuite/
	2011-10-06  Alan Modra  <amodra@gmail.com>
	* ld-plugin/plugin-1.d, * ld-plugin/plugin-2.d, * ld-plugin/plugin-3.d,
	* ld-plugin/plugin-4.d, * ld-plugin/plugin-5.d, * ld-plugin/plugin-6.d,
	* ld-plugin/plugin-7.d, * ld-plugin/plugin-8.d, * ld-plugin/plugin-9.d,
	* ld-plugin/plugin-10.d, * ld-plugin/plugin-11.d: Update.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ChangeLog.diff?cvsroot=src&only_with_tag=binutils-2_22-branch&r1=1.2373.2.1&r2=1.2373.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/plugin.c.diff?cvsroot=src&only_with_tag=binutils-2_22-branch&r1=1.40&r2=1.40.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testplug.c.diff?cvsroot=src&only_with_tag=binutils-2_22-branch&r1=1.4&r2=1.4.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ChangeLog.diff?cvsroot=src&only_with_tag=binutils-2_22-branch&r1=1.1460.2.5&r2=1.1460.2.6
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-plugin/plugin-1.d.diff?cvsroot=src&only_with_tag=binutils-2_22-branch&r1=1.1&r2=1.1.4.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-plugin/plugin-10.d.diff?cvsroot=src&only_with_tag=binutils-2_22-branch&r1=1.1&r2=1.1.4.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-plugin/plugin-11.d.diff?cvsroot=src&only_with_tag=binutils-2_22-branch&r1=1.1&r2=1.1.4.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-plugin/plugin-2.d.diff?cvsroot=src&only_with_tag=binutils-2_22-branch&r1=1.1&r2=1.1.4.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-plugin/plugin-3.d.diff?cvsroot=src&only_with_tag=binutils-2_22-branch&r1=1.1&r2=1.1.4.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-plugin/plugin-4.d.diff?cvsroot=src&only_with_tag=binutils-2_22-branch&r1=1.1&r2=1.1.4.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-plugin/plugin-5.d.diff?cvsroot=src&only_with_tag=binutils-2_22-branch&r1=1.1&r2=1.1.4.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-plugin/plugin-6.d.diff?cvsroot=src&only_with_tag=binutils-2_22-branch&r1=1.2&r2=1.2.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-plugin/plugin-7.d.diff?cvsroot=src&only_with_tag=binutils-2_22-branch&r1=1.4&r2=1.4.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-plugin/plugin-8.d.diff?cvsroot=src&only_with_tag=binutils-2_22-branch&r1=1.4&r2=1.4.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-plugin/plugin-9.d.diff?cvsroot=src&only_with_tag=binutils-2_22-branch&r1=1.1&r2=1.1.4.1
Comment 21 Sourceware Commits 2011-10-25 02:54:28 UTC
CVSROOT:	/cvs/src
Module name:	src
Branch: 	binutils-2_22-branch
Changes by:	amodra@sourceware.org	2011-10-25 02:54:25

Modified files:
	bfd            : ChangeLog elflink.c 

Log message:
	PR ld/13229
	PR ld/13244
	Apply mainline patches
	2011-10-08  Alan Modra  <amodra@gmail.com>
	* elflink.c (elf_link_add_object_symbols): Don't make IR symbols
	dynamic.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/ChangeLog.diff?cvsroot=src&only_with_tag=binutils-2_22-branch&r1=1.5473.2.9&r2=1.5473.2.10
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elflink.c.diff?cvsroot=src&only_with_tag=binutils-2_22-branch&r1=1.420.2.4&r2=1.420.2.5