compress.c 19 KB

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