Bug 24527 - Linker GOLD: Symbols inside 'extern "C++"' or 'extern "Java"' in version scripts are not matched
Summary: Linker GOLD: Symbols inside 'extern "C++"' or 'extern "Java"' in version scri...
Status: UNCONFIRMED
Alias: None
Product: binutils
Classification: Unclassified
Component: gold (show other bugs)
Version: 2.32
: P2 normal
Target Milestone: ---
Assignee: Cary Coutant
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-05-06 03:52 UTC by Arfrever Frehtes Taifersar Arahesis
Modified: 2022-03-09 20:04 UTC (History)
6 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Arfrever Frehtes Taifersar Arahesis 2019-05-06 03:52:24 UTC
$ cat test.s
	.data
	.globl	C_data
C_data:

	.text
	.globl	C_text
C_text:

	.data
	.globl	CPLUSPLUS_data
CPLUSPLUS_data:

	.text
	.globl	CPLUSPLUS_text
CPLUSPLUS_text:

	.data
	.globl	JAVA_data
JAVA_data:

	.text
	.globl	JAVA_text
JAVA_text:

	.data
	.globl	XXX_1
XXX_1:
	.globl	XXX_2
XXX_2:

	.text
	.globl	XXX_3
XXX_3:
	.globl	XXX_4
XXX_4:
$ cat test.map
{
  global:
    extern "C" {
      C_*;
    };
    extern "C++" {
      CPLUSPLUS_*;
    };
    extern "Java" {
      JAVA_*;
    };

  local:
    *;
};
$ gcc -fuse-ld=bfd -shared -Wl,--version-script=test.map -o test_bfd.so test.s
$ gcc -fuse-ld=gold -shared -Wl,--version-script=test.map -o test_gold.so test.s
$ 


Comparison between library built with linker BFD and library built with linker GOLD:

$ diff -u10 <(nm test_bfd.so | sed -e "s/^[0-9a-f]\+ //") <(nm test_gold.so | sed -e "s/^[0-9a-f]\+ //")
--- /dev/fd/63
+++ /dev/fd/62
@@ -1,30 +1,34 @@
-D CPLUSPLUS_data
-T CPLUSPLUS_text
+d CPLUSPLUS_data
+t CPLUSPLUS_text
 D C_data
 T C_text
-D JAVA_data
-T JAVA_text
+d JAVA_data
+t JAVA_text
 d XXX_1
 d XXX_2
 t XXX_3
 t XXX_4
 d _DYNAMIC
 d _GLOBAL_OFFSET_TABLE_
                  w _ITM_deregisterTMCloneTable
                  w _ITM_registerTMCloneTable
 r __FRAME_END__
 d __TMC_END__
-                 w __cxa_finalize@@GLIBC_2.2.5
+d __TMC_LIST__
+t __bss_start
+                 w __cxa_finalize
 t __do_global_dtors_aux
 t __do_global_dtors_aux_fini_array_entry
 d __dso_handle
 t __frame_dummy_init_array_entry
                  w __gmon_start__
 t __x86_indirect_thunk_rax
 t __x86_return_thunk
+t _edata
+t _end
 t _fini
 t _init
 b completed.7940
 t deregister_tm_clones
 t frame_dummy
 t register_tm_clones
$ 


All versions of linker GOLD (including current trunk) are affected.

Problem originally found when building Protocol Buffers with GOLD:
https://bugs.gentoo.org/683892
Protocol Buffers 3.7.1 has this version script which hides all symbols other than *google*:
https://github.com/protocolbuffers/protobuf/blob/v3.7.1/src/libprotobuf.map