PATCH: A testcase (Re: PATCH: A strang symbol versioning problem)

H. J. Lu hjl@lucon.org
Sun Aug 11 15:07:00 GMT 2002


On Sat, Aug 10, 2002 at 11:58:11PM -0700, H. J. Lu wrote:
> On Sat, Aug 10, 2002 at 03:06:10PM -0700, H. J. Lu wrote:
> > 
> > Here is a small testcase
> > 
> > # make
> > gcc  -B./ -g -fPIC   -c -o foo.o foo.c
> > gcc: file path prefix `./' never used
> > gcc  -B./ -g -fPIC   -c -o new.o new.c
> > gcc: file path prefix `./' never used
> > gcc  -B./ -Wl,--version-script=bar.map  -shared -o libnew.so new.o
> > gcc: file path prefix `./' never used
> > gcc  -B./ -shared -o libfoo.so -Wl,-rpath,. foo.o libnew.so
> > gcc: file path prefix `./' never used
> > gcc  -B./ -g -fPIC   -c -o old.o old.c
> > gcc: file path prefix `./' never used
> > gcc  -B./ -Wl,--version-script=bar.map  -shared -o libold.so old.o
> > gcc: file path prefix `./' never used
> > gcc  -B./ -o main -Wl,-rpath,. main.c libfoo.so libold.so new.o
> > ./libnew.so(*IND*+0x0): multiple definition of `bar@VERS.0'
> > libold.so(.text+0x12c): first defined here
> > collect2: ld returned 1 exit status
> > gcc: file path prefix `./' never used
> > make: *** [main] Error 1
> > 
> > I will see what I can do.
> 
> The problem is the section pointer got changed across the call to
> elf_merge_symbol. If the first call changes the section pointer to
> undefined due to override, the next call to elf_merge_symbol will
> be confused. I am enclosing a patch here. Do we expect/want the
> section pointer gets changed after elf_add_default_symbol? Any
> comments?
> 
> 

Here is the patch to add a testcase. I will take another look at my
patch to make sure it is correct.


H.J.
---
-------------- next part --------------
2002-08-11  H.J. Lu <hjl@gnu.org>

	* ld-elfvers/vers.exp: Add vers23.

	* ld-elfvers/vers23.c: New.
	* ld-elfvers/vers23.dsym: New.
	* ld-elfvers/vers23.ver: New.
	* ld-elfvers/vers23a.c: New.
	* ld-elfvers/vers23a.dsym: New.
	* ld-elfvers/vers23a.map: New.
	* ld-elfvers/vers23a.sym: New.
	* ld-elfvers/vers23a.ver: New.
	* ld-elfvers/vers23b.c: New.
	* ld-elfvers/vers23b.dsym: New.
	* ld-elfvers/vers23b.map: New.
	* ld-elfvers/vers23b.ver: New.

--- ld/testsuite/ld-elfvers/vers.exp.add	Thu Aug  8 22:16:49 2002
+++ ld/testsuite/ld-elfvers/vers.exp	Sun Aug 11 14:51:58 2002
@@ -831,3 +831,8 @@ build_vers_lib "vers21" vers21.c vers21 
 build_vers_lib "vers22a" vers22a.c vers22a "" vers22.map vers22a.ver vers22a.dsym vers22a.sym
 build_vers_lib "vers22b" vers22b.c vers22b "" vers22.map vers22b.ver vers22b.dsym ""
 build_vers_lib "vers22" vers22.c vers22 "vers22a.so vers22b.so" "" vers22.ver vers22.dsym ""
