gdb: fix vfork with multiple threads
[deliverable/binutils-gdb.git] / bfd / elfxx-aarch64.c
index d16f2ecc1ff53f6667993162bcd2d69889ec2585..70385a0ebda9b4888ba458a226dac140e1e3c9e6 100644 (file)
@@ -1,5 +1,5 @@
 /* AArch64-specific support for ELF.
-   Copyright (C) 2009-2019 Free Software Foundation, Inc.
+   Copyright (C) 2009-2021 Free Software Foundation, Inc.
    Contributed by ARM Ltd.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -395,10 +395,12 @@ _bfd_aarch64_elf_put_addend (bfd *abfd,
 }
 
 bfd_vma
-_bfd_aarch64_elf_resolve_relocation (bfd_reloc_code_real_type r_type,
+_bfd_aarch64_elf_resolve_relocation (bfd *input_bfd,
+                                    bfd_reloc_code_real_type r_type,
                                     bfd_vma place, bfd_vma value,
-                                    bfd_vma addend, bfd_boolean weak_undef_p)
+                                    bfd_vma addend, bool weak_undef_p)
 {
+  bool tls_reloc = true;
   switch (r_type)
     {
     case BFD_RELOC_AARCH64_NONE:
@@ -446,6 +448,8 @@ _bfd_aarch64_elf_resolve_relocation (bfd_reloc_code_real_type r_type,
     case BFD_RELOC_AARCH64_MOVW_G2_NC:
     case BFD_RELOC_AARCH64_MOVW_G2_S:
     case BFD_RELOC_AARCH64_MOVW_G3:
+      tls_reloc = false;
+      /* fall-through.  */
     case BFD_RELOC_AARCH64_TLSDESC_OFF_G0_NC:
     case BFD_RELOC_AARCH64_TLSDESC_OFF_G1:
     case BFD_RELOC_AARCH64_TLSGD_MOVW_G0_NC:
@@ -466,6 +470,15 @@ _bfd_aarch64_elf_resolve_relocation (bfd_reloc_code_real_type r_type,
     case BFD_RELOC_AARCH64_TLSLE_LDST32_TPREL_LO12:
     case BFD_RELOC_AARCH64_TLSLE_LDST64_TPREL_LO12:
     case BFD_RELOC_AARCH64_TLSLE_LDST8_TPREL_LO12:
+      /* Weak Symbols and TLS relocations are implementation defined.  For this
+        case we choose to emit 0.  */
+      if (weak_undef_p && tls_reloc)
+       {
+         _bfd_error_handler (_("%pB: warning: Weak TLS is implementation "
+                               "defined and may not work as expected"),
+                               input_bfd);
+         value = place;
+       }
       value = value + addend;
       break;
 
@@ -562,7 +575,7 @@ _bfd_aarch64_elf_resolve_relocation (bfd_reloc_code_real_type r_type,
 
 /* Support for core dump NOTE sections.  */
 
-bfd_boolean
+bool
 _bfd_aarch64_elf_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
 {
   int offset;
@@ -571,7 +584,7 @@ _bfd_aarch64_elf_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
   switch (note->descsz)
     {
       default:
-       return FALSE;
+       return false;
 
       case 392:                /* sizeof(struct elf_prstatus) on Linux/arm64.  */
        /* pr_cursig */
@@ -594,13 +607,13 @@ _bfd_aarch64_elf_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
                                          size, note->descpos + offset);
 }
 
-bfd_boolean
+bool
 _bfd_aarch64_elf_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
 {
   switch (note->descsz)
     {
     default:
-      return FALSE;
+      return false;
 
     case 136:       /* This is sizeof(struct elf_prpsinfo) on Linux/aarch64.  */
       elf_tdata (abfd)->core->pid = bfd_get_32 (abfd, note->descdata + 24);
@@ -622,7 +635,7 @@ _bfd_aarch64_elf_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
       command[n - 1] = '\0';
   }
 
-  return TRUE;
+  return true;
 }
 
 char *
@@ -695,6 +708,7 @@ _bfd_aarch64_elf_link_setup_gnu_properties (struct bfd_link_info *info,
   bfd *pbfd;
   bfd *ebfd = NULL;
   elf_property *prop;
+  unsigned align;
 
   uint32_t gnu_prop = *gprop;
 
@@ -721,7 +735,7 @@ _bfd_aarch64_elf_link_setup_gnu_properties (struct bfd_link_info *info,
                                    4);
       if (gnu_prop & GNU_PROPERTY_AARCH64_FEATURE_1_BTI
          && !(prop->u.number & GNU_PROPERTY_AARCH64_FEATURE_1_BTI))
-           _bfd_error_handler (_("%pB: warning: BTI turned on by --force-bti "
+           _bfd_error_handler (_("%pB: warning: BTI turned on by -force-bti "
                                  "when all inputs do not have BTI in NOTE "
                                  "section."), ebfd);
       prop->u.number |= gnu_prop;
@@ -743,6 +757,11 @@ _bfd_aarch64_elf_link_setup_gnu_properties (struct bfd_link_info *info,
            info->callbacks->einfo (
              _("%F%P: failed to create GNU property section\n"));
 
+          align = (bfd_get_mach (ebfd) & bfd_mach_aarch64_ilp32) ? 2 : 3;
+         if (!bfd_set_section_alignment (sec, align))
+           info->callbacks->einfo (_("%F%pA: failed to align section\n"),
+                                   sec);
+
          elf_section_type (sec) = SHT_NOTE;
        }
     }
@@ -811,7 +830,7 @@ _bfd_aarch64_elf_parse_gnu_properties (bfd *abfd, unsigned int type,
    If APROP isn't NULL, merge it with BPROP and/or PROP.  Vice-versa if BROP
    isn't NULL.  Return TRUE if there is any update to APROP or if BPROP should
    be merge with ABFD.  */
-bfd_boolean
+bool
 _bfd_aarch64_elf_merge_gnu_properties (struct bfd_link_info *info
                                       ATTRIBUTE_UNUSED,
                                       bfd *abfd ATTRIBUTE_UNUSED,
@@ -820,7 +839,7 @@ _bfd_aarch64_elf_merge_gnu_properties (struct bfd_link_info *info
                                       uint32_t prop)
 {
   unsigned int orig_number;
-  bfd_boolean updated = FALSE;
+  bool updated = false;
   unsigned int pr_type = aprop != NULL ? aprop->pr_type : bprop->pr_type;
 
   switch (pr_type)
@@ -850,14 +869,14 @@ _bfd_aarch64_elf_merge_gnu_properties (struct bfd_link_info *info
            else
              {
                bprop->u.number = prop;
-               updated = TRUE;
+               updated = true;
              }
          }
        /* No PROP and BPROP is NULL, so remove APROP.  */
        else if (aprop != NULL)
          {
            aprop->pr_kind = property_remove;
-           updated = TRUE;
+           updated = true;
          }
       }
       break;
This page took 0.035215 seconds and 4 git commands to generate.