bfd/elfnn-aarch64.c: Cleanup a couple of TLS functions

Message ID 1400858202-4459-1-git-send-email-will.newton@linaro.org
State Accepted
Headers show

Commit Message

Will Newton May 23, 2014, 3:16 p.m.
Add an assert and remove an unused line of code.

bfd/ChangeLog:

2014-05-21  Will Newton  <will.newton@linaro.org>

        * elfnn-aarch64.c (tpoff_base): Make test of tls_sec
	being non-NULL into an assert.
	(elfNN_aarch64_tls_relax): Remove unused code.
---
 bfd/elfnn-aarch64.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Marcus Shawcroft June 2, 2014, 7:19 a.m. | #1
On 23/05/14 16:16, Will Newton wrote:
> Add an assert and remove an unused line of code.
>
> bfd/ChangeLog:
>
> 2014-05-21  Will Newton  <will.newton@linaro.org>
>
>          * elfnn-aarch64.c (tpoff_base): Make test of tls_sec
> 	being non-NULL into an assert.
> 	(elfNN_aarch64_tls_relax): Remove unused code.
> ---
>   bfd/elfnn-aarch64.c | 4 +---
>   1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
> index 498b7bd..d917c7e 100644
> --- a/bfd/elfnn-aarch64.c
> +++ b/bfd/elfnn-aarch64.c
> @@ -3301,8 +3301,7 @@ tpoff_base (struct bfd_link_info *info)
>     struct elf_link_hash_table *htab = elf_hash_table (info);
>
>     /* If tls_sec is NULL, we should have signalled an error already.  */
> -  if (htab->tls_sec == NULL)
> -    return 0;
> +  BFD_ASSERT (htab->tls_sec != NULL);
>
>     bfd_vma base = align_power ((bfd_vma) TCB_SIZE,
>   			      htab->tls_sec->alignment_power);
> @@ -3938,7 +3937,6 @@ elfNN_aarch64_tls_relax (struct elf_aarch64_link_hash_table *globals,
>   	     or
>   	     adrp x0, :tlsdesc:var   =>   adrp x0, :gottprel:var
>   	   */
> -	  insn = bfd_getl32 (contents + rel->r_offset);
>   	  return bfd_reloc_continue;
>   	}
>
>

Looks OK to me.
/Marcus

Patch

diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
index 498b7bd..d917c7e 100644
--- a/bfd/elfnn-aarch64.c
+++ b/bfd/elfnn-aarch64.c
@@ -3301,8 +3301,7 @@  tpoff_base (struct bfd_link_info *info)
   struct elf_link_hash_table *htab = elf_hash_table (info);
 
   /* If tls_sec is NULL, we should have signalled an error already.  */
-  if (htab->tls_sec == NULL)
-    return 0;
+  BFD_ASSERT (htab->tls_sec != NULL);
 
   bfd_vma base = align_power ((bfd_vma) TCB_SIZE,
 			      htab->tls_sec->alignment_power);
@@ -3938,7 +3937,6 @@  elfNN_aarch64_tls_relax (struct elf_aarch64_link_hash_table *globals,
 	     or
 	     adrp x0, :tlsdesc:var   =>   adrp x0, :gottprel:var
 	   */
-	  insn = bfd_getl32 (contents + rel->r_offset);
 	  return bfd_reloc_continue;
 	}