+
+# Test versioned definitions in different files.
+build_vers_lib "vers23a" vers23a.c vers23a "" vers23a.map vers23a.ver vers23a.dsym vers23a.sym
+build_vers_lib "vers23b" vers23b.c vers23b "" vers23b.map vers23b.ver vers23b.dsym ""
+build_exec "vers23" vers23.c vers23 "tmpdir/vers23a.so tmpdir/vers23b.o tmpdir/vers23b.so" "" vers23.ver vers23.dsym ""
--- ld/testsuite/ld-elfvers/vers23.c.add	Sun Aug 11 14:58:28 2002
+++ ld/testsuite/ld-elfvers/vers23.c	Sun Aug 11 14:49:45 2002
@@ -0,0 +1,5 @@
+main ()
+{
+  bar ();
+  foo ();
+}
--- ld/testsuite/ld-elfvers/vers23.dsym.add	Sun Aug 11 14:58:28 2002
+++ ld/testsuite/ld-elfvers/vers23.dsym	Sun Aug 11 14:56:56 2002
@@ -0,0 +1 @@
+[0-9a-f]*      DF \*UND\*	[0-9a-f]*  VERS.0      (0x[0-9a-f][0-9a-f] )?foo
--- ld/testsuite/ld-elfvers/vers23.ver.add	Sun Aug 11 14:58:29 2002
+++ ld/testsuite/ld-elfvers/vers23.ver	Sun Aug 11 15:03:08 2002
@@ -0,0 +1,4 @@
+Version References:
+  required from tmpdir/vers23a.so:
+    0x05aa7610 0x00 ?? VERS.0
+
--- ld/testsuite/ld-elfvers/vers23a.c.add	Sun Aug 11 14:58:28 2002
+++ ld/testsuite/ld-elfvers/vers23a.c	Sun Aug 11 14:53:04 2002
@@ -0,0 +1,11 @@
+__asm__(".symver _old_bar,bar@VERS.0");
+
+void
+_old_bar (void) 
+{
+}
+
+void
+foo (void) 
+{
+}
--- ld/testsuite/ld-elfvers/vers23a.dsym.add	Sun Aug 11 14:58:28 2002
+++ ld/testsuite/ld-elfvers/vers23a.dsym	Sun Aug 11 14:54:48 2002
@@ -0,0 +1,3 @@
+[0]*[ 	]+g[ 	]+DO[ 	]+\*ABS\*[ 	]+[0]*[ 	]+VERS.0[ 	]+VERS.0
+[0-9a-f]*[ 	]+g[ 	]+DF[ 	]+.text[	]+[0-9a-f]*[ 	]+\(VERS.0\)[ 	]+(0x[0-9a-f]*|)[ 	]*bar
+[0-9a-f]*[ 	]+g[ 	]+DF[ 	]+.text[	]+[0-9a-f]*[ 	]+VERS.0[ 	]+(0x[0-9a-f]*|)[ 	]*foo
--- ld/testsuite/ld-elfvers/vers23a.map.add	Sun Aug 11 14:58:28 2002
+++ ld/testsuite/ld-elfvers/vers23a.map	Sun Aug 11 14:52:40 2002
@@ -0,0 +1,5 @@
+VERS.0 {
+  global:
+    bar;
+    foo;
+};
--- ld/testsuite/ld-elfvers/vers23a.sym.add	Sun Aug 11 14:58:28 2002
+++ ld/testsuite/ld-elfvers/vers23a.sym	Sun Aug 11 14:34:15 2002
@@ -0,0 +1 @@
+[0-9a-f]*[ 	]+g[ 	]+F[ 	]+.text[ 	]+[0-9a-f]* (0x[0-9a-f][0-9a-f] )?bar@VERS.0
--- ld/testsuite/ld-elfvers/vers23a.ver.add	Sun Aug 11 14:58:28 2002
+++ ld/testsuite/ld-elfvers/vers23a.ver	Sun Aug 11 14:35:28 2002
@@ -0,0 +1,4 @@
+Version definitions:
+1 0x01 0x065f090f vers23a.so
+2 0x00 0x05aa7610 VERS.0
+
--- ld/testsuite/ld-elfvers/vers23b.c.add	Sun Aug 11 14:58:28 2002
+++ ld/testsuite/ld-elfvers/vers23b.c	Sun Aug 11 14:52:52 2002
@@ -0,0 +1,4 @@
+void
+bar (void) 
+{
+}
--- ld/testsuite/ld-elfvers/vers23b.dsym.add	Sun Aug 11 14:58:28 2002
+++ ld/testsuite/ld-elfvers/vers23b.dsym	Sun Aug 11 14:53:28 2002
@@ -0,0 +1,2 @@
+[0]*[ 	]+g[ 	]+DO[ 	]+\*ABS\*[ 	]+[0]*[ 	]+VERS.0[ 	]+VERS.0
+[0-9a-f]*[ 	]+g[ 	]+DF[ 	]+.text[	]+[0-9a-f]*[ 	]+VERS.0[ 	]+(0x[0-9a-f]*|)[ 	]*bar
--- ld/testsuite/ld-elfvers/vers23b.map.add	Sun Aug 11 14:58:28 2002
+++ ld/testsuite/ld-elfvers/vers23b.map	Sun Aug 11 14:52:44 2002
@@ -0,0 +1,4 @@
+VERS.0 {
+  global:
+    bar;
+};
--- ld/testsuite/ld-elfvers/vers23b.ver.add	Sun Aug 11 14:58:28 2002
+++ ld/testsuite/ld-elfvers/vers23b.ver	Sun Aug 11 14:35:16 2002
@@ -0,0 +1,4 @@
+Version definitions:
+1 0x01 0x065e990f vers23b.so
+2 0x00 0x05aa7610 VERS.0
+


More information about the Binutils mailing list