Automatic date update in version.in
[external/binutils.git] / bfd / bfd.c
index 8517104..f56a8d3 100644 (file)
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -1,5 +1,5 @@
 /* Generic BFD library interface and support routines.
-   Copyright (C) 1990-2018 Free Software Foundation, Inc.
+   Copyright (C) 1990-2019 Free Software Foundation, Inc.
    Written by Cygnus Support.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -220,6 +220,9 @@ CODE_FRAGMENT
 .  {* Set if this is a thin archive.  *}
 .  unsigned int is_thin_archive : 1;
 .
+.  {* Set if this archive should not cache element positions.  *}
+.  unsigned int no_element_cache : 1;
+.
 .  {* Set if only required symbols should be added in the link hash table for
 .     this object.  Used by VMS linkers.  *}
 .  unsigned int selective_search : 1;
@@ -236,6 +239,9 @@ CODE_FRAGMENT
 .  {* Set if this is a plugin output file.  *}
 .  unsigned int lto_output : 1;
 .
+.  {* Set if this is a slim LTO object not loaded with a compiler plugin.  *}
+.  unsigned int lto_slim_object : 1;
+.
 .  {* Set to dummy BFD created when claimed by a compiler plug-in
 .     library.  *}
 .  bfd *plugin_dummy_bfd;
@@ -2332,6 +2338,8 @@ bfd_update_compression_header (bfd *abfd, bfd_byte *contents,
                  bfd_put_32 (abfd, sec->size, &echdr->ch_size);
                  bfd_put_32 (abfd, 1 << sec->alignment_power,
                              &echdr->ch_addralign);
+                 /* bfd_log2 (alignof (Elf32_Chdr)) */
+                 bfd_set_section_alignment (abfd, sec, 2);
                }
              else
                {
@@ -2342,6 +2350,8 @@ bfd_update_compression_header (bfd *abfd, bfd_byte *contents,
                  bfd_put_64 (abfd, sec->size, &echdr->ch_size);
                  bfd_put_64 (abfd, 1 << sec->alignment_power,
                              &echdr->ch_addralign);
+                 /* bfd_log2 (alignof (Elf64_Chdr)) */
+                 bfd_set_section_alignment (abfd, sec, 3);
                }
            }
          else
@@ -2354,6 +2364,8 @@ bfd_update_compression_header (bfd *abfd, bfd_byte *contents,
                 order.  */
              memcpy (contents, "ZLIB", 4);
              bfd_putb64 (sec->size, contents + 4);
+             /* No way to keep the original alignment, just use 1 always. */
+             bfd_set_section_alignment (abfd, sec, 0);
            }
        }
     }
@@ -2368,12 +2380,14 @@ bfd_update_compression_header (bfd *abfd, bfd_byte *contents,
    SYNOPSIS
        bfd_boolean bfd_check_compression_header
          (bfd *abfd, bfd_byte *contents, asection *sec,
-         bfd_size_type *uncompressed_size);
+         bfd_size_type *uncompressed_size,
+         unsigned int *uncompressed_alignment_power);
 
 DESCRIPTION
        Check the compression header at CONTENTS of SEC in ABFD and
-       store the uncompressed size in UNCOMPRESSED_SIZE if the
-       compression header is valid.
+       store the uncompressed size in UNCOMPRESSED_SIZE and the
+       uncompressed data alignment in UNCOMPRESSED_ALIGNMENT_POWER
+       if the compression header is valid.
 
 RETURNS
        Return TRUE if the compression header is valid.
@@ -2382,7 +2396,8 @@ RETURNS
 bfd_boolean
 bfd_check_compression_header (bfd *abfd, bfd_byte *contents,
                              asection *sec,
-                             bfd_size_type *uncompressed_size)
+                             bfd_size_type *uncompressed_size,
+                             unsigned int *uncompressed_alignment_power)
 {
   if (bfd_get_flavour (abfd) == bfd_target_elf_flavour
       && (elf_section_flags (sec) & SHF_COMPRESSED) != 0)
@@ -2404,9 +2419,10 @@ bfd_check_compression_header (bfd *abfd, bfd_byte *contents,
          chdr.ch_addralign = bfd_get_64 (abfd, &echdr->ch_addralign);
        }
       if (chdr.ch_type == ELFCOMPRESS_ZLIB
-         && chdr.ch_addralign == 1U << sec->alignment_power)
+         && chdr.ch_addralign == (1U << bfd_log2 (chdr.ch_addralign)))
        {
          *uncompressed_size = chdr.ch_size;
+         *uncompressed_alignment_power = bfd_log2 (chdr.ch_addralign);
          return TRUE;
        }
     }
@@ -2469,10 +2485,6 @@ bfd_convert_section_size (bfd *ibfd, sec_ptr isec, bfd *obfd,
 {
   bfd_size_type hdr_size;
 
-  /* Do nothing if input file will be decompressed.  */
-  if ((ibfd->flags & BFD_DECOMPRESS))
-    return size;
-
   /* Do nothing if either input or output aren't ELF.  */
   if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
       || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
@@ -2483,6 +2495,14 @@ bfd_convert_section_size (bfd *ibfd, sec_ptr isec, bfd *obfd,
       == get_elf_backend_data (obfd)->s->elfclass)
     return size;
 
+  /* Convert GNU property size.  */
+  if (CONST_STRNEQ (isec->name, NOTE_GNU_PROPERTY_SECTION_NAME))
+    return _bfd_elf_convert_gnu_property_size (ibfd, obfd);
+
+  /* Do nothing if input file will be decompressed.  */
+  if ((ibfd->flags & BFD_DECOMPRESS))
+    return size;
+
   /* Do nothing if the input section isn't a SHF_COMPRESSED section. */
   hdr_size = bfd_get_compression_header_size (ibfd, isec);
   if (hdr_size == 0)
@@ -2523,10 +2543,6 @@ bfd_convert_section_contents (bfd *ibfd, sec_ptr isec, bfd *obfd,
   Elf_Internal_Chdr chdr;
   bfd_boolean use_memmove;
 
-  /* Do nothing if input file will be decompressed.  */
-  if ((ibfd->flags & BFD_DECOMPRESS))
-    return TRUE;
-
   /* Do nothing if either input or output aren't ELF.  */
   if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
       || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
@@ -2537,6 +2553,15 @@ bfd_convert_section_contents (bfd *ibfd, sec_ptr isec, bfd *obfd,
       == get_elf_backend_data (obfd)->s->elfclass)
     return TRUE;
 
+  /* Convert GNU properties.  */
+  if (CONST_STRNEQ (isec->name, NOTE_GNU_PROPERTY_SECTION_NAME))
+    return _bfd_elf_convert_gnu_properties (ibfd, isec, obfd, ptr,
+                                           ptr_size);
+
+  /* Do nothing if input file will be decompressed.  */
+  if ((ibfd->flags & BFD_DECOMPRESS))
+    return TRUE;
+
   /* Do nothing if the input section isn't a SHF_COMPRESSED section. */
   ihdr_size = bfd_get_compression_header_size (ibfd, isec);
   if (ihdr_size == 0)