Lines Matching refs:sec
144 (bfd *abfd, bfd_byte *contents, asection *sec);
147 Set the compression header at CONTENTS of SEC in ABFD and update
153 asection *sec)
165 struct bfd_elf_section_data * esd = elf_section_data (sec);
171 elf_section_flags (sec) |= SHF_COMPRESSED;
177 bfd_put_32 (abfd, sec->size, &echdr->ch_size);
178 bfd_put_32 (abfd, 1u << sec->alignment_power,
181 bfd_set_section_alignment (sec, 2);
189 bfd_put_64 (abfd, sec->size, &echdr->ch_size);
190 bfd_put_64 (abfd, UINT64_C (1) << sec->alignment_power,
193 bfd_set_section_alignment (sec, 3);
200 elf_section_flags (sec) &= ~SHF_COMPRESSED;
209 bfd_putb64 (sec->size, contents + 4);
211 bfd_set_section_alignment (sec, 0);
216 /* Check the compression header at CONTENTS of SEC in ABFD and store the
224 asection *sec ATTRIBUTE_UNUSED,
231 && (elf_section_flags (sec) & SHF_COMPRESSED) != 0)
269 int bfd_get_compression_header_size (bfd *abfd, asection *sec);
272 Return the size of the compression header of SEC in ABFD.
277 asection *sec ATTRIBUTE_UNUSED)
282 if (sec == NULL)
287 else if (!(elf_section_flags (sec) & SHF_COMPRESSED))
566 bfd_compress_section_contents (bfd *abfd, sec_ptr sec)
579 = bfd_is_section_compressed_info (abfd, sec,
601 input_buffer = sec->contents;
604 zlib_size = sec->size - orig_header_size;
630 bfd_set_section_alignment (sec, uncompressed_alignment_pow);
631 sec->contents = buffer;
632 sec->flags |= SEC_IN_MEMORY;
633 sec->compress_status = COMPRESS_SECTION_NONE;
634 sec->size = uncompressed_size;
690 elf_section_flags (sec) &= ~SHF_COMPRESSED;
692 sec->compress_status = COMPRESS_SECTION_NONE;
696 sec->size = uncompressed_size;
697 bfd_update_compression_header (abfd, buffer, sec);
698 sec->size = compressed_size;
699 sec->compress_status = COMPRESS_SECTION_DONE;
701 sec->alloced = 1;
702 sec->contents = buffer;
703 sec->flags |= SEC_IN_MEMORY;
727 bfd_get_full_section_contents (bfd *abfd, sec_ptr sec, bfd_byte **ptr)
729 bfd_size_type readsz = bfd_get_section_limit_octets (abfd, sec);
730 bfd_size_type allocsz = bfd_get_section_alloc_size (abfd, sec);
737 const unsigned int compress_status = sec->compress_status;
747 && bfd_section_size_insane (abfd, sec))
754 abfd, sec, (uint64_t) readsz);
761 if (p == NULL && !sec->mmapped_p)
771 abfd, sec, (uint64_t) allocsz);
776 if (!bfd_get_section_contents (abfd, sec, p, 0, readsz))
788 compressed_buffer = (bfd_byte *) bfd_malloc (sec->compressed_size);
791 save_rawsize = sec->rawsize;
792 save_size = sec->size;
796 sec->rawsize = 0;
797 sec->size = sec->compressed_size;
798 sec->compress_status = COMPRESS_SECTION_NONE;
799 ret = bfd_get_section_contents (abfd, sec, compressed_buffer,
800 0, sec->compressed_size);
802 sec->rawsize = save_rawsize;
803 sec->size = save_size;
804 sec->compress_status = compress_status;
813 compression_header_size = bfd_get_compression_header_size (abfd, sec);
821 sec->compressed_size - compression_header_size, p, readsz))
836 if (sec->contents == NULL)
846 if (p != sec->contents)
847 memcpy (p, sec->contents, readsz);
878 bfd_is_section_compressed_info (bfd *abfd, sec_ptr sec,
887 unsigned int saved = sec->compress_status;
892 compression_header_size = bfd_get_compression_header_size (abfd, sec);
898 sec->compress_status = COMPRESS_SECTION_NONE;
901 if (bfd_get_section_contents (abfd, sec, header, 0, header_size))
913 *uncompressed_size_p = sec->size;
918 if (!bfd_check_compression_header (abfd, header, sec, ch_type,
927 else if (strcmp (sec->name, ".debug_str") == 0
935 sec->compress_status = saved;
953 bfd_is_section_compressed (bfd *abfd, sec_ptr sec)
959 return (bfd_is_section_compressed_info (abfd, sec,
986 bfd_init_section_decompress_status (bfd *abfd, sec_ptr sec)
995 compression_header_size = bfd_get_compression_header_size (abfd, sec);
1001 if (sec->rawsize != 0
1002 || sec->contents != NULL
1003 || sec->compress_status != COMPRESS_SECTION_NONE
1004 || !bfd_get_section_contents (abfd, sec, header, 0, header_size))
1022 else if (!bfd_check_compression_header (abfd, header, sec,
1034 && (sec->size != (uLong) sec->size
1041 sec->compressed_size = sec->size;
1042 sec->size = uncompressed_size;
1043 bfd_set_section_alignment (sec, uncompressed_alignment_power);
1044 sec->compress_status = (ch_type == ch_compress_zstd
1067 bfd_init_section_compress_status (bfd *abfd, sec_ptr sec)
1074 || sec->size == 0
1075 || sec->rawsize != 0
1076 || sec->contents != NULL
1077 || sec->compress_status != COMPRESS_SECTION_NONE
1078 || bfd_section_size_insane (abfd, sec))
1085 uncompressed_size = sec->size;
1091 if (!bfd_get_section_contents (abfd, sec, uncompressed_buffer,
1098 sec->contents = uncompressed_buffer;
1099 if (bfd_compress_section_contents (abfd, sec) == (bfd_size_type) -1)
1101 free (sec->contents);
1102 sec->contents = NULL;
1125 bfd_compress_section (bfd *abfd, sec_ptr sec, bfd_byte *uncompressed_buffer)
1127 bfd_size_type uncompressed_size = sec
1133 || sec->contents != NULL
1134 || sec->compressed_size != 0
1135 || sec->compress_status != COMPRESS_SECTION_NONE)
1141 sec->contents = uncompressed_buffer;
1142 if (bfd_compress_section_contents (abfd, sec) == (bfd_size_type) -1)
1144 free (sec->contents);
1145 sec->contents = NULL;