This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Add --compress-debug-sections option to gas


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]