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: ld68k coff again


Hi Bruno,

The size of the sources files and their object files are :
dtb00.S :	10 bytes
list.S:         4 bytes
descr001.S	8 bytes

But the size of the linked file is 24 bytes

It seems that a word is added by the linker at the end of the linked
file and I don't know how to remove it.

You have run into a limitation of the COFF file format. With COFF all(*) sections have a 4 byte alignment, so the output section is padded to a 4 byte boundary.


There are two possible solutions to your problem:

1. Switch to a better file format. (Go on, do it. You know that ELF makes sense... :-)

2. Hack the assembler and linker so that the default section alignment is two bytes instead of four. The attached patch will do this. You will have to build and install the assembler and linker of course.

Cheers
  Nick

(*) There are a few exceptions, but they have fixed names. You cannot just choose the alignment for an arbitrary section.
Index: bfd/coff-m68k.c
===================================================================
RCS file: /cvs/src/src/bfd/coff-m68k.c,v
retrieving revision 1.14
diff -c -3 -p -r1.14 coff-m68k.c
*** bfd/coff-m68k.c	20 Feb 2005 14:59:06 -0000	1.14
--- bfd/coff-m68k.c	4 Oct 2007 16:46:18 -0000
*************** Foundation, Inc., 59 Temple Place - Suit
*** 48,54 ****
       symbol.  If this is not defined, then, for a relocation against a
       common symbol, the object file holds zero.  */
  
! #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
  
  #ifndef COFF_PAGE_SIZE
  /* The page size is a guess based on ELF.  */
--- 48,54 ----
       symbol.  If this is not defined, then, for a relocation against a
       common symbol, the object file holds zero.  */
  
! #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (1)
  
  #ifndef COFF_PAGE_SIZE
  /* The page size is a guess based on ELF.  */

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