+ /* Paranoia - check that we will not overflow "buffer". */
+ if (((end - data) * 2) /* Number of hex characters we want to emit. */
+ + ((end - data) / VerilogDataWidth) /* Number of spaces we want to emit. */
+ + 2 /* The carriage return & line feed characters. */
+ > (long) sizeof (buffer))
+ {
+ /* FIXME: Should we generate an error message ? */
+ return FALSE;
+ }
+
+ /* Write the data.
+ FIXME: Under some circumstances we can emit a space at the end of
+ the line. This is not really necessary, but catching these cases
+ would make the code more complicated. */
+ if (VerilogDataWidth == 1)
+ {
+ for (src = data; src < end;)
+ {
+ TOHEX (dst, *src);
+ dst += 2;
+ src ++;
+ if (src < end)
+ *dst++ = ' ';
+ }
+ }
+ else if (bfd_little_endian (abfd))
+ {
+ /* If the input byte stream contains:
+ 05 04 03 02 01 00
+ and VerilogDataWidth is 4 then we want to emit:
+ 02030405 0001 */
+ int i;
+
+ for (src = data; src < (end - VerilogDataWidth); src += VerilogDataWidth)
+ {
+ for (i = VerilogDataWidth - 1; i >= 0; i--)
+ {
+ TOHEX (dst, src[i]);
+ dst += 2;
+ }
+ *dst++ = ' ';
+ }
+
+ /* Emit any remaining bytes. Be careful not to read beyond "end". */
+ while (end > src)
+ {
+ -- end;
+ TOHEX (dst, *end);
+ dst += 2;
+ }
+ }
+ else