bfd/ChangeLog
authorDave Korn <dave.korn@artimi.com>
Mon, 4 May 2009 12:09:30 +0000 (12:09 +0000)
committerDave Korn <dave.korn@artimi.com>
Mon, 4 May 2009 12:09:30 +0000 (12:09 +0000)
* elflink.c (find_version_for_sym):  Remove from here, ...
* linker.c (bfd_find_version_for_sym):  ... rename, replace
here, make public and update all callers.
* bfd-in2.h:  Regenerate.

ld/ChangeLog

* NEWS:  Mention new feature.
* ld.texinfo (--version-script):  Document extent of PE support.
(WIN32):  Mention --version-script.  Extend auto-export description.
* pe-dll.c (process_def_file):  Use version script info to filter
symbols from auto-export.
* testsuite/ld-pe/vers-script-1.d:  New file.
* testsuite/ld-pe/vers-script-2.d:  New file.
* testsuite/ld-pe/vers-script-3.d:  New file.
* testsuite/ld-pe/vers-script-4.d:  New file.
* testsuite/ld-pe/vers-script-1.ver:  New file.
* testsuite/ld-pe/vers-script-2.ver:  New file.
* testsuite/ld-pe/vers-script-3.ver:  New file.
* testsuite/ld-pe/vers-script-4.ver:  New file.
* testsuite/ld-pe/vers-script-dll.c:  New file.
* testsuite/ld-pe/vers-script.exp:  New test script.

18 files changed:
bfd/ChangeLog
bfd/bfd-in2.h
bfd/elflink.c
bfd/linker.c
ld/ChangeLog
ld/NEWS
ld/ld.texinfo
ld/pe-dll.c
ld/testsuite/ld-pe/vers-script-1.d [new file with mode: 0644]
ld/testsuite/ld-pe/vers-script-1.ver [new file with mode: 0755]
ld/testsuite/ld-pe/vers-script-2.d [new file with mode: 0644]
ld/testsuite/ld-pe/vers-script-2.ver [new file with mode: 0755]
ld/testsuite/ld-pe/vers-script-3.d [new file with mode: 0644]
ld/testsuite/ld-pe/vers-script-3.ver [new file with mode: 0755]
ld/testsuite/ld-pe/vers-script-4.d [new file with mode: 0644]
ld/testsuite/ld-pe/vers-script-4.ver [new file with mode: 0755]
ld/testsuite/ld-pe/vers-script-dll.c [new file with mode: 0755]
ld/testsuite/ld-pe/vers-script.exp [new file with mode: 0755]

index d13bda0610b4bbe5af78e1a08d58784d5f3db788..adc6b8d9b4f36196b4a45b4cefe8adda624730ac 100644 (file)
@@ -1,3 +1,10 @@
+2009-05-04  Dave Korn  <dave.korn.cygwin@gmail.com>
+
+       * elflink.c (find_version_for_sym):  Remove from here, ...
+       * linker.c (bfd_find_version_for_sym):  ... rename, replace
+       here, make public and update all callers.
+       * bfd-in2.h:  Regenerate.
+
 2009-04-30  Nick Clifton  <nickc@redhat.com>
 
        * elf-bfd.h (struct bfd_elf_section_data): Add indirect_relocs
index 18eae4e8e19671465983a04f0dff4694ded43573..cf6500c30f0e75294399cf91a6858dc6fdfd0d13 100644 (file)
@@ -5590,6 +5590,10 @@ bfd_boolean bfd_generic_define_common_symbol
 #define bfd_define_common_symbol(output_bfd, info, h) \
        BFD_SEND (output_bfd, _bfd_define_common_symbol, (output_bfd, info, h))
 
+struct bfd_elf_version_tree * bfd_find_version_for_sym
+   (struct bfd_elf_version_tree *verdefs,
+    const char *sym_name, bfd_boolean *hide);
+
 /* Extracted from simple.c.  */
 bfd_byte *bfd_simple_get_relocated_section_contents
    (bfd *abfd, asection *sec, bfd_byte *outbuf, asymbol **symbol_table);
index 54ad2af43aba5642b92487b371b4fa650ebe2fa1..bfbf79a95170e1555f24685ac6942f5a74d61ccf 100644 (file)
@@ -1798,80 +1798,6 @@ nondefault:
   return TRUE;
 }
 \f
-static struct bfd_elf_version_tree *
-find_version_for_sym (struct bfd_elf_version_tree *verdefs,
-                     const char *sym_name,
-                     bfd_boolean *hide)
-{
-  struct bfd_elf_version_tree *t;
-  struct bfd_elf_version_tree *local_ver, *global_ver, *exist_ver;
-
-  local_ver = NULL;
-  global_ver = NULL;
-  exist_ver = NULL;
-  for (t = verdefs; t != NULL; t = t->next)
-    {
-      if (t->globals.list != NULL)
-       {
-         struct bfd_elf_version_expr *d = NULL;
-
-         while ((d = (*t->match) (&t->globals, d, sym_name)) != NULL)
-           {
-             global_ver = t;
-             if (d->symver)
-               exist_ver = t;
-             d->script = 1;
-             /* If the match is a wildcard pattern, keep looking for
-                a more explicit, perhaps even local, match.  */
-             if (d->literal)
-               break;
-           }
-
-         if (d != NULL)
-           break;
-       }
-
-      if (t->locals.list != NULL)
-       {
-         struct bfd_elf_version_expr *d = NULL;
-
-         while ((d = (*t->match) (&t->locals, d, sym_name)) != NULL)
-           {
-             local_ver = t;
-             /* If the match is a wildcard pattern, keep looking for
-                a more explicit, perhaps even global, match.  */
-             if (d->literal)
-               {
-                 /* An exact match overrides a global wildcard.  */
-                 global_ver = NULL;
-                 break;
-               }
-           }
-
-         if (d != NULL)
-           break;
-       }
-    }
-
-  if (global_ver != NULL)
-    {
-      /* If we already have a versioned symbol that matches the
-        node for this symbol, then we don't want to create a
-        duplicate from the unversioned symbol.  Instead hide the
-        unversioned symbol.  */
-      *hide = exist_ver == global_ver;
-      return global_ver;
-    }
-
-  if (local_ver != NULL)
-    {
-      *hide = TRUE;
-      return local_ver;
-    }
-
-  return NULL;
-}
-
 /* This routine is used to export all defined symbols into the dynamic
    symbol table.  It is called via elf_link_hash_traverse.  */
 
