Relocating .data at 0x0

David Robins dbrobins@student.math.uwaterloo.ca
Wed May 30 12:51:00 GMT 2001


I'm trying to write an ld script to have it relocate the .data segment at
0x0 (i.e., generate symbol addresses starting at 0x0 for all sections
included there).  My script looks like:

OUTPUT_FORMAT("a.out-i386-linux")
OUTPUT_ARCH("i386")
SECTIONS
{ 
  .text 0x20 :  
  { 
    CREATE_OBJECT_SYMBOLS
    *(.text)
    _etext = .;
    __etext = .;
  }
  .data 0x0 : AT(ADDR(.text)+SIZEOF(.text))
  { 
    *(.data)
    *(.rodata)   /* a.out has no separate rodata section */
    CONSTRUCTORS
  }
/* plus .bss and a /DISCARD/ pseudo-section */
}

This dies with:
/usr/local/bin/ld: final link failed: File truncated

It will die with 'Bad value' for 'File truncated' if I change the data
address to, say, 0x400.  The .text segment size is about 0xa000.

The purpose is to be able to set DS/ES/SS/FS/GS to the start of the data
segment directly, not the code segment, so that the first item in the
data segment will be DS:0, not DS:0xa000.

ld version 2.11.90.08, same BFD version, gcc is egcs-2.91.66.

Any help appreciated.

Dave
Isa. 40:31



More information about the Binutils mailing list