public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Nick Clifton <nickc@cygnus.com>
To: binutils@sourceware.cygnus.com
Subject: Linker documentation patch
Date: Thu, 01 Jul 1999 00:00:00 -0000	[thread overview]
Message-ID: <199906221648.RAA28788@pathia.cygnus.co.uk> (raw)

Hi Guys,

  Any comments on the enclosed patch to ld.texinfo ?  It attempts to
  explain the difference between using dot in a linker script when it
  is between section statements or inside section statements.  The
  behaviour inside section statements is slightly non-intuitive, so I
  thought it worthwhile adding a few paragraphs describing it.

Cheers
	Nick

1999-06-22  Nick Clifton  <nickc@cygnus.com>

	* ld.texinfo (Location Counter): Describe behaviour of
	location counter inside section statements.

Index: ld.texinfo
===================================================================
RCS file: /cvs/cvsfiles/devo/ld/ld.texinfo,v
retrieving revision 1.164
diff -p -r1.164 ld.texinfo
*** ld.texinfo	1999/06/20 17:46:32	1.164
--- ld.texinfo	1999/06/22 16:44:57
*************** followed by a 1000 byte gap.  Then the @
*** 3410,3415 ****
--- 3410,3448 ----
  @samp{.text} section from @file{file3}.  The notation @samp{= 0x1234}
  specifies what data to write in the gaps (@pxref{Output Section Fill}).
  
+ @cindex dot inside sections
+ Note: @code{.} actually refers to the byte offset from the start of the
+ current containing object.  Normally this is the @code{SECTIONS}
+ statement, whoes start address is 0, hence @code{.} can be used as an
+ absolute address.  If @code{.} is used inside a section description
+ however, it refers to the byte offset from the start of that section,
+ not an absolute address.  Thus in a script like this:
+ 
+ @smallexample
+ SECTIONS
+ @{
+     . = 0x100
+     .text: @{
+       *(.text)
+       . = 0x200
+     @}
+     . = 0x500
+     .data: @{
+       *(.data)
+       . += 0x600
+     @}
+ @}
+ @end smallexample
+ 
+ The @samp{.text} section will be assigned a starting address of 0x100
+ and a size of exactly 0x200 bytes, even if there is not enough data in
+ the @samp{.text} input sections to fill this area.  (If there is too
+ much data, an error will be produced because this would be an attempt to
+ move @code{.} backwards).  The @samp{.data} section will start at 0x500
+ and it will have an extra 0x400 bytes worth of space after the end of
+ the values from the @samp{.data} input sections and before the end of
+ the @samp{.data} output section itself.
+ 
  @need 2000
  @node Operators
  @subsection Operators

             reply	other threads:[~1999-07-01  0:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-07-01  0:00 Nick Clifton [this message]
2000-01-07 11:07 Nick Clifton
2000-01-07 11:26 ` Ian Lance Taylor
2000-04-01  0:00 ` Nick Clifton
2000-01-07 11:31 Nick Clifton
2000-01-07 11:44 Nick Clifton
2000-04-01  0:00 ` Nick Clifton

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=199906221648.RAA28788@pathia.cygnus.co.uk \
    --to=nickc@cygnus.com \
    --cc=binutils@sourceware.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).