AArch64: Fix regression in Cortex A53 erratum when PIE. (PR ld/23904)
[deliverable/binutils-gdb.git] / bfd / compress.c
CommitLineData
0acf065b 1/* Compressed section support (intended for debug sections).
219d1afa 2 Copyright (C) 2008-2018 Free Software Foundation, Inc.
1b315056
CS
3
4 This file is part of BFD, the Binary File Descriptor library.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19 MA 02110-1301, USA. */
20
1b315056 21#include "sysdep.h"
243340ad 22#include <zlib.h>
1b315056
CS
23#include "bfd.h"
24#include "libbfd.h"
a953eec9 25#include "safe-ctype.h"
1b315056 26
151411f8
L
27#define MAX_COMPRESSION_HEADER_SIZE 24
28
4a114e3e
L
29static bfd_boolean
30decompress_contents (bfd_byte *compressed_buffer,
31 bfd_size_type compressed_size,
32 bfd_byte *uncompressed_buffer,
33 bfd_size_type uncompressed_size)
34{
35 z_stream strm;
36 int rc;
37
38 /* It is possible the section consists of several compressed
39 buffers concatenated together, so we uncompress in a loop. */
de13ef81
NC
40 /* PR 18313: The state field in the z_stream structure is supposed
41 to be invisible to the user (ie us), but some compilers will
42 still complain about it being used without initialisation. So
43 we first zero the entire z_stream structure and then set the fields
44 that we need. */
45 memset (& strm, 0, sizeof strm);
dab394de
L
46 strm.avail_in = compressed_size;
47 strm.next_in = (Bytef*) compressed_buffer;
4a114e3e
L
48 strm.avail_out = uncompressed_size;
49
a253d456 50 BFD_ASSERT (Z_OK == 0);
4a114e3e 51 rc = inflateInit (&strm);
a29a8af8 52 while (strm.avail_in > 0 && strm.avail_out > 0)
4a114e3e
L
53 {
54 if (rc != Z_OK)
a253d456 55 break;
4a114e3e 56 strm.next_out = ((Bytef*) uncompressed_buffer
07d6d2b8 57 + (uncompressed_size - strm.avail_out));
4a114e3e
L
58 rc = inflate (&strm, Z_FINISH);
59 if (rc != Z_STREAM_END)
a253d456 60 break;
4a114e3e
L
61 rc = inflateReset (&strm);
62 }
a253d456 63 rc |= inflateEnd (&strm);
82c6068a 64 return rc == Z_OK && strm.avail_out == 0;
4a114e3e 65}
4a114e3e 66
0b0732e1
L
67/* Compress data of the size specified in @var{uncompressed_size}
68 and pointed to by @var{uncompressed_buffer} using zlib and store
69 as the contents field. This function assumes the contents
18ece1de 70 field was allocated using bfd_malloc() or equivalent.
1b315056 71
151411f8
L
72 Return the uncompressed size if the full section contents is
73 compressed successfully. Otherwise return 0. */
1b315056 74
151411f8
L
75static bfd_size_type
76bfd_compress_section_contents (bfd *abfd, sec_ptr sec,
243340ad 77 bfd_byte *uncompressed_buffer,
3e19fb8f 78 bfd_size_type uncompressed_size)
1b315056 79{
ae6a0217 80 uLong compressed_size;
151411f8
L
81 bfd_byte *buffer;
82 bfd_size_type buffer_size;
83 bfd_boolean decompress;
51509926 84 int zlib_size = 0;
151411f8 85 int orig_compression_header_size;
dab394de 86 bfd_size_type orig_uncompressed_size;
4207142d 87 unsigned int orig_uncompressed_alignment_pow;
dab394de 88 int header_size = bfd_get_compression_header_size (abfd, NULL);
151411f8
L
89 bfd_boolean compressed
90 = bfd_is_section_compressed_with_header (abfd, sec,
dab394de 91 &orig_compression_header_size,
4207142d
MW
92 &orig_uncompressed_size,
93 &orig_uncompressed_alignment_pow);
dab394de
L
94
95 /* Either ELF compression header or the 12-byte, "ZLIB" + 8-byte size,
96 overhead in .zdebug* section. */
97 if (!header_size)
98 header_size = 12;
151411f8
L
99
100 if (compressed)
101 {
102 /* We shouldn't decompress unsupported compressed section. */
103 if (orig_compression_header_size < 0)
104 abort ();
4a114e3e 105
151411f8
L
106 /* Different compression schemes. Just move the compressed section
107 contents to the right position. */
108 if (orig_compression_header_size == 0)
109 {
110 /* Convert it from .zdebug* section. Get the uncompressed
de194d85 111 size first. We need to subtract the 12-byte overhead in
dab394de
L
112 .zdebug* section. Set orig_compression_header_size to
113 the 12-bye overhead. */
114 orig_compression_header_size = 12;
115 zlib_size = uncompressed_size - 12;
151411f8
L
116 }
117 else
118 {
dab394de 119 /* Convert it to .zdebug* section. */
151411f8 120 zlib_size = uncompressed_size - orig_compression_header_size;
151411f8 121 }
dab394de
L
122
123 /* Add the header size. */
124 compressed_size = zlib_size + header_size;
151411f8
L
125 }
126 else
dab394de 127 compressed_size = compressBound (uncompressed_size) + header_size;
4281caad 128
dab394de
L
129 /* Uncompress if it leads to smaller size. */
130 if (compressed && compressed_size > orig_uncompressed_size)
4a114e3e 131 {
151411f8 132 decompress = TRUE;
dab394de 133 buffer_size = orig_uncompressed_size;
4a114e3e 134 }
151411f8
L
135 else
136 {
137 decompress = FALSE;
dab394de 138 buffer_size = compressed_size;
151411f8 139 }
030aeb75 140 buffer = (bfd_byte *) bfd_alloc (abfd, buffer_size);
151411f8
L
141 if (buffer == NULL)
142 return 0;
4a114e3e 143
151411f8 144 if (compressed)
8d001214 145 {
dab394de 146 sec->size = orig_uncompressed_size;
151411f8
L
147 if (decompress)
148 {
dab394de
L
149 if (!decompress_contents (uncompressed_buffer
150 + orig_compression_header_size,
151 zlib_size, buffer, buffer_size))
151411f8
L
152 {
153 bfd_set_error (bfd_error_bad_value);
030aeb75 154 bfd_release (abfd, buffer);
151411f8
L
155 return 0;
156 }
157 free (uncompressed_buffer);
4207142d
MW
158 bfd_set_section_alignment (abfd, sec,
159 orig_uncompressed_alignment_pow);
160
151411f8
L
161 sec->contents = buffer;
162 sec->compress_status = COMPRESS_SECTION_DONE;
dab394de 163 return orig_uncompressed_size;
151411f8
L
164 }
165 else
166 {
167 bfd_update_compression_header (abfd, buffer, sec);
dab394de 168 memmove (buffer + header_size,
151411f8
L
169 uncompressed_buffer + orig_compression_header_size,
170 zlib_size);
171 }
8d001214
L
172 }
173 else
174 {
151411f8
L
175 if (compress ((Bytef*) buffer + header_size,
176 &compressed_size,
177 (const Bytef*) uncompressed_buffer,
178 uncompressed_size) != Z_OK)
179 {
030aeb75 180 bfd_release (abfd, buffer);
151411f8
L
181 bfd_set_error (bfd_error_bad_value);
182 return 0;
183 }
184
185 compressed_size += header_size;
186 /* PR binutils/18087: If compression didn't make the section smaller,
3e19fb8f
L
187 just keep it uncompressed. */
188 if (compressed_size < uncompressed_size)
dab394de 189 bfd_update_compression_header (abfd, buffer, sec);
151411f8
L
190 else
191 {
030aeb75
L
192 /* NOTE: There is a small memory leak here since
193 uncompressed_buffer is malloced and won't be freed. */
194 bfd_release (abfd, buffer);
151411f8
L
195 sec->contents = uncompressed_buffer;
196 sec->compress_status = COMPRESS_SECTION_NONE;
197 return uncompressed_size;
198 }
8d001214 199 }
4a114e3e 200
151411f8
L
201 free (uncompressed_buffer);
202 sec->contents = buffer;
203 sec->size = compressed_size;
204 sec->compress_status = COMPRESS_SECTION_DONE;
205
206 return uncompressed_size;
4a114e3e
L
207}
208
209/*
210FUNCTION
211 bfd_get_full_section_contents
212
213SYNOPSIS
214 bfd_boolean bfd_get_full_section_contents
215 (bfd *abfd, asection *section, bfd_byte **ptr);
216
217DESCRIPTION
218 Read all data from @var{section} in BFD @var{abfd}, decompress
219 if needed, and store in @var{*ptr}. If @var{*ptr} is NULL,
68ffbac6 220 return @var{*ptr} with memory malloc'd by this function.
4a114e3e
L
221
222 Return @code{TRUE} if the full section contents is retrieved
06614111
NC
223 successfully. If the section has no contents then this function
224 returns @code{TRUE} but @var{*ptr} is set to NULL.
4a114e3e
L
225*/
226
227bfd_boolean
228bfd_get_full_section_contents (bfd *abfd, sec_ptr sec, bfd_byte **ptr)
229{
e57278ef 230 bfd_size_type sz;
4a114e3e 231 bfd_byte *p = *ptr;
82c6068a 232 bfd_boolean ret;
38b774d2
AM
233 bfd_size_type save_size;
234 bfd_size_type save_rawsize;
4a114e3e 235 bfd_byte *compressed_buffer;
151411f8 236 unsigned int compression_header_size;
4a114e3e 237
e57278ef
AM
238 if (abfd->direction != write_direction && sec->rawsize != 0)
239 sz = sec->rawsize;
240 else
241 sz = sec->size;
4a114e3e 242 if (sz == 0)
06614111
NC
243 {
244 *ptr = NULL;
245 return TRUE;
246 }
4a114e3e
L
247
248 switch (sec->compress_status)
249 {
250 case COMPRESS_SECTION_NONE:
251 if (p == NULL)
252 {
0d13c96b 253 p = (bfd_byte *) bfd_malloc (sz);
4a114e3e 254 if (p == NULL)
a18590c3
NC
255 {
256 /* PR 20801: Provide a more helpful error message. */
257 if (bfd_get_error () == bfd_error_no_memory)
258 _bfd_error_handler
259 /* xgettext:c-format */
2dcf00ce
AM
260 (_("error: %pB(%pA) is too large (%#" PRIx64 " bytes)"),
261 abfd, sec, (uint64_t) sz);
0630b49c 262 return FALSE;
a18590c3 263 }
4a114e3e 264 }
06614111 265
82c6068a
AM
266 if (!bfd_get_section_contents (abfd, sec, p, 0, sz))
267 {
268 if (*ptr != p)
269 free (p);
270 return FALSE;
271 }
272 *ptr = p;
4a114e3e
L
273 return TRUE;
274
275 case DECOMPRESS_SECTION_SIZED:
82c6068a 276 /* Read in the full compressed section contents. */
38b774d2 277 compressed_buffer = (bfd_byte *) bfd_malloc (sec->compressed_size);
82c6068a
AM
278 if (compressed_buffer == NULL)
279 return FALSE;
38b774d2
AM
280 save_rawsize = sec->rawsize;
281 save_size = sec->size;
82c6068a
AM
282 /* Clear rawsize, set size to compressed size and set compress_status
283 to COMPRESS_SECTION_NONE. If the compressed size is bigger than
284 the uncompressed size, bfd_get_section_contents will fail. */
285 sec->rawsize = 0;
38b774d2 286 sec->size = sec->compressed_size;
82c6068a
AM
287 sec->compress_status = COMPRESS_SECTION_NONE;
288 ret = bfd_get_section_contents (abfd, sec, compressed_buffer,
38b774d2 289 0, sec->compressed_size);
82c6068a 290 /* Restore rawsize and size. */
38b774d2
AM
291 sec->rawsize = save_rawsize;
292 sec->size = save_size;
4a114e3e 293 sec->compress_status = DECOMPRESS_SECTION_SIZED;
82c6068a
AM
294 if (!ret)
295 goto fail_compressed;
4a114e3e 296
38b774d2
AM
297 if (p == NULL)
298 p = (bfd_byte *) bfd_malloc (sz);
299 if (p == NULL)
4a114e3e 300 goto fail_compressed;
4a114e3e 301
151411f8 302 compression_header_size = bfd_get_compression_header_size (abfd, sec);
dab394de
L
303 if (compression_header_size == 0)
304 /* Set header size to the zlib header size if it is a
305 SHF_COMPRESSED section. */
306 compression_header_size = 12;
151411f8 307 if (!decompress_contents (compressed_buffer + compression_header_size,
6438d1be 308 sec->compressed_size - compression_header_size, p, sz))
82c6068a
AM
309 {
310 bfd_set_error (bfd_error_bad_value);
38b774d2
AM
311 if (p != *ptr)
312 free (p);
82c6068a
AM
313 fail_compressed:
314 free (compressed_buffer);
315 return FALSE;
316 }
4a114e3e 317
82c6068a 318 free (compressed_buffer);
38b774d2
AM
319 *ptr = p;
320 return TRUE;
4a114e3e 321
82c6068a 322 case COMPRESS_SECTION_DONE:
db6b071a
NC
323 if (sec->contents == NULL)
324 return FALSE;
82c6068a
AM
325 if (p == NULL)
326 {
327 p = (bfd_byte *) bfd_malloc (sz);
328 if (p == NULL)
329 return FALSE;
330 *ptr = p;
331 }
06614111
NC
332 /* PR 17512; file: 5bc29788. */
333 if (p != sec->contents)
334 memcpy (p, sec->contents, sz);
82c6068a 335 return TRUE;
4a114e3e 336
82c6068a
AM
337 default:
338 abort ();
339 }
4a114e3e
L
340}
341
8a72cc6e
AM
342/*
343FUNCTION
344 bfd_cache_section_contents
345
346SYNOPSIS
347 void bfd_cache_section_contents
348 (asection *sec, void *contents);
349
350DESCRIPTION
351 Stash @var(contents) so any following reads of @var(sec) do
352 not need to decompress again.
353*/
354
355void
356bfd_cache_section_contents (asection *sec, void *contents)
357{
358 if (sec->compress_status == DECOMPRESS_SECTION_SIZED)
359 sec->compress_status = COMPRESS_SECTION_DONE;
360 sec->contents = contents;
361 sec->flags |= SEC_IN_MEMORY;
362}
363
4a114e3e
L
364/*
365FUNCTION
151411f8 366 bfd_is_section_compressed_with_header
4a114e3e
L
367
368SYNOPSIS
151411f8
L
369 bfd_boolean bfd_is_section_compressed_with_header
370 (bfd *abfd, asection *section,
dab394de 371 int *compression_header_size_p,
4207142d
MW
372 bfd_size_type *uncompressed_size_p,
373 unsigned int *uncompressed_alignment_power_p);
4a114e3e
L
374
375DESCRIPTION
151411f8 376 Return @code{TRUE} if @var{section} is compressed. Compression
4207142d
MW
377 header size is returned in @var{compression_header_size_p},
378 uncompressed size is returned in @var{uncompressed_size_p}
379 and the uncompressed data alignement power is returned in
380 @var{uncompressed_align_pow_p}. If compression is
381 unsupported, compression header size is returned with -1
382 and uncompressed size is returned with 0.
4a114e3e
L
383*/
384
385bfd_boolean
151411f8 386bfd_is_section_compressed_with_header (bfd *abfd, sec_ptr sec,
dab394de 387 int *compression_header_size_p,
4207142d
MW
388 bfd_size_type *uncompressed_size_p,
389 unsigned int *uncompressed_align_pow_p)
4a114e3e 390{
dab394de 391 bfd_byte header[MAX_COMPRESSION_HEADER_SIZE];
151411f8 392 int compression_header_size;
dab394de 393 int header_size;
64f40162
L
394 unsigned int saved = sec->compress_status;
395 bfd_boolean compressed;
396
151411f8
L
397 compression_header_size = bfd_get_compression_header_size (abfd, sec);
398 if (compression_header_size > MAX_COMPRESSION_HEADER_SIZE)
399 abort ();
dab394de 400 header_size = compression_header_size ? compression_header_size : 12;
151411f8 401
64f40162
L
402 /* Don't decompress the section. */
403 sec->compress_status = COMPRESS_SECTION_NONE;
4a114e3e 404
dab394de
L
405 /* Read the header. */
406 if (bfd_get_section_contents (abfd, sec, header, 0, header_size))
407 {
408 if (compression_header_size == 0)
07d6d2b8 409 /* In this case, it should be "ZLIB" followed by the uncompressed
dab394de
L
410 section size, 8 bytes in big-endian order. */
411 compressed = CONST_STRNEQ ((char*) header , "ZLIB");
412 else
413 compressed = TRUE;
414 }
415 else
416 compressed = FALSE;
64f40162 417
dab394de 418 *uncompressed_size_p = sec->size;
151411f8
L
419 if (compressed)
420 {
421 if (compression_header_size != 0)
422 {
151411f8 423 if (!bfd_check_compression_header (abfd, header, sec,
4207142d
MW
424 uncompressed_size_p,
425 uncompressed_align_pow_p))
151411f8
L
426 compression_header_size = -1;
427 }
428 /* Check for the pathalogical case of a debug string section that
429 contains the string ZLIB.... as the first entry. We assume that
430 no uncompressed .debug_str section would ever be big enough to
431 have the first byte of its (big-endian) size be non-zero. */
432 else if (strcmp (sec->name, ".debug_str") == 0
dab394de 433 && ISPRINT (header[4]))
151411f8 434 compressed = FALSE;
dab394de
L
435 else
436 *uncompressed_size_p = bfd_getb64 (header + 4);
151411f8 437 }
a953eec9 438
64f40162
L
439 /* Restore compress_status. */
440 sec->compress_status = saved;
151411f8 441 *compression_header_size_p = compression_header_size;
64f40162 442 return compressed;
4a114e3e
L
443}
444
151411f8
L
445/*
446FUNCTION
447 bfd_is_section_compressed
448
449SYNOPSIS
450 bfd_boolean bfd_is_section_compressed
451 (bfd *abfd, asection *section);
452
453DESCRIPTION
454 Return @code{TRUE} if @var{section} is compressed.
455*/
456
457bfd_boolean
458bfd_is_section_compressed (bfd *abfd, sec_ptr sec)
459{
460 int compression_header_size;
dab394de 461 bfd_size_type uncompressed_size;
4207142d 462 unsigned int uncompressed_align_power;
151411f8 463 return (bfd_is_section_compressed_with_header (abfd, sec,
dab394de 464 &compression_header_size,
4207142d
MW
465 &uncompressed_size,
466 &uncompressed_align_power)
dab394de
L
467 && compression_header_size >= 0
468 && uncompressed_size > 0);
151411f8
L
469}
470
4a114e3e
L
471/*
472FUNCTION
473 bfd_init_section_decompress_status
474
475SYNOPSIS
476 bfd_boolean bfd_init_section_decompress_status
477 (bfd *abfd, asection *section);
478
479DESCRIPTION
480 Record compressed section size, update section size with
481 decompressed size and set compress_status to
482 DECOMPRESS_SECTION_SIZED.
483
484 Return @code{FALSE} if the section is not a valid compressed
18ece1de 485 section. Otherwise, return @code{TRUE}.
4a114e3e
L
486*/
487
488bfd_boolean
243340ad 489bfd_init_section_decompress_status (bfd *abfd, sec_ptr sec)
4a114e3e 490{
dab394de 491 bfd_byte header[MAX_COMPRESSION_HEADER_SIZE];
151411f8 492 int compression_header_size;
dab394de 493 int header_size;
4a114e3e 494 bfd_size_type uncompressed_size;
4207142d 495 unsigned int uncompressed_alignment_power = 0;
4a114e3e 496
151411f8
L
497 compression_header_size = bfd_get_compression_header_size (abfd, sec);
498 if (compression_header_size > MAX_COMPRESSION_HEADER_SIZE)
499 abort ();
dab394de 500 header_size = compression_header_size ? compression_header_size : 12;
151411f8 501
dab394de 502 /* Read the header. */
4a114e3e
L
503 if (sec->rawsize != 0
504 || sec->contents != NULL
505 || sec->compress_status != COMPRESS_SECTION_NONE
151411f8 506 || !bfd_get_section_contents (abfd, sec, header, 0, header_size))
4a114e3e
L
507 {
508 bfd_set_error (bfd_error_invalid_operation);
509 return FALSE;
510 }
1b315056 511
dab394de 512 if (compression_header_size == 0)
4a114e3e 513 {
dab394de
L
514 /* In this case, it should be "ZLIB" followed by the uncompressed
515 section size, 8 bytes in big-endian order. */
516 if (! CONST_STRNEQ ((char*) header, "ZLIB"))
517 {
518 bfd_set_error (bfd_error_wrong_format);
519 return FALSE;
520 }
521 uncompressed_size = bfd_getb64 (header + 4);
4a114e3e 522 }
dab394de 523 else if (!bfd_check_compression_header (abfd, header, sec,
4207142d
MW
524 &uncompressed_size,
525 &uncompressed_alignment_power))
151411f8
L
526 {
527 bfd_set_error (bfd_error_wrong_format);
528 return FALSE;
529 }
dab394de 530
4a114e3e
L
531 sec->compressed_size = sec->size;
532 sec->size = uncompressed_size;
4207142d 533 bfd_set_section_alignment (abfd, sec, uncompressed_alignment_power);
4a114e3e 534 sec->compress_status = DECOMPRESS_SECTION_SIZED;
1b315056 535
4a114e3e 536 return TRUE;
4a114e3e
L
537}
538
539/*
540FUNCTION
541 bfd_init_section_compress_status
542
543SYNOPSIS
544 bfd_boolean bfd_init_section_compress_status
545 (bfd *abfd, asection *section);
546
547DESCRIPTION
548 If open for read, compress section, update section size with
549 compressed size and set compress_status to COMPRESS_SECTION_DONE.
550
551 Return @code{FALSE} if the section is not a valid compressed
18ece1de 552 section. Otherwise, return @code{TRUE}.
4a114e3e
L
553*/
554
555bfd_boolean
243340ad 556bfd_init_section_compress_status (bfd *abfd, sec_ptr sec)
4a114e3e 557{
4a114e3e
L
558 bfd_size_type uncompressed_size;
559 bfd_byte *uncompressed_buffer;
4a114e3e
L
560
561 /* Error if not opened for read. */
562 if (abfd->direction != read_direction
563 || sec->size == 0
564 || sec->rawsize != 0
565 || sec->contents != NULL
566 || sec->compress_status != COMPRESS_SECTION_NONE)
1b315056 567 {
4a114e3e
L
568 bfd_set_error (bfd_error_invalid_operation);
569 return FALSE;
1b315056 570 }
1b315056 571
4a114e3e
L
572 /* Read in the full section contents and compress it. */
573 uncompressed_size = sec->size;
574 uncompressed_buffer = (bfd_byte *) bfd_malloc (uncompressed_size);
e63d1232
NC
575 /* PR 21431 */
576 if (uncompressed_buffer == NULL)
577 return FALSE;
578
4a114e3e
L
579 if (!bfd_get_section_contents (abfd, sec, uncompressed_buffer,
580 0, uncompressed_size))
e63d1232 581 return FALSE;
1b315056 582
e63d1232
NC
583 uncompressed_size = bfd_compress_section_contents (abfd, sec,
584 uncompressed_buffer,
585 uncompressed_size);
586 return uncompressed_size != 0;
1b315056 587}
0ce398f1
L
588
589/*
590FUNCTION
591 bfd_compress_section
592
593SYNOPSIS
594 bfd_boolean bfd_compress_section
595 (bfd *abfd, asection *section, bfd_byte *uncompressed_buffer);
596
597DESCRIPTION
598 If open for write, compress section, update section size with
599 compressed size and set compress_status to COMPRESS_SECTION_DONE.
600
601 Return @code{FALSE} if compression fail. Otherwise, return
602 @code{TRUE}.
603*/
604
605bfd_boolean
606bfd_compress_section (bfd *abfd, sec_ptr sec, bfd_byte *uncompressed_buffer)
607{
608 bfd_size_type uncompressed_size = sec->size;
609
610 /* Error if not opened for write. */
611 if (abfd->direction != write_direction
612 || uncompressed_size == 0
613 || uncompressed_buffer == NULL
614 || sec->contents != NULL
615 || sec->compressed_size != 0
616 || sec->compress_status != COMPRESS_SECTION_NONE)
617 {
618 bfd_set_error (bfd_error_invalid_operation);
619 return FALSE;
620 }
621
622 /* Compress it. */
623 return bfd_compress_section_contents (abfd, sec, uncompressed_buffer,
3e19fb8f 624 uncompressed_size) != 0;
0ce398f1 625}
This page took 0.535291 seconds and 4 git commands to generate.