aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2005-01-23 05:36:37 +0000
committerAlan Modra <amodra@gmail.com>2005-01-23 05:36:37 +0000
commitb5666f2f09f4ae51777c3705202b25f325df0702 (patch)
tree8cfd00a6e8abd28054864c46ebb6a83dfc2c9197
parent059198c19dcb28433fe4d1da6f00ae8f15faa52f (diff)
downloadgdb-b5666f2f09f4ae51777c3705202b25f325df0702.zip
gdb-b5666f2f09f4ae51777c3705202b25f325df0702.tar.gz
gdb-b5666f2f09f4ae51777c3705202b25f325df0702.tar.bz2
* ld.texinfo (Location Counter <dot outside sections>): Document
effects of orphan section placement, and ". = ." workaround. * Makefile.in: Regenerate.
-rw-r--r--ld/ChangeLog6
-rw-r--r--ld/Makefile.in4
-rw-r--r--ld/ld.texinfo70
3 files changed, 77 insertions, 3 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index d261fe2..52c5c3d 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,9 @@
+2005-01-23 Alan Modra <amodra@bigpond.net.au>
+
+ * ld.texinfo (Location Counter <dot outside sections>): Document
+ effects of orphan section placement, and ". = ." workaround.
+ * Makefile.in: Regenerate.
+
2005-01-22 Richard Sandiford <rsandifo@redhat.com>
* emulparams/elf32bmip.sh (OTHER_GOT_SECTIONS): Add ". = .;".
diff --git a/ld/Makefile.in b/ld/Makefile.in
index eb2f110..25f21e0 100644
--- a/ld/Makefile.in
+++ b/ld/Makefile.in
@@ -629,7 +629,7 @@ deffilep.c ldgram.c ldlex.c
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
-TAR = gtar
+TAR = tar
GZIP_ENV = --best
SOURCES = $(ld_new_SOURCES) $(EXTRA_ld_new_SOURCES)
OBJECTS = $(ld_new_OBJECTS)
@@ -1111,7 +1111,7 @@ distclean-generic:
-test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
maintainer-clean-generic:
- -test -z "ldlexcdeffilephdeffilepcldgramhldgramc$(MAINTAINERCLEANFILES)" || rm -f ldlexc deffileph deffilepc ldgramh ldgramc $(MAINTAINERCLEANFILES)
+ -test -z "ldlex.cdeffilep.hdeffilep.cldgram.hldgram.c$(MAINTAINERCLEANFILES)" || rm -f ldlex.c deffilep.h deffilep.c ldgram.h ldgram.c $(MAINTAINERCLEANFILES)
mostlyclean-am: mostlyclean-hdr mostlyclean-noinstPROGRAMS \
mostlyclean-compile mostlyclean-libtool \
mostlyclean-aminfo mostlyclean-tags mostlyclean-generic \
diff --git a/ld/ld.texinfo b/ld/ld.texinfo
index 11628a6..9897530 100644
--- a/ld/ld.texinfo
+++ b/ld/ld.texinfo
@@ -2769,7 +2769,7 @@ The first case will define @var{symbol} to the value of
defined, and the value will be adjusted accordingly.
The special symbol name @samp{.} indicates the location counter. You
-may only use this within a @code{SECTIONS} command.
+may only use this within a @code{SECTIONS} command. @xref{Location Counter}.
The semicolon after @var{expression} is required.
@@ -4381,6 +4381,74 @@ and it will have an extra 0x600 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.
+@cindex dot outside sections
+Setting symbols to the value of the location counter outside of an
+output section statement can result in unexpected values if the linker
+needs to place orphan sections. For example, given the following:
+
+@smallexample
+SECTIONS
+@{
+ start_of_text = . ;
+ .text: @{ *(.text) @}
+ end_of_text = . ;
+
+ start_of_data = . ;
+ .data: @{ *(.data) @}
+ end_of_data = . ;
+@}
+@end smallexample
+
+If the linker needs to place some input section, e.g. @code{.rodata},
+not mentioned in the script, it might choose to place that section
+between @code{.text} and @code{.data}. You might think the linker
+should place @code{.rodata} on the blank line in the above script, but
+blank lines are of no particular significance to the linker. As well,
+the linker doesn't associate the above symbol names with their
+sections. Instead, it assumes that all assignments or other
+statements belong to the previous output section, except for the
+special case of an assignment to @code{.}. I.e., the linker will
+place the orphan @code{.rodata} section as if the script was written
+as follows:
+
+@smallexample
+SECTIONS
+@{
+ start_of_text = . ;
+ .text: @{ *(.text) @}
+ end_of_text = . ;
+
+ start_of_data = . ;
+ .rodata: @{ *(.rodata) @}
+ .data: @{ *(.data) @}
+ end_of_data = . ;
+@}
+@end smallexample
+
+This may or may not be the script author's intention for the value of
+@code{start_of_data}. One way to influence the orphan section
+placement is to assign the location counter to itself, as the linker
+assumes that an assignment to @code{.} is setting the start address of
+a following output section and thus should be grouped with that
+section. So you could write:
+
+@smallexample
+SECTIONS
+@{
+ start_of_text = . ;
+ .text: @{ *(.text) @}
+ end_of_text = . ;
+
+ . = . ;
+ start_of_data = . ;
+ .data: @{ *(.data) @}
+ end_of_data = . ;
+@}
+@end smallexample
+
+Now, the orphan @code{.rodata} section will be placed between
+@code{end_of_text} and @code{start_of_data}.
+
@need 2000
@node Operators
@subsection Operators