This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [patch] Add --compress-debug-sections option to gas
- From: Alan Modra <amodra at gmail dot com>
- To: Cary Coutant <ccoutant at google dot com>
- Cc: Binutils <binutils at sourceware dot org>
- Date: Fri, 2 Jul 2010 11:59:17 +0930
- Subject: Re: [patch] Add --compress-debug-sections option to gas
- References: <AANLkTim2Li4CdH8itmx1q-8oxxuH0EOcFjzaSsQzmKzX@mail.gmail.com> <20100629080745.GB6954@bubble.grove.modra.org> <AANLkTimTWfQYiyuwTbFQUK1d8wlUe_n-kdoouiTBpRS7@mail.gmail.com>
On Thu, Jul 01, 2010 at 06:03:02PM -0700, Cary Coutant wrote:
[snip]
> + /* Reserve all the space we can. If none is available, force
> + the obstack to grow by at least as many bytes as we have
> + remaining in the input stream. */
> + room = obstack_room (ob);
> + if (room <= 0)
> + room = strm->avail_in;
> + obstack_blank (ob, room);
obstack_blank_fast. You don't really need to zero the mem do you?
> + strm->next_out = (Bytef *) obstack_next_free (ob) - room;
> + strm->avail_out = room;
> + x = deflate (strm, Z_NO_FLUSH);
> + if (x != Z_OK)
> + return -1;
> +
> + /* Return unused space. */
> + if (strm->avail_out > 0)
> + obstack_blank (ob, -((int) strm->avail_out));
obstack_blank_fast again, similarly in compress_finish.
[snip]
> + /* Create a new frag to contain the "ZLIB" header. */
> + obstack_blank (ob, SIZEOF_STRUCT_FRAG + 12);
You should use frag_alloc here and later where you create frags
> + first_newf = (fragS *) obstack_finish (ob);
> + memset (first_newf, 0, SIZEOF_STRUCT_FRAG);
> + first_newf->fr_type = rs_fill;
otherwise these struct references might segfault on some architectures
due to misalignment. With these issues fixed the patch is OK to
commit.
--
Alan Modra
Australia Development Lab, IBM