]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - bfd/elf64-mips.c
aarch64: fix incorrect encoding for system register pmsdsfr_el1
[thirdparty/binutils-gdb.git] / bfd / elf64-mips.c
index 419d9bc6dbdd0e1941ee6fc375c4ee1add1e4de1..afd7b30f13452e3e59787ebda7dc545342017bc4 100644 (file)
@@ -1,5 +1,5 @@
 /* MIPS-specific support for 64-bit ELF
-   Copyright (C) 1996-2022 Free Software Foundation, Inc.
+   Copyright (C) 1996-2024 Free Software Foundation, Inc.
    Ian Lance Taylor, Cygnus Support
    Linker support added by Mark Mitchell, CodeSourcery, LLC.
    <mark@codesourcery.com>
@@ -431,7 +431,7 @@ static reloc_howto_type mips_elf64_howto_table_rel[] =
 
   /* High 16 bits of displacement in global offset table.  */
   HOWTO (R_MIPS_GOT_HI16,      /* type */
-        0,                     /* rightshift */
+        16,                    /* rightshift */
         4,                     /* size */
         16,                    /* bitsize */
         false,                 /* pc_relative */
@@ -534,7 +534,7 @@ static reloc_howto_type mips_elf64_howto_table_rel[] =
 
   /* High 16 bits of displacement in global offset table.  */
   HOWTO (R_MIPS_CALL_HI16,     /* type */
-        0,                     /* rightshift */
+        16,                    /* rightshift */
         4,                     /* size */
         16,                    /* bitsize */
         false,                 /* pc_relative */
@@ -691,7 +691,7 @@ static reloc_howto_type mips_elf64_howto_table_rel[] =
 
   /* TLS local dynamic offset.  */
   HOWTO (R_MIPS_TLS_DTPREL_HI16,       /* type */
-        0,                     /* rightshift */
+        16,                    /* rightshift */
         4,                     /* size */
         16,                    /* bitsize */
         false,                 /* pc_relative */
@@ -711,7 +711,7 @@ static reloc_howto_type mips_elf64_howto_table_rel[] =
         16,                    /* bitsize */
         false,                 /* pc_relative */
         0,                     /* bitpos */
-        complain_overflow_signed, /* complain_on_overflow */
+        complain_overflow_dont, /* complain_on_overflow */
         _bfd_mips_elf_generic_reloc, /* special_function */
         "R_MIPS_TLS_DTPREL_LO16",      /* name */
         true,                  /* partial_inplace */
@@ -753,7 +753,7 @@ static reloc_howto_type mips_elf64_howto_table_rel[] =
 
   /* TLS thread pointer offset.  */
   HOWTO (R_MIPS_TLS_TPREL_HI16,        /* type */
-        0,                     /* rightshift */
+        16,                    /* rightshift */
         4,                     /* size */
         16,                    /* bitsize */
         false,                 /* pc_relative */
@@ -773,7 +773,7 @@ static reloc_howto_type mips_elf64_howto_table_rel[] =
         16,                    /* bitsize */
         false,                 /* pc_relative */
         0,                     /* bitpos */
-        complain_overflow_signed, /* complain_on_overflow */
+        complain_overflow_dont, /* complain_on_overflow */
         _bfd_mips_elf_generic_reloc, /* special_function */
         "R_MIPS_TLS_TPREL_LO16", /* name */
         true,                  /* partial_inplace */
@@ -975,7 +975,7 @@ static reloc_howto_type mips_elf64_howto_table_rela[] =
 
   /* High 16 bits of symbol value.  */
   HOWTO (R_MIPS_HI16,          /* type */
-        0,                     /* rightshift */
+        16,                    /* rightshift */
         4,                     /* size */
         16,                    /* bitsize */
         false,                 /* pc_relative */
@@ -1191,7 +1191,7 @@ static reloc_howto_type mips_elf64_howto_table_rela[] =
 
   /* High 16 bits of displacement in global offset table.  */
   HOWTO (R_MIPS_GOT_HI16,      /* type */
-        0,                     /* rightshift */
+        16,                    /* rightshift */
         4,                     /* size */
         16,                    /* bitsize */
         false,                 /* pc_relative */
@@ -1285,7 +1285,7 @@ static reloc_howto_type mips_elf64_howto_table_rela[] =
 
   /* Get the higher value of a 64 bit addend.  */
   HOWTO (R_MIPS_HIGHER,                /* type */
-        0,                     /* rightshift */
+        32,                    /* rightshift */
         4,                     /* size */
         16,                    /* bitsize */
         false,                 /* pc_relative */
@@ -1300,7 +1300,7 @@ static reloc_howto_type mips_elf64_howto_table_rela[] =
 
   /* Get the highest value of a 64 bit addend.  */
   HOWTO (R_MIPS_HIGHEST,       /* type */
-        0,                     /* rightshift */
+        48,                    /* rightshift */
         4,                     /* size */
         16,                    /* bitsize */
         false,                 /* pc_relative */
@@ -1315,7 +1315,7 @@ static reloc_howto_type mips_elf64_howto_table_rela[] =
 
   /* High 16 bits of displacement in global offset table.  */
   HOWTO (R_MIPS_CALL_HI16,     /* type */
-        0,                     /* rightshift */
+        16,                    /* rightshift */
         4,                     /* size */
         16,                    /* bitsize */
         false,                 /* pc_relative */
@@ -1472,7 +1472,7 @@ static reloc_howto_type mips_elf64_howto_table_rela[] =
 
   /* TLS local dynamic offset.  */
   HOWTO (R_MIPS_TLS_DTPREL_HI16,       /* type */
-        0,                     /* rightshift */
+        16,                    /* rightshift */
         4,                     /* size */
         16,                    /* bitsize */
         false,                 /* pc_relative */
@@ -1492,7 +1492,7 @@ static reloc_howto_type mips_elf64_howto_table_rela[] =
         16,                    /* bitsize */
         false,                 /* pc_relative */
         0,                     /* bitpos */
-        complain_overflow_signed, /* complain_on_overflow */
+        complain_overflow_dont, /* complain_on_overflow */
         _bfd_mips_elf_generic_reloc, /* special_function */
         "R_MIPS_TLS_DTPREL_LO16",      /* name */
         false,                 /* partial_inplace */
@@ -1534,7 +1534,7 @@ static reloc_howto_type mips_elf64_howto_table_rela[] =
 
   /* TLS thread pointer offset.  */
   HOWTO (R_MIPS_TLS_TPREL_HI16,        /* type */
-        0,                     /* rightshift */
+        16,                    /* rightshift */
         4,                     /* size */
         16,                    /* bitsize */
         false,                 /* pc_relative */
@@ -1554,7 +1554,7 @@ static reloc_howto_type mips_elf64_howto_table_rela[] =
         16,                    /* bitsize */
         false,                 /* pc_relative */
         0,                     /* bitpos */
-        complain_overflow_signed, /* complain_on_overflow */
+        complain_overflow_dont, /* complain_on_overflow */
         _bfd_mips_elf_generic_reloc, /* special_function */
         "R_MIPS_TLS_TPREL_LO16", /* name */
         false,                 /* partial_inplace */
@@ -1799,7 +1799,7 @@ static reloc_howto_type mips16_elf64_howto_table_rel[] =
 
   /* MIPS16 TLS local dynamic offset.  */
   HOWTO (R_MIPS16_TLS_DTPREL_HI16,     /* type */
-        0,                     /* rightshift */
+        16,                    /* rightshift */
         4,                     /* size */
         16,                    /* bitsize */
         false,                 /* pc_relative */
@@ -1819,7 +1819,7 @@ static reloc_howto_type mips16_elf64_howto_table_rel[] =
         16,                    /* bitsize */
         false,                 /* pc_relative */
         0,                     /* bitpos */
-        complain_overflow_signed, /* complain_on_overflow */
+        complain_overflow_dont, /* complain_on_overflow */
         _bfd_mips_elf_generic_reloc, /* special_function */
         "R_MIPS16_TLS_DTPREL_LO16",    /* name */
         true,                  /* partial_inplace */
@@ -1844,7 +1844,7 @@ static reloc_howto_type mips16_elf64_howto_table_rel[] =
 
   /* MIPS16 TLS thread pointer offset.  */
   HOWTO (R_MIPS16_TLS_TPREL_HI16,      /* type */
-        0,                     /* rightshift */
+        16,                    /* rightshift */
         4,                     /* size */
         16,                    /* bitsize */
         false,                 /* pc_relative */
@@ -1864,7 +1864,7 @@ static reloc_howto_type mips16_elf64_howto_table_rel[] =
         16,                    /* bitsize */
         false,                 /* pc_relative */
         0,                     /* bitpos */
-        complain_overflow_signed, /* complain_on_overflow */
+        complain_overflow_dont, /* complain_on_overflow */
         _bfd_mips_elf_generic_reloc, /* special_function */
         "R_MIPS16_TLS_TPREL_LO16", /* name */
         true,                  /* partial_inplace */
@@ -2015,7 +2015,7 @@ static reloc_howto_type mips16_elf64_howto_table_rela[] =
 
   /* MIPS16 TLS local dynamic offset.  */
   HOWTO (R_MIPS16_TLS_DTPREL_HI16,     /* type */
-        0,                     /* rightshift */
+        16,                    /* rightshift */
         4,                     /* size */
         16,                    /* bitsize */
         false,                 /* pc_relative */
@@ -2035,7 +2035,7 @@ static reloc_howto_type mips16_elf64_howto_table_rela[] =
         16,                    /* bitsize */
         false,                 /* pc_relative */
         0,                     /* bitpos */
-        complain_overflow_signed, /* complain_on_overflow */
+        complain_overflow_dont, /* complain_on_overflow */
         _bfd_mips_elf_generic_reloc, /* special_function */
         "R_MIPS16_TLS_DTPREL_LO16",    /* name */
         false,                 /* partial_inplace */
@@ -2060,7 +2060,7 @@ static reloc_howto_type mips16_elf64_howto_table_rela[] =
 
   /* MIPS16 TLS thread pointer offset.  */
   HOWTO (R_MIPS16_TLS_TPREL_HI16,      /* type */
-        0,                     /* rightshift */
+        16,                    /* rightshift */
         4,                     /* size */
         16,                    /* bitsize */
         false,                 /* pc_relative */
@@ -2080,7 +2080,7 @@ static reloc_howto_type mips16_elf64_howto_table_rela[] =
         16,                    /* bitsize */
         false,                 /* pc_relative */
         0,                     /* bitpos */
-        complain_overflow_signed, /* complain_on_overflow */
+        complain_overflow_dont, /* complain_on_overflow */
         _bfd_mips_elf_generic_reloc, /* special_function */
         "R_MIPS16_TLS_TPREL_LO16", /* name */
         false,                 /* partial_inplace */
@@ -2311,7 +2311,7 @@ static reloc_howto_type micromips_elf64_howto_table_rel[] =
 
   /* High 16 bits of displacement in global offset table.  */
   HOWTO (R_MICROMIPS_GOT_HI16, /* type */
-        0,                     /* rightshift */
+        16,                    /* rightshift */
         4,                     /* size */
         16,                    /* bitsize */
         false,                 /* pc_relative */
@@ -2363,7 +2363,7 @@ static reloc_howto_type micromips_elf64_howto_table_rel[] =
 
   /* High 16 bits of displacement in global offset table.  */
   HOWTO (R_MICROMIPS_CALL_HI16,        /* type */
-        0,                     /* rightshift */
+        16,                    /* rightshift */
         4,                     /* size */
         16,                    /* bitsize */
         false,                 /* pc_relative */
@@ -2475,7 +2475,7 @@ static reloc_howto_type micromips_elf64_howto_table_rel[] =
 
   /* TLS local dynamic offset.  */
   HOWTO (R_MICROMIPS_TLS_DTPREL_HI16,  /* type */
-        0,                     /* rightshift */
+        16,                    /* rightshift */
         4,                     /* size */
         16,                    /* bitsize */
         false,                 /* pc_relative */
@@ -2495,7 +2495,7 @@ static reloc_howto_type micromips_elf64_howto_table_rel[] =
         16,                    /* bitsize */
         false,                 /* pc_relative */
         0,                     /* bitpos */
-        complain_overflow_signed, /* complain_on_overflow */
+        complain_overflow_dont, /* complain_on_overflow */
         _bfd_mips_elf_generic_reloc, /* special_function */
         "R_MICROMIPS_TLS_DTPREL_LO16", /* name */
         true,                  /* partial_inplace */
@@ -2523,7 +2523,7 @@ static reloc_howto_type micromips_elf64_howto_table_rel[] =
 
   /* TLS thread pointer offset.  */
   HOWTO (R_MICROMIPS_TLS_TPREL_HI16,   /* type */
-        0,                     /* rightshift */
+        16,                    /* rightshift */
         4,                     /* size */
         16,                    /* bitsize */
         false,                 /* pc_relative */
@@ -2543,7 +2543,7 @@ static reloc_howto_type micromips_elf64_howto_table_rel[] =
         16,                    /* bitsize */
         false,                 /* pc_relative */
         0,                     /* bitpos */
-        complain_overflow_signed, /* complain_on_overflow */
+        complain_overflow_dont, /* complain_on_overflow */
         _bfd_mips_elf_generic_reloc, /* special_function */
         "R_MICROMIPS_TLS_TPREL_LO16", /* name */
         true,                  /* partial_inplace */
@@ -2790,7 +2790,7 @@ static reloc_howto_type micromips_elf64_howto_table_rela[] =
 
   /* High 16 bits of displacement in global offset table.  */
   HOWTO (R_MICROMIPS_GOT_HI16, /* type */
-        0,                     /* rightshift */
+        16,                    /* rightshift */
         4,                     /* size */
         16,                    /* bitsize */
         false,                 /* pc_relative */
@@ -2835,7 +2835,7 @@ static reloc_howto_type micromips_elf64_howto_table_rela[] =
 
   /* Get the higher value of a 64 bit addend.  */
   HOWTO (R_MICROMIPS_HIGHER,   /* type */
-        0,                     /* rightshift */
+        32,                    /* rightshift */
         4,                     /* size */
         16,                    /* bitsize */
         false,                 /* pc_relative */
@@ -2850,7 +2850,7 @@ static reloc_howto_type micromips_elf64_howto_table_rela[] =
 
   /* Get the highest value of a 64 bit addend.  */
   HOWTO (R_MICROMIPS_HIGHEST,  /* type */
-        0,                     /* rightshift */
+        48,                    /* rightshift */
         4,                     /* size */
         16,                    /* bitsize */
         false,                 /* pc_relative */
@@ -2865,7 +2865,7 @@ static reloc_howto_type micromips_elf64_howto_table_rela[] =
 
   /* High 16 bits of displacement in global offset table.  */
   HOWTO (R_MICROMIPS_CALL_HI16,        /* type */
-        0,                     /* rightshift */
+        16,                    /* rightshift */
         4,                     /* size */
         16,                    /* bitsize */
         false,                 /* pc_relative */
@@ -2977,7 +2977,7 @@ static reloc_howto_type micromips_elf64_howto_table_rela[] =
 
   /* TLS local dynamic offset.  */
   HOWTO (R_MICROMIPS_TLS_DTPREL_HI16,  /* type */
-        0,                     /* rightshift */
+        16,                    /* rightshift */
         4,                     /* size */
         16,                    /* bitsize */
         false,                 /* pc_relative */
@@ -2997,7 +2997,7 @@ static reloc_howto_type micromips_elf64_howto_table_rela[] =
         16,                    /* bitsize */
         false,                 /* pc_relative */
         0,                     /* bitpos */
-        complain_overflow_signed, /* complain_on_overflow */
+        complain_overflow_dont, /* complain_on_overflow */
         _bfd_mips_elf_generic_reloc, /* special_function */
         "R_MICROMIPS_TLS_DTPREL_LO16", /* name */
         false,                 /* partial_inplace */
@@ -3025,7 +3025,7 @@ static reloc_howto_type micromips_elf64_howto_table_rela[] =
 
   /* TLS thread pointer offset.  */
   HOWTO (R_MICROMIPS_TLS_TPREL_HI16,   /* type */
-        0,                     /* rightshift */
+        16,                    /* rightshift */
         4,                     /* size */
         16,                    /* bitsize */
         false,                 /* pc_relative */
@@ -3045,7 +3045,7 @@ static reloc_howto_type micromips_elf64_howto_table_rela[] =
         16,                    /* bitsize */
         false,                 /* pc_relative */
         0,                     /* bitpos */
-        complain_overflow_signed, /* complain_on_overflow */
+        complain_overflow_dont, /* complain_on_overflow */
         _bfd_mips_elf_generic_reloc, /* special_function */
         "R_MICROMIPS_TLS_TPREL_LO16", /* name */
         false,                 /* partial_inplace */
@@ -3577,8 +3577,11 @@ mips_elf64_gprel32_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
   else
     relocation = symbol->value;
 
-  relocation += symbol->section->output_section->vma;
-  relocation += symbol->section->output_offset;
+  if (symbol->section->output_section != NULL)
+    {
+      relocation += symbol->section->output_section->vma;
+      relocation += symbol->section->output_offset;
+    }
 
   if (!_bfd_mips_reloc_offset_in_range (abfd, input_section, reloc_entry,
                                        check_inplace))
@@ -4745,10 +4748,8 @@ const struct elf_size_info mips_elf64_size_info =
 #define elf_backend_get_target_dtag    _bfd_mips_elf_get_target_dtag
 #define elf_backend_adjust_dynamic_symbol \
                                _bfd_mips_elf_adjust_dynamic_symbol
-#define elf_backend_always_size_sections \
-                               _bfd_mips_elf_always_size_sections
-#define elf_backend_size_dynamic_sections \
-                               _bfd_mips_elf_size_dynamic_sections
+#define elf_backend_late_size_sections \
+                               _bfd_mips_elf_late_size_sections
 #define elf_backend_init_index_section _bfd_elf_init_1_index_section
 #define elf_backend_relocate_section    _bfd_mips_elf_relocate_section
 #define elf_backend_finish_dynamic_symbol \
@@ -4815,6 +4816,7 @@ const struct elf_size_info mips_elf64_size_info =
 
 #define bfd_elf64_get_dynamic_reloc_upper_bound mips_elf64_get_dynamic_reloc_upper_bound
 #define bfd_elf64_mkobject             _bfd_mips_elf_mkobject
+#define bfd_elf64_bfd_free_cached_info _bfd_mips_elf_free_cached_info
 
 /* The SGI style (n)64 NewABI.  */
 #define TARGET_LITTLE_SYM              mips_elf64_le_vec