Bug 000128

When Created: 12/19/1996 21:10:00
Against DJGPP version: 2.00
By whom:
Abstract: Wrong struct sizes in COFF.H
While trying to compile the DLL.CC program, I noticed that some of the structure sizes in COFF.H are wrong.  For example, sizeof(struct external_scnhdr) returns 20 when the actual size of the header in an object file is 18.  I added up the sizes of all the elements and that came out to 18, so I have no idea where the extra two bytes are coming from...  The external_reloc structure exhibits the strange behavior (2 extra "phantom" bytes) also, but the rest of them seem to work fine.

Note added: 12/19/1996 21:11:51
By whom:
Oops, sorry about that.  It looks like the carriage returns aren't automatically added.

Workaround added: 12/19/1996 21:14:21
By whom:
It's kind of kludgy, but if you replace

fread(syment, filhdr.f_nsyms, SYMESZ, file);


for (t = 0; t < filhdr.f_nsyms; t++)
  fread(&syment[t], 1, 18, file);

It works fine.  You can't just enter the size manually e.g.
fread(syment, 1, 18, file);
because it appears that it is taking up 20 bytes in memory, also.

Note added: 04/19/1997 01:12:46
By whom:
Are you sure you aren't being confused by the way in which DJGPP aligns structure
members?  Check chapter 22.9 of the FAQ.

Note added: 07/27/1997 22:21:06
By whom:
You're right, it's the alignment.  Using -fpack-struct fixes the problem...

I guess just be sure and specify that when reading in multiple structs from

Closed on 04/12/1999 12:00:17: Programmer's error.
By whom:

  webmaster     delorie software   privacy  
  Copyright 2010   by DJ Delorie     Updated Jul 2010