]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
PR ld/13250
authorAlan Modra <amodra@gmail.com>
Tue, 25 Oct 2011 02:57:24 +0000 (02:57 +0000)
committerAlan Modra <amodra@gmail.com>
Tue, 25 Oct 2011 02:57:24 +0000 (02:57 +0000)
bfd/
2011-10-08  H.J. Lu  <hongjiu.lu@intel.com>
* elflink.c (elf_link_add_object_symbols): Preserve the maximum
alignment and size for common symbols.
ld/testsuite/
2011-10-08  H.J. Lu  <hongjiu.lu@intel.com>
* ld-elf/shared.exp (build_tests): Add tests for PR ld/13250.
(run_tests): Likewise.
* ld-elf/pr13250-1.c: New.
* ld-elf/pr13250-2.c: Likewise.
* ld-elf/pr13250-3.c: Likewise.

bfd/ChangeLog
bfd/elflink.c
ld/testsuite/ChangeLog
ld/testsuite/ld-elf/shared.exp

index b97235b1d5392da41972a04055d76220f639e84a..a366b23b75b5e5a3bb1f3542cd3f001cc96e638e 100644 (file)
@@ -1,6 +1,11 @@
 2011-10-25  Alan Modra  <amodra@gmail.com>
 
        Apply mainline patches
+       2011-10-08  H.J. Lu  <hongjiu.lu@intel.com>
+       PR ld/13250
+       * elflink.c (elf_link_add_object_symbols): Preserve the maximum
+       alignment and size for common symbols.
+
        2011-10-08  Alan Modra  <amodra@gmail.com>
        PR ld/13229
        PR ld/13244
index 9558a2593cd294644a7277f90c12182874db1413..f8741e41538664c2039eb27c6028e0c11577c478 100644 (file)
@@ -4515,6 +4515,8 @@ error_free_dyn:
        {
          struct bfd_hash_entry *p;
          struct elf_link_hash_entry *h;
+         bfd_size_type size;
+         unsigned int alignment_power;
 
          for (p = htab->root.table.table[i]; p != NULL; p = p->next)
            {
@@ -4524,6 +4526,20 @@ error_free_dyn:
              if (h->dynindx >= old_dynsymcount)
                _bfd_elf_strtab_delref (htab->dynstr, h->dynstr_index);
 
+             /* Preserve the maximum alignment and size for common
+                symbols even if this dynamic lib isn't on DT_NEEDED
+                since it can still be loaded at the run-time by another
+                dynamic lib.  */
+             if (h->root.type == bfd_link_hash_common)
+               {
+                 size = h->root.u.c.size;
+                 alignment_power = h->root.u.c.p->alignment_power;
+               }
+             else
+               {
+                 size = 0;
+                 alignment_power = 0;
+               }
              memcpy (p, old_ent, htab->root.table.entsize);
              old_ent = (char *) old_ent + htab->root.table.entsize;
              h = (struct elf_link_hash_entry *) p;
@@ -4532,6 +4548,13 @@ error_free_dyn:
                  memcpy (h->root.u.i.link, old_ent, htab->root.table.entsize);
                  old_ent = (char *) old_ent + htab->root.table.entsize;
                }
+             else if (h->root.type == bfd_link_hash_common)
+               {
+                 if (size > h->root.u.c.size)
+                   h->root.u.c.size = size;
+                 if (alignment_power > h->root.u.c.p->alignment_power)
+                   h->root.u.c.p->alignment_power = alignment_power;
+               }
            }
        }
 
index 6881e29e6ae39ac8127bb89e0241437513209946..f528fedba98c1c890b67fff16d95c89c2569c384 100644 (file)
@@ -1,6 +1,14 @@
 2011-10-25  Alan Modra  <amodra@gmail.com>
 
        Apply mainline patches
+       2011-10-08  H.J. Lu  <hongjiu.lu@intel.com>
+       PR ld/13250
+       * ld-elf/shared.exp (build_tests): Add tests for PR ld/13250.
+       (run_tests): Likewise.
+       * ld-elf/pr13250-1.c: New.
+       * ld-elf/pr13250-2.c: Likewise.
+       * ld-elf/pr13250-3.c: Likewise.
+
        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,
index eea9c7e931061c12b78ca4b1cf7d1bd64e7259cc..9cd0221ccb9e10de47b982f8876d52457459b378 100644 (file)
@@ -157,6 +157,15 @@ set build_tests {
   {"Build libpr11138-2.o"
    "-r -nostdlib" ""
    {pr11138-2.c} {} "libpr11138-2.o"}
+  {"Build pr13250-1.so"
+   "-shared" "-fPIC"
+   {pr13250-1.c} {} "libpr13250-1.so"}
+  {"Build pr13250-2.so with libpr13250-1.so"
+   "-shared tmpdir/libpr13250-1.so" "-fPIC"
+   {pr13250-2.c} {} "libpr13250-2.so"}
+  {"Build libpr13250-3.o"
+   "-r -nostdlib" ""
+   {pr13250-3.c} {} "libpr13250-3.o"}
 }
 
 run_cc_link_tests $build_tests
@@ -283,6 +292,9 @@ set run_tests {
     {"Run with libpr11138-1.so pr11138-2.c"
      "--version-script=pr11138-2.map tmpdir/libpr11138-1.so tmpdir/pr11138-2.o" ""
      {dummy.c} "pr11138b" "pr11138.out"}
+    {"Run with pr13250-3.c, libpr13250-1.so and libpr13250-2.so"
+     "--as-needed tmpdir/pr13250-3.o tmpdir/libpr13250-1.so tmpdir/libpr13250-2.so" ""
+     {dummy.c} "pr13250" "pass.out"}
 }
 
 # NetBSD ELF systems do not currently support the .*_array sections.