Lines Matching refs:sec
142 (bfd *abfd, bfd_byte *contents, asection *sec);
145 Set the compression header at CONTENTS of SEC in ABFD and update
151 asection *sec)
162 struct bfd_elf_section_data * esd = elf_section_data (sec);
168 elf_section_flags (sec) |= SHF_COMPRESSED;
174 bfd_put_32 (abfd, sec->size, &echdr->ch_size);
175 bfd_put_32 (abfd, 1u << sec->alignment_power,
178 bfd_set_section_alignment (sec, 2);
186 bfd_put_64 (abfd, sec->size, &echdr->ch_size);
187 bfd_put_64 (abfd, UINT64_C (1) << sec->alignment_power,
190 bfd_set_section_alignment (sec, 3);
197 elf_section_flags (sec) &= ~SHF_COMPRESSED;
205 bfd_putb64 (sec->size, contents + 4);
207 bfd_set_section_alignment (sec, 0);
212 /* Check the compression header at CONTENTS of SEC in ABFD and store the
219 asection *sec,
225 && (elf_section_flags (sec) & SHF_COMPRESSED) != 0)
262 int bfd_get_compression_header_size (bfd *abfd, asection *sec);
265 Return the size of the compression header of SEC in ABFD.
269 bfd_get_compression_header_size (bfd *abfd, asection *sec)
273 if (sec == NULL)
278 else if (!(elf_section_flags (sec) & SHF_COMPRESSED))
547 sec)
560 = bfd_is_section_compressed_info (abfd, sec,
582 input_buffer = sec->contents;
585 zlib_size = sec->size - orig_header_size;
611 bfd_set_section_alignment (sec, uncompressed_alignment_pow);
612 sec->contents = buffer;
613 sec->flags |= SEC_IN_MEMORY;
614 sec->compress_status = COMPRESS_SECTION_NONE;
615 sec->size = uncompressed_size;
670 elf_section_flags (sec) &= ~SHF_COMPRESSED;
671 sec->compress_status = COMPRESS_SECTION_NONE;
675 sec->size = uncompressed_size;
676 bfd_update_compression_header (abfd, buffer, sec);
677 sec->size = compressed_size;
678 sec->compress_status = COMPRESS_SECTION_DONE;
680 sec->alloced = 1;
681 sec->contents = buffer;
682 sec->flags |= SEC_IN_MEMORY;
706 bfd_get_full_section_contents (bfd *abfd, sec_ptr sec, bfd_byte **ptr)
708 bfd_size_type readsz = bfd_get_section_limit_octets (abfd, sec);
709 bfd_size_type allocsz = bfd_get_section_alloc_size (abfd, sec);
716 const unsigned int compress_status = sec->compress_status;
726 && bfd_section_size_insane (abfd, sec))
733 abfd, sec, (uint64_t) readsz);
740 if (p == NULL && !sec->mmapped_p)
750 abfd, sec, (uint64_t) allocsz);
755 if (!bfd_get_section_contents (abfd, sec, p, 0, readsz))
767 compressed_buffer = (bfd_byte *) bfd_malloc (sec->compressed_size);
770 save_rawsize = sec->rawsize;
771 save_size = sec->size;
775 sec->rawsize = 0;
776 sec->size = sec->compressed_size;
777 sec->compress_status = COMPRESS_SECTION_NONE;
778 ret = bfd_get_section_contents (abfd, sec, compressed_buffer,
779 0, sec->compressed_size);
781 sec->rawsize = save_rawsize;
782 sec->size = save_size;
783 sec->compress_status = compress_status;
792 compression_header_size = bfd_get_compression_header_size (abfd, sec);
800 sec->compressed_size - compression_header_size, p, readsz))
815 if (sec->contents == NULL)
825 if (p != sec->contents)
826 memcpy (p, sec->contents, readsz);
857 bfd_is_section_compressed_info (bfd *abfd, sec_ptr sec,
866 unsigned int saved = sec->compress_status;
871 compression_header_size = bfd_get_compression_header_size (abfd, sec);
877 sec->compress_status = COMPRESS_SECTION_NONE;
880 if (bfd_get_section_contents (abfd, sec, header, 0, header_size))
892 *uncompressed_size_p = sec->size;
897 if (!bfd_check_compression_header (abfd, header, sec, ch_type,
906 else if (strcmp (sec->name, ".debug_str") == 0
914 sec->compress_status = saved;
932 bfd_is_section_compressed (bfd *abfd, sec_ptr sec)
938 return (bfd_is_section_compressed_info (abfd, sec,
965 bfd_init_section_decompress_status (bfd *abfd, sec_ptr sec)
974 compression_header_size = bfd_get_compression_header_size (abfd, sec);
980 if (sec->rawsize != 0
981 || sec->contents != NULL
982 || sec->compress_status != COMPRESS_SECTION_NONE
983 || !bfd_get_section_contents (abfd, sec, header, 0, header_size))
1001 else if (!bfd_check_compression_header (abfd, header, sec,
1013 && (sec->size != (uLong) sec->size
1020 sec->compressed_size = sec->size;
1021 sec->size = uncompressed_size;
1022 bfd_set_section_alignment (sec, uncompressed_alignment_power);
1023 sec->compress_status = (ch_type == ch_compress_zstd
1046 bfd_init_section_compress_status (bfd *abfd, sec_ptr sec)
1053 || sec->size == 0
1054 || sec->rawsize != 0
1055 || sec->contents != NULL
1056 || sec->compress_status != COMPRESS_SECTION_NONE
1057 || bfd_section_size_insane (abfd, sec))
1064 uncompressed_size = sec->size;
1070 if (!bfd_get_section_contents (abfd, sec, uncompressed_buffer,
1077 sec->contents = uncompressed_buffer;
1078 if (bfd_compress_section_contents (abfd, sec) == (bfd_size_type) -1)
1080 free (sec->contents);
1081 sec->contents = NULL;
1104 bfd_compress_section (bfd *abfd, sec_ptr sec, bfd_byte *uncompressed_buffer)
1106 bfd_size_type uncompressed_size = sec->size;
1112 || sec->contents != NULL
1113 || sec->compressed_size != 0
1114 || sec->compress_status != COMPRESS_SECTION_NONE)
1120 sec->contents = uncompressed_buffer;
1121 if (bfd_compress_section_contents (abfd, sec) == (bfd_size_type) -1)
1123 free (sec->contents);
1124 sec->contents = NULL;