ld: Simple Linker Script Example

Barry Rountree rountree@uga.edu
Fri Nov 7 01:52:00 GMT 2003


I'm puzzling my way through the ld documentation and I think I'm in need of 
the "hello, world!" of linker scripts -- the minimal linker script that will 
link two C files together into an executable.

gcc -Wl,--verbose gives the default script, of course, but it's moderately 
large and as I change things I'm getting some opaque (to me) interactions.  

The documentation gives the example 

SECTIONS
{
  . = 0x10000;
  .text : { *(.text) }
  . = 0x8000000;
  .data : { *(.data) }
  .bss : { *(.bss) }
}

with the comment "The simplest possible linker script has just one command: 
SECTIONS. .... That's it! That's a simple and complete linker script."  It 
doesn't work by itself, of course, and while I got rid of the link errors by 
cutting and pasting a few lines from the default script, the resulting binary 
segfaulted.

The two machines I'm working on are:

	Linux 2.4.21-0.13mdk i686
	SunOS 5.9 sun4u sparc SUNW,Sun-Fire-880

Both have gcc 3.2 and binutils 2.14.

Thanks,

Barry Rountree




More information about the Binutils mailing list