diff options
author | Philip Guenther <guenther@cvs.openbsd.org> | 2016-09-03 10:03:27 +0000 |
---|---|---|
committer | Philip Guenther <guenther@cvs.openbsd.org> | 2016-09-03 10:03:27 +0000 |
commit | 5b0b0056e7b5fdabf0a65b08b6541ec7a303a003 (patch) | |
tree | 96ecfa308cd79ae9bb1fa202a03dde95da8a201d /gnu/usr.bin/binutils-2.17 | |
parent | c976d2c75f89202e9719d0c8f0fc9ef4caa54898 (diff) |
Tests about TLS relocations that should only apply when building a
shared library need to test for 'shared && !executable' so that PIE
files can optimize to initial-exec and local-exec models
ok kettenis@
Diffstat (limited to 'gnu/usr.bin/binutils-2.17')
-rw-r--r-- | gnu/usr.bin/binutils-2.17/bfd/elf32-i386.c | 15 | ||||
-rw-r--r-- | gnu/usr.bin/binutils-2.17/bfd/elf64-x86-64.c | 13 | ||||
-rw-r--r-- | gnu/usr.bin/binutils-2.17/bfd/elfxx-sparc.c | 12 |
3 files changed, 21 insertions, 19 deletions
diff --git a/gnu/usr.bin/binutils-2.17/bfd/elf32-i386.c b/gnu/usr.bin/binutils-2.17/bfd/elf32-i386.c index 081432a1bf8..1c709f75552 100644 --- a/gnu/usr.bin/binutils-2.17/bfd/elf32-i386.c +++ b/gnu/usr.bin/binutils-2.17/bfd/elf32-i386.c @@ -882,7 +882,7 @@ elf_i386_copy_indirect_symbol (struct bfd_link_info *info, static int elf_i386_tls_transition (struct bfd_link_info *info, int r_type, int is_local) { - if (info->shared) + if (info->shared && !info->executable) return r_type; switch (r_type) @@ -988,7 +988,7 @@ elf_i386_check_relocs (bfd *abfd, case R_386_TLS_IE_32: case R_386_TLS_IE: case R_386_TLS_GOTIE: - if (info->shared) + if (info->shared && !info->executable) info->flags |= DF_STATIC_TLS; /* Fall through */ @@ -1116,7 +1116,7 @@ elf_i386_check_relocs (bfd *abfd, case R_386_TLS_LE_32: case R_386_TLS_LE: - if (!info->shared) + if (!info->shared || info->executable) break; info->flags |= DF_STATIC_TLS; /* Fall through */ @@ -1691,7 +1691,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) /* If R_386_TLS_{IE_32,IE,GOTIE} symbol is now local to the binary, make it a R_386_TLS_LE_32 requiring no TLS entry. */ if (h->got.refcount > 0 - && !info->shared + && (!info->shared || info->executable) && h->dynindx == -1 && (elf_i386_hash_entry(h)->tls_type & GOT_TLS_IE)) h->got.offset = (bfd_vma) -1; @@ -3279,7 +3279,7 @@ elf_i386_relocate_section (bfd *output_bfd, break; case R_386_TLS_LDM: - if (! info->shared) + if (! info->shared || info->executable) { unsigned int val; @@ -3340,7 +3340,8 @@ elf_i386_relocate_section (bfd *output_bfd, break; case R_386_TLS_LDO_32: - if (info->shared || (input_section->flags & SEC_CODE) == 0) + if ((info->shared && !info->executable) + || (input_section->flags & SEC_CODE) == 0) relocation -= dtpoff_base (info); else /* When converting LDO to LE, we must negate. */ @@ -3349,7 +3350,7 @@ elf_i386_relocate_section (bfd *output_bfd, case R_386_TLS_LE_32: case R_386_TLS_LE: - if (info->shared) + if (info->shared && !info->executable) { Elf_Internal_Rela outrel; asection *sreloc; diff --git a/gnu/usr.bin/binutils-2.17/bfd/elf64-x86-64.c b/gnu/usr.bin/binutils-2.17/bfd/elf64-x86-64.c index 752d6be212e..c63bf138994 100644 --- a/gnu/usr.bin/binutils-2.17/bfd/elf64-x86-64.c +++ b/gnu/usr.bin/binutils-2.17/bfd/elf64-x86-64.c @@ -694,7 +694,7 @@ elf64_x86_64_elf_object_p (bfd *abfd) static int elf64_x86_64_tls_transition (struct bfd_link_info *info, int r_type, int is_local) { - if (info->shared) + if (info->shared && !info->executable) return r_type; switch (r_type) @@ -772,7 +772,7 @@ elf64_x86_64_check_relocs (bfd *abfd, struct bfd_link_info *info, asection *sec, goto create_got; case R_X86_64_TPOFF32: - if (info->shared) + if (info->shared && !info->executable) { (*_bfd_error_handler) (_("%B: relocation %s against `%s' can not be used when making a shared object; recompile with -fPIC"), @@ -785,7 +785,7 @@ elf64_x86_64_check_relocs (bfd *abfd, struct bfd_link_info *info, asection *sec, break; case R_X86_64_GOTTPOFF: - if (info->shared) + if (info->shared && !info->executable) info->flags |= DF_STATIC_TLS; /* Fall through */ @@ -1516,7 +1516,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf) /* If R_X86_64_GOTTPOFF symbol is now local to the binary, make it a R_X86_64_TPOFF32 requiring no GOT entry. */ if (h->got.refcount > 0 - && !info->shared + && (!info->shared || info->executable) && h->dynindx == -1 && elf64_x86_64_hash_entry (h)->tls_type == GOT_TLS_IE) h->got.offset = (bfd_vma) -1; @@ -2978,14 +2978,15 @@ elf64_x86_64_relocate_section (bfd *output_bfd, struct bfd_link_info *info, break; case R_X86_64_DTPOFF32: - if (info->shared || (input_section->flags & SEC_CODE) == 0) + if ((info->shared && !info->executable) + || (input_section->flags & SEC_CODE) == 0) relocation -= dtpoff_base (info); else relocation = tpoff (info, relocation); break; case R_X86_64_TPOFF32: - BFD_ASSERT (! info->shared); + BFD_ASSERT (! info->shared || info->executable); relocation = tpoff (info, relocation); break; diff --git a/gnu/usr.bin/binutils-2.17/bfd/elfxx-sparc.c b/gnu/usr.bin/binutils-2.17/bfd/elfxx-sparc.c index 643a028cfbe..6b3abcb4fdd 100644 --- a/gnu/usr.bin/binutils-2.17/bfd/elfxx-sparc.c +++ b/gnu/usr.bin/binutils-2.17/bfd/elfxx-sparc.c @@ -1009,7 +1009,7 @@ sparc_elf_tls_transition (struct bfd_link_info *info, bfd *abfd, && ! _bfd_sparc_elf_tdata (abfd)->has_tlsgd) r_type = R_SPARC_REV32; - if (info->shared) + if (info->shared && !info->executable) return r_type; switch (r_type) @@ -1134,13 +1134,13 @@ _bfd_sparc_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, case R_SPARC_TLS_LE_HIX22: case R_SPARC_TLS_LE_LOX10: - if (info->shared) + if (info->shared && !info->executable) goto r_sparc_plt32; break; case R_SPARC_TLS_IE_HI22: case R_SPARC_TLS_IE_LO10: - if (info->shared) + if (info->shared && !info->executable) info->flags |= DF_STATIC_TLS; /* Fall through */ @@ -1237,7 +1237,7 @@ _bfd_sparc_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, case R_SPARC_TLS_GD_CALL: case R_SPARC_TLS_LDM_CALL: - if (info->shared) + if (info->shared && !info->executable) { /* These are basically R_SPARC_TLS_WPLT30 relocs against __tls_get_addr. */ @@ -1949,9 +1949,9 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, PTR inf) } /* If R_SPARC_TLS_IE_{HI22,LO10} symbol is now local to the binary, - make it a R_SPARC_TLS_LE_{HI22,LO10} requiring no TLS entry. */ + make it a R_SPARC_TLS_LE_{HI22,LO10} requiring no GOT entry. */ if (h->got.refcount > 0 - && !info->shared + && (!info->shared || info->executable) && h->dynindx == -1 && _bfd_sparc_elf_hash_entry(h)->tls_type == GOT_TLS_IE) h->got.offset = (bfd_vma) -1; |