public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Charles Wilson <cwilson@ece.gatech.edu>
To: DJ Delorie <dj@delorie.com>
Cc: nickc@cygnus.com, binutils@sourceware.cygnus.com
Subject: Re: binutils-20000625 ld.exe --shared broken
Date: Fri, 07 Jul 2000 21:06:00 -0000	[thread overview]
Message-ID: <3966A978.2DF7F1BE@ece.gatech.edu> (raw)
In-Reply-To: <200007071900.PAA29511@envy.delorie.com>

DJ Delorie wrote:
> 
> > (bfd/coffcode.h: coff_write_object_contents)
> > -     3250      if (bfd_seek (abfd, scn_base, SEEK_SET) != 0)
> > -     3251        return false;
> 
> While you're in there, could you check one thing for me?  In bfd_seek,
> is it actually using the BFD_IN_MEMORY code, but failing because we're
> trying to seek past the end of the data block?  If so, it's probably
> trying to "seek beyond EOF" to write out one of the structures, which
> you can probably fix pretty quickly, by just growing the data block
> (see the code to do that in bfd_write).  It probably should check for
> the bfd being writable before allowing that, too.

Yup, that's what the problem was -- it was executing the BFD_IN_MEMORY
code, and the bim had no allocated memory at all. The following seems to
work for me, but I'm unsure of some of the finer details. 

1) Are the bfd_set_error's correct?

2) Is this *really* the right thing to do? 

Fri Jul 7 2000 23:52:00 Charles Wilson <cwilson@ece.gatech.edu>
 
       * bfd/libbfd.c: fix 'seek beyond EOF' error when
	 writing out a structure that is BFD_IN_MEMORY.

-----------------
--- binutils-20000625-orig/bfd/libbfd.c Sat Jun 24 21:52:33 2000
+++ binutils-20000625/bfd/libbfd.c      Sat Jul  8 00:01:47 2000
@@ -691,11 +691,31 @@
       
       if ((bfd_size_type) abfd->where > bim->size)
        {
-         abfd->where = bim->size;
-         bfd_set_error (bfd_error_file_truncated);
-         return -1;
-       }
-      
+         if ((abfd->direction == write_direction) || 
+             (abfd->direction == both_direction))
+           {
+             long newsize, oldsize = (bim->size + 127) & ~127;
+             bim->size = abfd->where;
+             /* Round up to cut down on memory fragmentation */
+             newsize = (bim->size + 127) & ~127;
+             if (newsize > oldsize)
+               {
+                 bim->buffer = bfd_realloc (bim->buffer, newsize);
+                 if (bim->buffer == 0)
+                   {
+                     bim->size = 0;
+                     bfd_set_error (bfd_error_no_memory);
+                     return -1;
+                   }
+               }
+           }
+         else
+           {
+             abfd->where = bim->size;
+             bfd_set_error (bfd_error_file_truncated);
+             return -1;
+           }   
+       }      
       return 0;
     }
 
-------------

begin 664 binutils.patch.gz
M'XL("`:H9CD``V)I;G5T:6QS+G!A=&-H`(U3RV[;,!`\2U\QI\*,S%J2\VAM
MR/"YQ_8#!#THAP!-!C0%(TW<;R\I2K(<.VAY69([LSN[7%)*47+9&BX.-(WM
M>DP?J-)\MRB;>B%X:<W7*OA5&/QH)=)[I,GJ(5TMEW#P,(JBZP"WN`+XACA>
MQ<GJ_LESMUO0Q^_)/$D0.;M,L-V&\&NPO,%L9@/E!_Z;Y>;UA1$4]DPWQV>F
M&38V_9YNG)>$"-Y"&N`"D)T!Z\[9!6,F9UHKC2YVM\T;+FP&W<JJ,*PF'JV9
M:;4$3=SQ%-)>713TTGRJFFM6&:XDL@Q'S0W+QRN"]W=/<.L6H53F>8(G/?AM
M)`DE=Y#LZ(J80XG:;6QEL[$T1$C2)X(O^&/M>F2>`=FT*V?`X@X_52MKM"\P
M"E5K4*NCA%6V9WNE7]'H8K=GTA2=W+O%2.T%_9<.UZL!OQDJ(*/;%QOT>LNV
M:9AV+V??1K-""%7U.;QK/N0F:T]SX2^H&6+B76/HC^V(UY/[SV9"JMRW@4S0
MDYGH[TZ32H:]MTP<V-5[?CJ?T;_T7,UH=$M3E]Z/Z>GR._4P6WNO%>%?MYQ@
%X00$``"3
`
end

  reply	other threads:[~2000-07-07 21:06 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-07-07 10:16 Nick Clifton
2000-07-07 10:31 ` DJ Delorie
2000-07-07 11:24   ` Charles Wilson
2000-07-07 12:00     ` DJ Delorie
2000-07-07 21:06       ` Charles Wilson [this message]
2000-07-12 11:30         ` DJ Delorie
     [not found] <396547F2.333FBD51@ece.gatech.edu>
     [not found] ` <200007070300.XAA08402@envy.delorie.com>
     [not found]   ` <396574C7.924FADB6@ece.gatech.edu>
2000-07-07  6:39     ` DJ Delorie
2000-07-07  8:55       ` Charles Wilson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3966A978.2DF7F1BE@ece.gatech.edu \
    --to=cwilson@ece.gatech.edu \
    --cc=binutils@sourceware.cygnus.com \
    --cc=dj@delorie.com \
    --cc=nickc@cygnus.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).