aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2011-10-08 16:51:11 +0000
committerH.J. Lu <hjl.tools@gmail.com>2011-10-08 16:51:11 +0000
commit3e0882af52d7a4b40de87c0be36f1b5bc84ddadb (patch)
tree8356aa5ce3049354ee8dfb631f7f4b98d8591ec2 /bfd
parentc3df8c14822028ab319894b4c02c519073b62dba (diff)
downloadgdb-3e0882af52d7a4b40de87c0be36f1b5bc84ddadb.zip
gdb-3e0882af52d7a4b40de87c0be36f1b5bc84ddadb.tar.gz
gdb-3e0882af52d7a4b40de87c0be36f1b5bc84ddadb.tar.bz2
Preserve the maximum alignment/size for common symbols.
bfd/ 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. ld/testsuite/ 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.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog6
-rw-r--r--bfd/elflink.c23
2 files changed, 29 insertions, 0 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 8f99755..05372bf 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+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
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 358ada8c..18aefdb 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -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;
+ }
}
}