@@ -1898,7 +1824,7 @@ _bfd_elf_export_symbol (struct elf_link_hash_entry *h, void *data)
       bfd_boolean hide;
 
       if (eif->verdefs == NULL
-         || (find_version_for_sym (eif->verdefs, h->root.root.string, &hide)
+         || (bfd_find_version_for_sym (eif->verdefs, h->root.root.string, &hide)
              && !hide))
        {
          if (! bfd_elf_link_record_dynamic_symbol (eif->info, h))
@@ -2160,7 +2086,7 @@ _bfd_elf_link_assign_sym_version (struct elf_link_hash_entry *h, void *data)
     {
       bfd_boolean hide;
 
-      h->verinfo.vertree = find_version_for_sym (sinfo->verdefs,
+      h->verinfo.vertree = bfd_find_version_for_sym (sinfo->verdefs,
                                                 h->root.root.string, &hide);
       if (h->verinfo.vertree != NULL && hide)
        (*bed->elf_backend_hide_symbol) (info, h, TRUE);
index bfbd8861ddd50708121f84d031cfad872047b85b..66ec2faa3910dd988da5e31530e31a57cf99a8c2 100644 (file)
@@ -3245,3 +3245,95 @@ bfd_generic_define_common_symbol (bfd *output_bfd,
   section->flags &= ~SEC_IS_COMMON;
   return TRUE;
 }
+
+/*
+FUNCTION
+       bfd_find_version_for_sym 
+
+SYNOPSIS
+       struct bfd_elf_version_tree * bfd_find_version_for_sym
+         (struct bfd_elf_version_tree *verdefs,
+          const char *sym_name, bfd_boolean *hide);
+
+DESCRIPTION
+       Search an elf version script tree for symbol versioning
+       info and export / don't-export status for a given symbol.
+       Return non-NULL on success and NULL on failure; also sets
+       the output @samp{hide} boolean parameter.
+
+*/
+
+struct bfd_elf_version_tree *
+bfd_find_version_for_sym (struct bfd_elf_version_tree *verdefs,
+                     const char *sym_name,
+                     bfd_boolean *hide)
+{
+  struct bfd_elf_version_tree *t;
+  struct bfd_elf_version_tree *local_ver, *global_ver, *exist_ver;
+
+  local_ver = NULL;
+  global_ver = NULL;
+  exist_ver = NULL;
+  for (t = verdefs; t != NULL; t = t->next)
+    {
+      if (t->globals.list != NULL)
+       {
+         struct bfd_elf_version_expr *d = NULL;
+
+         while ((d = (*t->match) (&t->globals, d, sym_name)) != NULL)
+           {
+             global_ver = t;
+             if (d->symver)
+               exist_ver = t;
+             d->script = 1;
+             /* If the match is a wildcard pattern, keep looking for
+                a more explicit, perhaps even local, match.  */
+             if (d->literal)
+               break;
+           }
+
+         if (d != NULL)
+           break;
+       }
+
+      if (t->locals.list != NULL)
+       {
+         struct bfd_elf_version_expr *d = NULL;
+
+         while ((d = (*t->match) (&t->locals, d, sym_name)) != NULL)
+           {
+             local_ver = t;
+             /* If the match is a wildcard pattern, keep looking for
+                a more explicit, perhaps even global, match.  */
+             if (d->literal)
+               {
+                 /* An exact match overrides a global wildcard.  */
+                 global_ver = NULL;
+                 break;
+               }
+           }
+
+         if (d != NULL)
+           break;
+       }
+    }
+
+  if (global_ver != NULL)
+    {
+      /* If we already have a versioned symbol that matches the
+        node for this symbol, then we don't want to create a
+        duplicate from the unversioned symbol.  Instead hide the
+        unversioned symbol.  */
+      *hide = exist_ver == global_ver;
+      return global_ver;
+    }
+
+  if (local_ver != NULL)
+    {
+      *hide = TRUE;
+      return local_ver;
+    }
+
+  return NULL;
+}
+
index 77586e38d5cfb2ad65a5a78f1d487d5f94061505..83461c8e6a25230b1c476e10da16c7c54c4186b8 100644 (file)
@@ -1,3 +1,21 @@
+2009-05-04  Dave Korn  <dave.korn.cygwin@gmail.com>
+
+       * NEWS:  Mention new feature.
+       * ld.texinfo (--version-script):  Document extent of PE support.
+       (WIN32):  Mention --version-script.  Extend auto-export description.
+       * pe-dll.c (process_def_file):  Use version script info to filter
+       symbols from auto-export.
+       * testsuite/ld-pe/vers-script-1.d:  New file.
+       * testsuite/ld-pe/vers-script-2.d:  New file.
+       * testsuite/ld-pe/vers-script-3.d:  New file.
+       * testsuite/ld-pe/vers-script-4.d:  New file.
+       * testsuite/ld-pe/vers-script-1.ver:  New file.
+       * testsuite/ld-pe/vers-script-2.ver:  New file.
+       * testsuite/ld-pe/vers-script-3.ver:  New file.
+       * testsuite/ld-pe/vers-script-4.ver:  New file.
+       * testsuite/ld-pe/vers-script-dll.c:  New file.
+       * testsuite/ld-pe/vers-script.exp:  New test script.
+
 2009-05-01  Nathan Sidwell  <nathan@codesourcery.com>
 
        * emulparams/vxworks.sh (TEXT_START_ADDR): Override.
diff --git a/ld/NEWS b/ld/NEWS
index a0d7fb24a8c003de70ef39702f97cc385aa2a799..dce9503e05e76c05215e94799aef1ca544f70713 100644 (file)
--- a/ld/NEWS
+++ b/ld/NEWS
@@ -1,5 +1,9 @@
 -*- text -*-
 
+* PE targets now add primitive support for ELF version scripts; symbols
+  are not versioned, but the local and global symbol visibility directives
+  are respected when filtering symbols in auto-export mode.
+
 * New option --no-export-dynamic to undo the effect of the -E and
   --export-dynamic options.
 
index 77846d5a545a8d9f6aa3cdadd064098c43183bf5..bdfa9484911d89baa9e9c03324f880ada96e7070 100644 (file)
@@ -1816,8 +1816,11 @@ the linker script being used by the linker.
 Specify the name of a version script to the linker.  This is typically
 used when creating shared libraries to specify additional information
 about the version hierarchy for the library being created.  This option
-is only meaningful on ELF platforms which support shared libraries.
-@xref{VERSION}.
+is only fully supported on ELF platforms which support shared libraries;
+see @ref{VERSION}.  It is partially supported on PE platforms, which can
+use version scripts to filter symbol visibility in auto-export mode: any
+symbols marked @samp{local} in the version script will not be exported.
+@xref{WIN32}.
 
 @kindex --warn-common
 @cindex warnings, on combining symbols
@@ -6582,9 +6585,19 @@ which is controlled by the following command line options:
 @item --exclude-symbols
 @item --exclude-libs
 @item --exclude-modules-for-implib
+@item --version-script
 @end itemize
 
-If, however, @samp{--export-all-symbols} is not given explicitly on the
+When auto-export is in operation, @command{ld} will export all the non-local
+(global and common) symbols it finds in a DLL, with the exception of a few
+symbols known to belong to the system's runtime and libraries.  As it will
+often not be desirable to export all of a DLL's symbols, which may include
+private functions that are not part of any public interface, the command-line
+options listed above may be used to filter symbols out from the list for 
+exporting.  The @samp{--output-def} option can be used in order to see the
+final list of exported symbols with all exclusions taken into effect.
+
+If @samp{--export-all-symbols} is not given explicitly on the
 command line, then the default auto-export behavior will be @emph{disabled}
 if either of the following are true:
 
index 397b66e587698454520c57c6740cc89bdc096172..b5470c5c75b373fc4d92ee3f5f7fd4208d42493e 100644 (file)
@@ -670,9 +670,18 @@ process_def_file (bfd *abfd ATTRIBUTE_UNUSED, struct bfd_link_info *info)
              /* We should export symbols which are either global or not
                 anything at all.  (.bss data is the latter)
                 We should not export undefined symbols.  */
-             if (symbols[j]->section != &bfd_und_section
-                 && ((symbols[j]->flags & BSF_GLOBAL)
-                     || (symbols[j]->flags == 0)))
+             bfd_boolean would_export = symbols[j]->section != &bfd_und_section
+                     && ((symbols[j]->flags & BSF_GLOBAL)
+                         || (symbols[j]->flags == 0));
+             if (lang_elf_version_info && would_export)
+               {
+                 bfd_boolean hide = 0;
+                 char ofs = pe_details->underscored && symbols[j]->name[0] == '_';
+                 (void) bfd_find_version_for_sym (lang_elf_version_info,
+                               symbols[j]->name + ofs, &hide);
+                 would_export = !hide;
+               }
+             if (would_export)
                {
                  const char *sn = symbols[j]->name;
 
diff --git a/ld/testsuite/ld-pe/vers-script-1.d b/ld/testsuite/ld-pe/vers-script-1.d
new file mode 100644 (file)
index 0000000..a6c0bec
--- /dev/null
@@ -0,0 +1,153 @@
+EXPORTS
+    A @1
+    B @2
+    C @3
+    D @4
+    E @5
+    GC_abort @6
+    GC_add_ext_descriptor @7
+    GC_add_leaked @8
+    GC_add_map_entry @9
+    GC_used_heap_size_after_full @10
+    GC_version @11
+    GC_with_callee_saves_pushed @12
+    GC_words_allocd_at_reset @13
+    GC_world_stopped @14
+    GC_write @15
+    JIS0208_to_Unicode @16
+    JIS0212_to_Unicode @17
+    JvConvertArgv @18
+    JvRunMain @19
+    JvRunMainName @20
+    Unicode_to_JIS @21
+    _Jv_AllocBytes @22
+    _Jv_AllocObject @23
+    _Jv_AllocObjectNoFinalizer @24
+    _Jv_JNIFunctions @25
+    _Jv_JNI_InvokeFunctions @26
+    _Jv_JNI_PopSystemFrame @27
+    _Jv_JVMPI_Notify_OBJECT_ALLOC @28
+    _Jv_JVMPI_Notify_THREAD_END @29
+    _Jv_JVMPI_Notify_THREAD_START @30
+    _Jv_JVMTI_Interface @31
+    _Jv_LookupInterfaceMethod @32
+    _Jv_LookupInterfaceMethodIdx @33
+    _Jv_LookupJNIMethod @34
+    _Jv_Malloc @35
+    _Jv_Throw @36
+    _Jv_ThrowAbstractMethodError @37
+    _Jv_UnwrapJNIweakReference @38
+    _Jv__mcmp @39
+    _Jv__mdiff @40
+    _Jv__mprec_bigtens @41
+    _Jv__mprec_tinytens @42
+    _Jv_argc @43
+    _Jv_argv @44
+    _Jv_b2d @45
+    _Jv_booleanClass @46
+    _Jv_byteClass @47
+    _Jv_charClass @48
+    _Jv_d2b @49
+    _Jv_ulp @50
+    _Jv_voidClass @51
+    _Z10_Jv_InitGCv @52
+    _Z10_Jv_equalnP13_Jv_Utf8ConstPN4java4lang6StringEi @53
+    _Z11_Jv_SetArgsiPPKc @54
+    _Z11_Jv_ZMallocPvjj @55
+    _Z11trie_lookupPtt @56
+    _Z12_Jv_CondWaitP23_Jv_ConditionVariable_tP11_Jv_Mutex_txi @57
+    _Z12_Jv_init_cifP13_Jv_Utf8ConstibP7ffi_cifPP9_ffi_typeS5_ @58
+    _Z12_Jv_is_proxyPv @59
+    _Z12shsTransformP8SHS_INFO @60
+    _Z13_Jv_DisableGCv @61
+    _Z15_Jv_create_coreP14_Jv_core_chainPN4java4lang6StringE @62
+    _Z16_Jv_BlockSigchldv @63
+    _Z16_Jv_BuildGCDescrPN4java4lang5ClassE @64
+    _Z16_Jv_GCFreeMemoryv @65
+    _Z16_Jv_SetStackSizePKc @66
+    _Z16_Jv_VerifyMethodP16_Jv_InterpMethod @67
+    _Z17JvNewStringLatin1PKc @68
+    _Z24_Jv_isPrimitiveOrDerivedPK13_Jv_Utf8Const @69
+    _Z26_Jv_FindSymbolInExecutablePKc @70
+    _Z26_Jv_GCInitializeFinalizersPFvvE @71
+    _Z37_Jv_FindClassFromSignatureNoExceptionPcPN4java4lang11ClassLoaderEPS_ @72
+    _Z39_Jv_ThrowNoClassDefFoundErrorTrampolineP7ffi_cifPvPS1_S1_ @73
+    _Z7in_hashPN4java4lang6ObjectE @74
+    _Z7shsInitP8SHS_INFO @75
+    _Z8shsFinalP8SHS_INFO @76
+    _Z9_Jv_AbortPKcS0_iS0_ @77
+    _Z9_Jv_RunGCv @78
+    _Z9_Jv_ZFreePvS_ @79
+    _Z9_Jv_equalP13_Jv_Utf8ConstPN4java4lang6StringEi @80
+    _Z9shsUpdateP8SHS_INFOPhi @81
+    _ZGr30_java\$Sutil\$Sweeks\$_properties @82
+    _ZGr32_java\$Sutil\$Siso4217\$_properties @83
+    _ZGr48_gnu\$Sjavax\$Sprint\$SPrinterDialog_de\$_properties @84
+    _ZGr49_gnu\$Sjava\$Slocale\$SLocaleInformation\$_properties @85
+    _ZGr51_gnu\$Sjava\$Sutil\$Sregex\$SMessagesBundle\$_properties @86
+    _ZTVN5javax8security4auth4x50021X500PrivateCredentialE @87
+    _ZTVN5javax8security4auth5login12LoginContextE @88
+    _ZTVN5javax8security4auth5login13ConfigurationE @89
+    _ZTVN5javax8security4auth5login14LoginExceptionE @90
+    _ZTVN5javax8security4sasl19RealmChoiceCallbackE @91
+    _ZTVN5javax8security4sasl23AuthenticationExceptionE @92
+    _ZTVN5javax8security4sasl4SaslE @93
+    __gcj_personality_v0 @94
+    __ieee754_acos @95
+    __ieee754_asin @96
+    __ieee754_atan2 @97
+    __kernel_cos @98
+    __kernel_rem_pio2 @99
+    __kernel_sin @100
+    __kernel_tan @101
+    _dist_code @102
+    _length_code @103
+    _mprec_log10 @104
+    _tr_align @105
+    _tr_flush_block @106
+    _tr_init @107
+    _tr_stored_block @108
+    _tr_tally @109
+    adler32 @110
+    adler32_combine @111
+    crc32 @112
+    crc32_combine @113
+    deflate @114
+    deflateBound @115
+    deflateCopy @116
+    ffi_call_STDCALL @117
+    ffi_call_SYSV @118
+    ffi_closure_SYSV @119
+    ffi_closure_SYSV_inner @120
+    ffi_closure_alloc @121
+    ffi_closure_free @122
+    free_list_index_of @123
+    get_crc_table @124
+    gzclearerr @125
+    gzclose @126
+    gzungetc @127
+    gzwrite @128
+    h0 @129
+    h1 @130
+    h2 @131
+    h3 @132
+    h4 @133
+    inflate @134
+    inflateBack @135
+    inflateBackEnd @136
+    inflate_fast @137
+    inflate_table @138
+    lt_dladderror @139
+    lt_dladdsearchdir @140
+    lt_dlsetsearchpath @141
+    lt_dlsym @142
+    lt_preloaded_symbols @143
+    print @144
+    thread_table @145
+    uncompress @146
+    zError @147
+    z_errmsg @148
+    zcalloc @149
+    zcfree @150
+    zlibCompileFlags @151
+    zlibVersion @152
diff --git a/ld/testsuite/ld-pe/vers-script-1.ver b/ld/testsuite/ld-pe/vers-script-1.ver
new file mode 100755 (executable)
index 0000000..07f54aa
--- /dev/null
@@ -0,0 +1,5 @@
+# Anonymous GNU ld version script to export everything.
+
+{
+  global: *;
+};
diff --git a/ld/testsuite/ld-pe/vers-script-2.d b/ld/testsuite/ld-pe/vers-script-2.d
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/ld/testsuite/ld-pe/vers-script-2.ver b/ld/testsuite/ld-pe/vers-script-2.ver
new file mode 100755 (executable)
index 0000000..6e7cac6
--- /dev/null
@@ -0,0 +1,5 @@
+# Anonymous GNU ld version script to export nothing.
+
+{
+  local: *;
+};
diff --git a/ld/testsuite/ld-pe/vers-script-3.d b/ld/testsuite/ld-pe/vers-script-3.d
new file mode 100644 (file)
index 0000000..679a655
--- /dev/null
@@ -0,0 +1,77 @@
+EXPORTS
+    JvConvertArgv @1
+    JvRunMain @2
+    JvRunMainName @3
+    _Jv_AllocBytes @4
+    _Jv_AllocObject @5
+    _Jv_AllocObjectNoFinalizer @6
+    _Jv_JNIFunctions @7
+    _Jv_JNI_InvokeFunctions @8
+    _Jv_JNI_PopSystemFrame @9
+    _Jv_JVMPI_Notify_OBJECT_ALLOC @10
+    _Jv_JVMPI_Notify_THREAD_END @11
+    _Jv_JVMPI_Notify_THREAD_START @12
+    _Jv_JVMTI_Interface @13
+    _Jv_LookupInterfaceMethod @14
+    _Jv_LookupInterfaceMethodIdx @15
+    _Jv_LookupJNIMethod @16
+    _Jv_Malloc @17
+    _Jv_Throw @18
+    _Jv_ThrowAbstractMethodError @19
+    _Jv_UnwrapJNIweakReference @20
+    _Jv__mcmp @21
+    _Jv__mdiff @22
+    _Jv__mprec_bigtens @23
+    _Jv__mprec_tinytens @24
+    _Jv_argc @25
+    _Jv_argv @26
+    _Jv_b2d @27
+    _Jv_booleanClass @28
+    _Jv_byteClass @29
+    _Jv_charClass @30
+    _Jv_d2b @31
+    _Jv_ulp @32
+    _Jv_voidClass @33
+    _Z10_Jv_InitGCv @34
+    _Z10_Jv_equalnP13_Jv_Utf8ConstPN4java4lang6StringEi @35
+    _Z11_Jv_SetArgsiPPKc @36
+    _Z11_Jv_ZMallocPvjj @37
+    _Z11trie_lookupPtt @38
+    _Z12_Jv_CondWaitP23_Jv_ConditionVariable_tP11_Jv_Mutex_txi @39
+    _Z12_Jv_init_cifP13_Jv_Utf8ConstibP7ffi_cifPP9_ffi_typeS5_ @40
+    _Z12_Jv_is_proxyPv @41
+    _Z12shsTransformP8SHS_INFO @42
+    _Z13_Jv_DisableGCv @43
+    _Z15_Jv_create_coreP14_Jv_core_chainPN4java4lang6StringE @44
+    _Z16_Jv_BlockSigchldv @45
+    _Z16_Jv_BuildGCDescrPN4java4lang5ClassE @46
+    _Z16_Jv_GCFreeMemoryv @47
+    _Z16_Jv_SetStackSizePKc @48
+    _Z16_Jv_VerifyMethodP16_Jv_InterpMethod @49
+    _Z17JvNewStringLatin1PKc @50
+    _Z24_Jv_isPrimitiveOrDerivedPK13_Jv_Utf8Const @51
+    _Z26_Jv_FindSymbolInExecutablePKc @52
+    _Z26_Jv_GCInitializeFinalizersPFvvE @53
+    _Z37_Jv_FindClassFromSignatureNoExceptionPcPN4java4lang11ClassLoaderEPS_ @54
+    _Z39_Jv_ThrowNoClassDefFoundErrorTrampolineP7ffi_cifPvPS1_S1_ @55
+    _Z7in_hashPN4java4lang6ObjectE @56
+    _Z7shsInitP8SHS_INFO @57
+    _Z8shsFinalP8SHS_INFO @58
+    _Z9_Jv_AbortPKcS0_iS0_ @59
+    _Z9_Jv_RunGCv @60
+    _Z9_Jv_ZFreePvS_ @61
+    _Z9_Jv_equalP13_Jv_Utf8ConstPN4java4lang6StringEi @62
+    _Z9shsUpdateP8SHS_INFOPhi @63
+    _ZGr30_java\$Sutil\$Sweeks\$_properties @64
+    _ZGr32_java\$Sutil\$Siso4217\$_properties @65
+    _ZGr48_gnu\$Sjavax\$Sprint\$SPrinterDialog_de\$_properties @66
+    _ZGr49_gnu\$Sjava\$Slocale\$SLocaleInformation\$_properties @67
+    _ZGr51_gnu\$Sjava\$Sutil\$Sregex\$SMessagesBundle\$_properties @68
+    _ZTVN5javax8security4auth4x50021X500PrivateCredentialE @69
+    _ZTVN5javax8security4auth5login12LoginContextE @70
+    _ZTVN5javax8security4auth5login13ConfigurationE @71
+    _ZTVN5javax8security4auth5login14LoginExceptionE @72
+    _ZTVN5javax8security4sasl19RealmChoiceCallbackE @73
+    _ZTVN5javax8security4sasl23AuthenticationExceptionE @74
+    _ZTVN5javax8security4sasl4SaslE @75
+    __gcj_personality_v0 @76
diff --git a/ld/testsuite/ld-pe/vers-script-3.ver b/ld/testsuite/ld-pe/vers-script-3.ver
new file mode 100755 (executable)
index 0000000..d2d189b
--- /dev/null
@@ -0,0 +1,7 @@
+# Anonymous GNU ld version script to hide boehm-gc, libffi and fdlibm
+# symbols in libgcj.so.
+
+{
+  global: Jv*; _Jv_*; __gcj_personality_v0; __gcj_personality_sj0; _Z*;
+  local: *;
+};
diff --git a/ld/testsuite/ld-pe/vers-script-4.d b/ld/testsuite/ld-pe/vers-script-4.d
new file mode 100644 (file)
index 0000000..679a655
--- /dev/null
@@ -0,0 +1,77 @@
+EXPORTS
+    JvConvertArgv @1
+    JvRunMain @2
+    JvRunMainName @3
+    _Jv_AllocBytes @4
+    _Jv_AllocObject @5
+    _Jv_AllocObjectNoFinalizer @6
+    _Jv_JNIFunctions @7
+    _Jv_JNI_InvokeFunctions @8
+    _Jv_JNI_PopSystemFrame @9
+    _Jv_JVMPI_Notify_OBJECT_ALLOC @10
+    _Jv_JVMPI_Notify_THREAD_END @11
+    _Jv_JVMPI_Notify_THREAD_START @12
+    _Jv_JVMTI_Interface @13
+    _Jv_LookupInterfaceMethod @14
+    _Jv_LookupInterfaceMethodIdx @15
+    _Jv_LookupJNIMethod @16
+    _Jv_Malloc @17
+    _Jv_Throw @18
+    _Jv_ThrowAbstractMethodError @19
+    _Jv_UnwrapJNIweakReference @20
+    _Jv__mcmp @21
+    _Jv__mdiff @22
+    _Jv__mprec_bigtens @23
+    _Jv__mprec_tinytens @24
+    _Jv_argc @25
+    _Jv_argv @26
+    _Jv_b2d @27
+    _Jv_booleanClass @28
+    _Jv_byteClass @29
+    _Jv_charClass @30
+    _Jv_d2b @31
+    _Jv_ulp @32
+    _Jv_voidClass @33
+    _Z10_Jv_InitGCv @34
+    _Z10_Jv_equalnP13_Jv_Utf8ConstPN4java4lang6StringEi @35
+    _Z11_Jv_SetArgsiPPKc @36
+    _Z11_Jv_ZMallocPvjj @37
+    _Z11trie_lookupPtt @38
+    _Z12_Jv_CondWaitP23_Jv_ConditionVariable_tP11_Jv_Mutex_txi @39
+    _Z12_Jv_init_cifP13_Jv_Utf8ConstibP7ffi_cifPP9_ffi_typeS5_ @40
+    _Z12_Jv_is_proxyPv @41
+    _Z12shsTransformP8SHS_INFO @42
+    _Z13_Jv_DisableGCv @43
+    _Z15_Jv_create_coreP14_Jv_core_chainPN4java4lang6StringE @44
+    _Z16_Jv_BlockSigchldv @45
+    _Z16_Jv_BuildGCDescrPN4java4lang5ClassE @46
+    _Z16_Jv_GCFreeMemoryv @47
+    _Z16_Jv_SetStackSizePKc @48
+    _Z16_Jv_VerifyMethodP16_Jv_InterpMethod @49
+    _Z17JvNewStringLatin1PKc @50
+    _Z24_Jv_isPrimitiveOrDerivedPK13_Jv_Utf8Const @51
+    _Z26_Jv_FindSymbolInExecutablePKc @52
+    _Z26_Jv_GCInitializeFinalizersPFvvE @53
+    _Z37_Jv_FindClassFromSignatureNoExceptionPcPN4java4lang11ClassLoaderEPS_ @54
+    _Z39_Jv_ThrowNoClassDefFoundErrorTrampolineP7ffi_cifPvPS1_S1_ @55
+    _Z7in_hashPN4java4lang6ObjectE @56
+    _Z7shsInitP8SHS_INFO @57
+    _Z8shsFinalP8SHS_INFO @58
+    _Z9_Jv_AbortPKcS0_iS0_ @59
+    _Z9_Jv_RunGCv @60
+    _Z9_Jv_ZFreePvS_ @61
+    _Z9_Jv_equalP13_Jv_Utf8ConstPN4java4lang6StringEi @62
+    _Z9shsUpdateP8SHS_INFOPhi @63
+    _ZGr30_java\$Sutil\$Sweeks\$_properties @64
+    _ZGr32_java\$Sutil\$Siso4217\$_properties @65
+    _ZGr48_gnu\$Sjavax\$Sprint\$SPrinterDialog_de\$_properties @66
+    _ZGr49_gnu\$Sjava\$Slocale\$SLocaleInformation\$_properties @67
+    _ZGr51_gnu\$Sjava\$Sutil\$Sregex\$SMessagesBundle\$_properties @68
+    _ZTVN5javax8security4auth4x50021X500PrivateCredentialE @69
+    _ZTVN5javax8security4auth5login12LoginContextE @70
+    _ZTVN5javax8security4auth5login13ConfigurationE @71
+    _ZTVN5javax8security4auth5login14LoginExceptionE @72
+    _ZTVN5javax8security4sasl19RealmChoiceCallbackE @73
+    _ZTVN5javax8security4sasl23AuthenticationExceptionE @74
+    _ZTVN5javax8security4sasl4SaslE @75
+    __gcj_personality_v0 @76
diff --git a/ld/testsuite/ld-pe/vers-script-4.ver b/ld/testsuite/ld-pe/vers-script-4.ver
new file mode 100755 (executable)
index 0000000..f38abf1
--- /dev/null
@@ -0,0 +1,10 @@
+# GNU ld version script to hide boehm-gc, libffi and fdlibm
+# symbols in libgcj.so.
+
+TEST_1_0 {
+  local: *;
+};
+
+TEST_1_1 {
+  global: Jv*; _Jv_*; __gcj_personality_v0; __gcj_personality_sj0; _Z*;
+};
\ No newline at end of file
diff --git a/ld/testsuite/ld-pe/vers-script-dll.c b/ld/testsuite/ld-pe/vers-script-dll.c
new file mode 100755 (executable)
index 0000000..9b7a574
--- /dev/null
@@ -0,0 +1,156 @@
+
+#define FUNC(X_)  extern void X_ (void); void X_ (void) { };
+
+FUNC(A)
+FUNC(B)
+FUNC(C)
+FUNC(D)
+FUNC(E)
+FUNC(GC_abort)
+FUNC(GC_add_ext_descriptor)
+FUNC(GC_add_leaked)
+FUNC(GC_add_map_entry)
+FUNC(GC_used_heap_size_after_full)
+FUNC(GC_version)
+FUNC(GC_with_callee_saves_pushed)
+FUNC(GC_words_allocd_at_reset)
+FUNC(GC_world_stopped)
+FUNC(GC_write)
+FUNC(JIS0208_to_Unicode)
+FUNC(JIS0212_to_Unicode)
+FUNC(JvConvertArgv)
+FUNC(JvRunMain)
+FUNC(JvRunMainName)
+FUNC(Unicode_to_JIS)
+FUNC(_Jv_AllocBytes)
+FUNC(_Jv_AllocObject)
+FUNC(_Jv_AllocObjectNoFinalizer)
+FUNC(_ZTVN5javax8security4sasl23AuthenticationExceptionE)
+FUNC(_ZTVN5javax8security4sasl4SaslE)
+FUNC(__gcj_personality_v0)
+FUNC(__ieee754_acos)
+FUNC(__ieee754_asin)
+FUNC(__ieee754_atan2)
+FUNC(__kernel_cos)
+FUNC(__kernel_rem_pio2)
+FUNC(__kernel_sin)
+FUNC(__kernel_tan)
+FUNC(_dist_code)
+FUNC(_length_code)
+FUNC(_mprec_log10)
+FUNC(_tr_align)
+FUNC(_tr_flush_block)
+FUNC(_tr_init)
+FUNC(_tr_stored_block)
+FUNC(_tr_tally)
+FUNC(adler32)
+FUNC(adler32_combine)
+FUNC(crc32)
+FUNC(crc32_combine)
+FUNC(deflate)
+FUNC(deflateBound)
+FUNC(deflateCopy)
+FUNC(ffi_call_STDCALL)
+FUNC(ffi_call_SYSV)
+FUNC(ffi_closure_SYSV)
+FUNC(ffi_closure_SYSV_inner)
+FUNC(ffi_closure_alloc)
+FUNC(ffi_closure_free)
+FUNC(free_list_index_of)
+FUNC(get_crc_table)
+FUNC(gzclearerr)
+FUNC(gzclose)
+FUNC(gzungetc)
+FUNC(gzwrite)
+FUNC(h0)
+FUNC(h1)
+FUNC(h2)
+FUNC(h3)
+FUNC(h4)
+FUNC(inflate)
+FUNC(inflateBack)
+FUNC(inflateBackEnd)
+FUNC(inflate_fast)
+FUNC(inflate_table)
+FUNC(lt_dladderror)
+FUNC(lt_dladdsearchdir)
+FUNC(lt_dlsetsearchpath)
+FUNC(lt_dlsym)
+FUNC(lt_preloaded_symbols)
+FUNC(print)
+FUNC(thread_table)
+FUNC(uncompress)
+FUNC(zError)
+FUNC(z_errmsg)
+FUNC(zcalloc)
+FUNC(zcfree)
+FUNC(zlibCompileFlags)
+FUNC(zlibVersion)
+FUNC(_Jv_JNIFunctions)
+FUNC(_Jv_JNI_InvokeFunctions)
+FUNC(_Jv_JNI_PopSystemFrame)
+FUNC(_Jv_JVMPI_Notify_OBJECT_ALLOC)
+FUNC(_Jv_JVMPI_Notify_THREAD_END)
+FUNC(_Jv_JVMPI_Notify_THREAD_START)
+FUNC(_Jv_JVMTI_Interface)
+FUNC(_Jv_LookupInterfaceMethod)
+FUNC(_Jv_LookupInterfaceMethodIdx)
+FUNC(_Jv_LookupJNIMethod)
+FUNC(_Jv_Malloc)
+FUNC(_Jv_Throw)
+FUNC(_Jv_ThrowAbstractMethodError)
+FUNC(_Jv_UnwrapJNIweakReference)
+FUNC(_Jv__mcmp)
+FUNC(_Jv__mdiff)
+FUNC(_Jv__mprec_bigtens)
+FUNC(_Jv__mprec_tinytens)
+FUNC(_Jv_argc)
+FUNC(_Jv_argv)
+FUNC(_Jv_b2d)
+FUNC(_Jv_booleanClass)
+FUNC(_Jv_byteClass)
+FUNC(_Jv_charClass)
+FUNC(_Jv_d2b)
+FUNC(_Jv_ulp)
+FUNC(_Jv_voidClass)
+FUNC(_Z10_Jv_InitGCv)
+FUNC(_Z10_Jv_equalnP13_Jv_Utf8ConstPN4java4lang6StringEi)
+FUNC(_Z11_Jv_SetArgsiPPKc)
+FUNC(_Z11_Jv_ZMallocPvjj)
+FUNC(_Z11trie_lookupPtt)
+FUNC(_Z12_Jv_CondWaitP23_Jv_ConditionVariable_tP11_Jv_Mutex_txi)
+FUNC(_Z12_Jv_init_cifP13_Jv_Utf8ConstibP7ffi_cifPP9_ffi_typeS5_)
+FUNC(_Z12_Jv_is_proxyPv)
+FUNC(_Z12shsTransformP8SHS_INFO)
+FUNC(_Z13_Jv_DisableGCv)
+FUNC(_Z15_Jv_create_coreP14_Jv_core_chainPN4java4lang6StringE)
+FUNC(_Z16_Jv_BlockSigchldv)
+FUNC(_Z16_Jv_BuildGCDescrPN4java4lang5ClassE)
+FUNC(_Z16_Jv_GCFreeMemoryv)
+FUNC(_Z16_Jv_SetStackSizePKc)
+FUNC(_Z16_Jv_VerifyMethodP16_Jv_InterpMethod)
+FUNC(_Z17JvNewStringLatin1PKc)
+FUNC(_ZTVN5javax8security4auth4x50021X500PrivateCredentialE)
+FUNC(_ZTVN5javax8security4auth5login12LoginContextE)
+FUNC(_ZTVN5javax8security4auth5login13ConfigurationE)
+FUNC(_ZTVN5javax8security4auth5login14LoginExceptionE)
+FUNC(_ZTVN5javax8security4sasl19RealmChoiceCallbackE)
+FUNC(_Z24_Jv_isPrimitiveOrDerivedPK13_Jv_Utf8Const)
+FUNC(_Z26_Jv_FindSymbolInExecutablePKc)
+FUNC(_Z26_Jv_GCInitializeFinalizersPFvvE)
+FUNC(_Z37_Jv_FindClassFromSignatureNoExceptionPcPN4java4lang11ClassLoaderEPS_)
+FUNC(_Z39_Jv_ThrowNoClassDefFoundErrorTrampolineP7ffi_cifPvPS1_S1_)
+FUNC(_Z7in_hashPN4java4lang6ObjectE)
+FUNC(_Z7shsInitP8SHS_INFO)
+FUNC(_Z8shsFinalP8SHS_INFO)
+FUNC(_Z9_Jv_AbortPKcS0_iS0_)
+FUNC(_Z9_Jv_RunGCv)
+FUNC(_Z9_Jv_ZFreePvS_)
+FUNC(_Z9_Jv_equalP13_Jv_Utf8ConstPN4java4lang6StringEi)
+FUNC(_Z9shsUpdateP8SHS_INFOPhi)
+FUNC(_ZGr30_java$Sutil$Sweeks$_properties)
+FUNC(_ZGr32_java$Sutil$Siso4217$_properties)
+FUNC(_ZGr48_gnu$Sjavax$Sprint$SPrinterDialog_de$_properties)
+FUNC(_ZGr49_gnu$Sjava$Slocale$SLocaleInformation$_properties)
+FUNC(_ZGr51_gnu$Sjava$Sutil$Sregex$SMessagesBundle$_properties)
+
diff --git a/ld/testsuite/ld-pe/vers-script.exp b/ld/testsuite/ld-pe/vers-script.exp
new file mode 100755 (executable)
index 0000000..e0638b1
--- /dev/null
@@ -0,0 +1,76 @@
+# Expect script for version-script driven export from dll tests
+#   Copyright 2009
+#   Free Software Foundation, Inc.
+#
+# This file is part of the GNU Binutils.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+# MA 02110-1301, USA.
+#
+
+# This test can only be run on PE/COFF platforms.
+if {![is_pecoff_format]} {
+    return
+}
+
+# No compiler, no test.
+if { [which $CC] == 0 } {
+    untested "PE version scripts"
+    return
+}
+
+proc build_vers_script_dll_o {} {
+    global CC
+    global CFLAGS
+    global srcdir
+    global subdir
+    
+    # Compile the object file.
+    if ![ld_compile "$CC $CFLAGS -shared" $srcdir/$subdir/vers-script-dll.c tmpdir/vers-script-dll.o] {
+       fail "compiling shared lib object"
+    }
+}
+
+proc run_ver_script_test { testname } {
+    global CC
+    global srcdir
+    global subdir
+    global verbose
+
+    if ![ld_simple_link "$CC -shared \
+           -Wl,--version-script,$srcdir/$subdir/$testname.ver \
+           -Wl,--output-def,tmpdir/$testname.def" tmpdir/$testname.dll \
+           "tmpdir/vers-script-dll.o"] {
+       fail "linking DLL"
+    }
+
+    if { $verbose > 2 } then { verbose "output is [file_contents tmpdir/$testname.def]" 3 }
+    if { [regexp_diff tmpdir/$testname.def $srcdir/$subdir/$testname.d] } then {
+       fail $testname
+       if { $verbose == 2 } then { verbose "output is [file_contents tmpdir/$testname.def]" 2 }
+       return
+    }
+
+    pass "$testname"
+}
+
+
+build_vers_script_dll_o
+
+run_ver_script_test "vers-script-1"
+run_ver_script_test "vers-script-2"
+run_ver_script_test "vers-script-3"
+run_ver_script_test "vers-script-4"
+