aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2013-01-18 22:50:30 +0000
committerH.J. Lu <hjl.tools@gmail.com>2013-01-18 22:50:30 +0000
commit3bea1fcb8b8a9b3c2133c162fe4cd6c91f40cfdf (patch)
tree33498089cae58727b371d062fc99963767b83672 /bfd
parentc60797fda43722bb6fbd5ea8381e465ee6792493 (diff)
downloadbinutils-3bea1fcb8b8a9b3c2133c162fe4cd6c91f40cfdf.zip
binutils-3bea1fcb8b8a9b3c2133c162fe4cd6c91f40cfdf.tar.gz
binutils-3bea1fcb8b8a9b3c2133c162fe4cd6c91f40cfdf.tar.bz2
Resolve size relocation against non-zero TLS symbol
bfd/ * elf32-i386.c (elf_i386_allocate_dynrelocs): Clear pc_count for non-zero TLS symbol. (elf_i386_relocate_section): Resolve size relocation against non-zero TLS symbol. * elf64-x86-64.c (elf_x86_64_allocate_dynrelocs): Clear pc_count for non-zero TLS symbol. (elf_x86_64_relocate_section): Resolve size relocation against non-zero TLS symbol. ld/testsuite/ * ld-size/size-10.rd: Updated. * ld-size/size-8.rd: Likewise. * ld-size/size32-2-i386.d: Likewise. * ld-size/size32-2-x32.d: Likewise. * ld-size/size32-2-x86-64.d: Likewise. * ld-size/size64-2-x32.d: Likewise. * ld-size/size64-2-x86-64.d: Likewise.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog11
-rw-r--r--bfd/elf32-i386.c24
-rw-r--r--bfd/elf64-x86-64.c24
3 files changed, 59 insertions, 0 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 85b411a..e60c472 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,14 @@
+2013-01-18 H.J. Lu <hongjiu.lu@intel.com>
+
+ * elf32-i386.c (elf_i386_allocate_dynrelocs): Clear pc_count for
+ non-zero TLS symbol.
+ (elf_i386_relocate_section): Resolve size relocation against
+ non-zero TLS symbol.
+ * elf64-x86-64.c (elf_x86_64_allocate_dynrelocs): Clear pc_count
+ for non-zero TLS symbol.
+ (elf_x86_64_relocate_section): Resolve size relocation against
+ non-zero TLS symbol.
+
2013-01-18 Mike Frysinger <vapier@gentoo.org>
* elflink.c (bfd_elf_size_dynamic_sections): Only add DT_RPATH
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index f8ad1d1..01e50a4 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -2358,6 +2358,24 @@ elf_i386_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
if (eh->dyn_relocs == NULL)
return TRUE;
+ /* Since pc_count for TLS symbol can only have size relocations and
+ we always resolve size relocation against non-zero TLS symbol, we
+ clear pc_count for non-zero TLS symbol. */
+ if (h->type == STT_TLS && h->size != 0)
+ {
+ struct elf_dyn_relocs **pp;
+
+ for (pp = &eh->dyn_relocs; (p = *pp) != NULL; )
+ {
+ p->count -= p->pc_count;
+ p->pc_count = 0;
+ if (p->count == 0)
+ *pp = p->next;
+ else
+ pp = &p->next;
+ }
+ }
+
/* In the shared -Bsymbolic case, discard space allocated for
dynamic pc-relative relocs against symbols which turn out to be
defined in regular objects. For the normal shared case, discard
@@ -3691,6 +3709,12 @@ elf_i386_relocate_section (bfd *output_bfd,
case R_386_SIZE32:
/* Set to symbol size. */
relocation = st_size;
+ if (h && h->type == STT_TLS && st_size != 0)
+ {
+ /* Resolve size relocation against non-zero TLS symbol. */
+ unresolved_reloc = FALSE;
+ break;
+ }
/* Fall through. */
case R_386_32:
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index 79b6dc6..71f33e2 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -2400,6 +2400,24 @@ elf_x86_64_allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
if (eh->dyn_relocs == NULL)
return TRUE;
+ /* Since pc_count for TLS symbol can only have size relocations and
+ we always resolve size relocation against non-zero TLS symbol, we
+ clear pc_count for non-zero TLS symbol. */
+ if (h->type == STT_TLS && h->size != 0)
+ {
+ struct elf_dyn_relocs **pp;
+
+ for (pp = &eh->dyn_relocs; (p = *pp) != NULL; )
+ {
+ p->count -= p->pc_count;
+ p->pc_count = 0;
+ if (p->count == 0)
+ *pp = p->next;
+ else
+ pp = &p->next;
+ }
+ }
+
/* In the shared -Bsymbolic case, discard space allocated for
dynamic pc-relative relocs against symbols which turn out to be
defined in regular objects. For the normal shared case, discard
@@ -3687,6 +3705,12 @@ elf_x86_64_relocate_section (bfd *output_bfd,
case R_X86_64_SIZE64:
/* Set to symbol size. */
relocation = st_size;
+ if (h && h->type == STT_TLS && st_size != 0)
+ {
+ /* Resolve size relocation against non-zero TLS symbol. */
+ unresolved_reloc = FALSE;
+ break;
+ }
goto direct;
case R_X86_64_PC8: