This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] Fix --dynamic-list
- From: "H. J. Lu" <hjl at lucon dot org>
- To: Nick Clifton <nickc at redhat dot com>
- Cc: Jakub Jelinek <jakub at redhat dot com>, binutils at sources dot redhat dot com
- Date: Mon, 16 Oct 2006 10:03:37 -0700
- Subject: Re: [PATCH] Fix --dynamic-list
- References: <Pine.LNX.4.64.0607261822590.25141@wotan.suse.de> <20060727171133.GA14609@lucon.org> <Pine.LNX.4.64.0607281452000.25141@wotan.suse.de> <20060728174040.GA24620@lucon.org> <20060808165950.GA27903@lucon.org> <Pine.LNX.4.64.0608081928530.25141@wotan.suse.de> <20060809193918.GA5352@lucon.org> <45003A75.3080501@redhat.com> <20061010154936.GI4556@sunsite.mff.cuni.cz> <452CA576.3000303@redhat.com>
On Wed, Oct 11, 2006 at 09:04:06AM +0100, Nick Clifton wrote:
> Hi Jakub,
>
> >BTW, I have noticed that you have changed info->symbolic to SYMBOLIC_BIND
> >in a bunch of generic places and i386,x86_64,ia64 ELF backends, but not at
> >all in the other backends. Should that be changed in all the other
> >backends too? I see the remaining ->symbolic in elflink.c is intentional,
> >but what about elf32-arm.c, elf32-bfin.c, elf32-cris.c, elf32-hppa.c,
> >elf32-i370.c, elf32-m32r.c, elf32-m68k.c, elf32-ppc.c, elf32-s390.c,
> >elf32-score.c, elf32-sh.c, elf32-vax.c, elf64-alpha.c, elf64-hppa.c,
> >elf64-s390.c, elf64-sh64.c, elf-m10300.c, elfxx-mips.c and elfxx-sparc.c?
>
> Yes I think that this would be a good idea. Thanks for catching it.
>
> >2006-10-10 Jakub Jelinek <jakub@redhat.com>
> >
> > * ldlang.c (lang_append_dynamic_list): When appending, add all
> > elements
> > of the dynamic list rather than just the first entry.
>
> Approved - please apply.
>
Here is the patch to add some testcases for this.
H.J.
-----
2006-10-16 H.J. Lu <hongjiu.lu@intel.com>
* ld-elf/dl4.c: New file.
* ld-elf/dl4.list: Likewise.
* ld-elf/dl4a.out: Likewise.
* ld-elf/dl4b.out: Likewise.
* ld-elf/dl4main.c: Likewise.
* ld-elf/dl4xxx.c: Likewise.
* ld-elf/dl4xxx.list: Likewise.
* ld-elf/shared.exp (build_tests): Add libdl4a.so and
libdl4b.so.
(run_tests): Likewise.
--- ld/testsuite/ld-elf/dl4.c.dl 2006-10-16 09:42:09.000000000 -0700
+++ ld/testsuite/ld-elf/dl4.c 2006-10-16 09:42:09.000000000 -0700
@@ -0,0 +1,24 @@
+#include <stdio.h>
+
+int foo1;
+int foo2;
+
+extern void xxx1 (void);
+extern void xxx2 (void);
+
+void
+bar (int x)
+{
+ if (foo1 == 1)
+ printf ("bar OK1\n");
+ else if (foo1 == 0)
+ printf ("bar OK2\n");
+ if (foo2 == 1)
+ printf ("bar OK3\n");
+ else if (foo2 == 0)
+ printf ("bar OK4\n");
+ foo1 = -1;
+ foo2 = -1;
+ xxx1 ();
+ xxx2 ();
+}
--- ld/testsuite/ld-elf/dl4.list.dl 2006-10-16 09:42:09.000000000 -0700
+++ ld/testsuite/ld-elf/dl4.list 2006-10-16 09:42:09.000000000 -0700
@@ -0,0 +1,4 @@
+{
+ foo1;
+ foo2;
+};
--- ld/testsuite/ld-elf/dl4a.out.dl 2006-10-16 09:42:09.000000000 -0700
+++ ld/testsuite/ld-elf/dl4a.out 2006-10-16 09:42:09.000000000 -0700
@@ -0,0 +1,6 @@
+bar OK1
+bar OK3
+DSO1
+DSO2
+OK1
+OK3
--- ld/testsuite/ld-elf/dl4b.out.dl 2006-10-16 09:42:09.000000000 -0700
+++ ld/testsuite/ld-elf/dl4b.out 2006-10-16 09:55:17.000000000 -0700
@@ -0,0 +1,6 @@
+bar OK1
+bar OK3
+MAIN1
+MAIN2
+OK1
+OK3
--- ld/testsuite/ld-elf/dl4main.c.dl 2006-10-16 09:42:09.000000000 -0700
+++ ld/testsuite/ld-elf/dl4main.c 2006-10-16 09:53:44.000000000 -0700
@@ -0,0 +1,34 @@
+#include <stdio.h>
+
+extern int foo1;
+extern int foo2;
+extern void bar (void);
+
+void
+xxx1 (void)
+{
+ printf ("MAIN1\n");
+}
+
+void
+xxx2 (void)
+{
+ printf ("MAIN2\n");
+}
+
+int
+main (void)
+{
+ foo1 = 1;
+ foo2 = 1;
+ bar ();
+ if (foo1 == -1)
+ printf ("OK1\n");
+ else if (foo1 == 1)
+ printf ("OK2\n");
+ if (foo2 == -1)
+ printf ("OK3\n");
+ else if (foo2 == 1)
+ printf ("OK4\n");
+ return 0;
+}
--- ld/testsuite/ld-elf/dl4xxx.c.dl 2006-10-16 09:42:09.000000000 -0700
+++ ld/testsuite/ld-elf/dl4xxx.c 2006-10-16 09:42:09.000000000 -0700
@@ -0,0 +1,13 @@
+#include <stdio.h>
+
+void
+xxx1 (void)
+{
+ printf ("DSO1\n");
+}
+
+void
+xxx2 (void)
+{
+ printf ("DSO2\n");
+}
--- ld/testsuite/ld-elf/dl4xxx.list.dl 2006-10-16 09:42:09.000000000 -0700
+++ ld/testsuite/ld-elf/dl4xxx.list 2006-10-16 09:42:09.000000000 -0700
@@ -0,0 +1,4 @@
+{
+ xxx1;
+ xxx2;
+};
--- ld/testsuite/ld-elf/shared.exp.dl 2006-10-16 08:30:47.000000000 -0700
+++ ld/testsuite/ld-elf/shared.exp 2006-10-16 09:42:09.000000000 -0700
@@ -75,6 +75,12 @@ set build_tests {
{"Build libdl2b.so with --dynamic-list=dl2.list and dl2xxx.list"
"-shared -Wl,--dynamic-list=dl2.list,--dynamic-list=dl2xxx.list" "-fPIC"
{dl2.c dl2xxx.c} {} "libdl2b.so"}
+ {"Build libdl4a.so with --dynamic-list=dl4.list"
+ "-shared -Wl,--dynamic-list=dl4.list" "-fPIC"
+ {dl4.c dl4xxx.c} {} "libdl4a.so"}
+ {"Build libdl4b.so with --dynamic-list=dl4.list and dl4xxx.list"
+ "-shared -Wl,--dynamic-list=dl4.list,--dynamic-list=dl4xxx.list" "-fPIC"
+ {dl4.c dl4xxx.c} {} "libdl4b.so"}
}
set run_tests {
@@ -123,6 +129,12 @@ set run_tests {
{"Run with libdl2b.so"
"tmpdir/libdl2b.so" ""
{dl2main.c} "dl2b" "dl2b.out"}
+ {"Run with libdl4a.so"
+ "tmpdir/libdl4a.so" ""
+ {dl4main.c} "dl4a" "dl4a.out"}
+ {"Run with libdl4b.so"
+ "tmpdir/libdl4b.so" ""
+ {dl4main.c} "dl4b" "dl4b.out"}
}
run_cc_link_tests $build_tests