This is the mail archive of the
binutils@sourceware.cygnus.com
mailing list for the binutils project.
.init/.text/.fini vs. .text/.init/.fini
- To: binutils at sourceware dot cygnus dot com
- Subject: .init/.text/.fini vs. .text/.init/.fini
- From: Geoff Keating <geoffk at cygnus dot com>
- Date: Thu, 13 Apr 2000 16:45:33 -0700
If the .init section is before .text, then when users write
(say) -Ttext=0x70000000, they discover to their surprise that
(a) relocs from .init to .text may now overflow; and
(b) their program now needs more PHDRs than before,
which results in a very unhelpful error message
from ld and an unsuccessful link.
because the option just changes the start of the .text section,
and the .init section stays where it was at the default address.
This patch fixes this. OK to install?
--
- Geoffrey Keating <geoffk@cygnus.com>
===File ~/patches/cygnus/rs6000-crtS-elfsc2.patch===========
2000-04-13 Geoff Keating <geoffk@cygnus.com>
* scripttempl/elf.sc: Move .init after .text.
Index: elf.sc
===================================================================
RCS file: /cvs/src/src/ld/scripttempl/elf.sc,v
retrieving revision 1.11
diff -p -u -u -p -r1.11 elf.sc
--- elf.sc 2000/04/13 23:38:46 1.11
+++ elf.sc 2000/04/13 23:39:27
@@ -124,8 +124,6 @@ SECTIONS
.gnu.version_d ${RELOCATING-0} : { *(.gnu.version_d) }
.gnu.version_r ${RELOCATING-0} : { *(.gnu.version_r) }
- .rel.init ${RELOCATING-0} : { *(.rel.init) }
- .rela.init ${RELOCATING-0} : { *(.rela.init) }
.rel.text ${RELOCATING-0} :
{
*(.rel.text)
@@ -138,6 +136,8 @@ SECTIONS
${RELOCATING+*(.rela.text.*)}
${RELOCATING+*(.rela.gnu.linkonce.t*)}
}
+ .rel.init ${RELOCATING-0} : { *(.rel.init) }
+ .rela.init ${RELOCATING-0} : { *(.rela.init) }
.rel.fini ${RELOCATING-0} : { *(.rel.fini) }
.rela.fini ${RELOCATING-0} : { *(.rela.fini) }
.rel.rodata ${RELOCATING-0} :
@@ -196,14 +196,9 @@ SECTIONS
.rela.plt ${RELOCATING-0} : { *(.rela.plt) }
${OTHER_PLT_RELOC_SECTIONS}
- .init ${RELOCATING-0} :
- {
- ${INIT_START}
- KEEP (*(.init))
- ${INIT_END}
- } =${NOP-0}
-
${DATA_PLT-${BSS_PLT-${PLT}}}
+ /* .text should be before .init and so on, so that -Ttext=0x1234
+ will work. */
.text ${RELOCATING-0} :
{
${RELOCATING+${TEXT_START_SYMBOLS}}
@@ -214,6 +209,12 @@ SECTIONS
*(.gnu.warning)
${RELOCATING+*(.gnu.linkonce.t*)}
${RELOCATING+${OTHER_TEXT_SECTIONS}}
+ } =${NOP-0}
+ .init ${RELOCATING-0} :
+ {
+ ${INIT_START}
+ KEEP (*(.init))
+ ${INIT_END}
} =${NOP-0}
.fini ${RELOCATING-0} :
{
============================================================