sh*-elf: Don't make .stack section in shared libs

kaz Kojima kkojima@rr.iij4u.or.jp
Sun Jul 27 02:00:00 GMT 2003


Hi,

On sh*-elf target, now ld testcases which try to make shared libs
fail with "not enough room for program headers" error. The patch
below fixes them by avoiding to make the .stack section in shared
libs. I'll check it in to the mainline if there is no objection.

Regards,
	kaz
--
2003-07-26  Kaz Kojima  <kkojima@rr.iij4u.or.jp>

	* emulparams/shelf.sh (OTHER_SECTIONS): Don't include .stack
	section for shared library.
	* emulparams/shelf32.sh (OTHER_SECTIONS): Likewise.
	* emulparams/shelf64.sh (OTHER_SECTIONS): Likewise.

diff -u3prN ORIG/src/ld/emulparams/shelf.sh LOCAL/src/ld/emulparams/shelf.sh
--- ORIG/src/ld/emulparams/shelf.sh	Thu Jun 27 00:42:33 2002
+++ LOCAL/src/ld/emulparams/shelf.sh	Sun Jul 27 10:11:16 2003
@@ -23,10 +23,11 @@ DTOR_END='___dtors_end = .;'
 # N.B. We can't use PROVIDE to set the default value in a symbol because
 # the address is needed to place the .stack section, which in turn is needed
 # to hold the sentinel value(s).
-OTHER_SECTIONS="  .stack        ${RELOCATING-0}${RELOCATING+(DEFINED(_stack) ? _stack : 0x30000)} :
+test -z "$CREATE_SHLIB" && OTHER_SECTIONS="  .stack        ${RELOCATING-0}${RELOCATING+(DEFINED(_stack) ? _stack : 0x30000)} :
   {
     ${RELOCATING+_stack = .;}
     *(.stack)
     LONG(0xdeaddead)
   }"
-
+# We do not need .stack for shared library.
+test -n "$CREATE_SHLIB" && OTHER_SECTIONS=""
diff -u3prN ORIG/src/ld/emulparams/shelf32.sh LOCAL/src/ld/emulparams/shelf32.sh
--- ORIG/src/ld/emulparams/shelf32.sh	Sat Jul 19 13:08:11 2003
+++ LOCAL/src/ld/emulparams/shelf32.sh	Sun Jul 27 09:45:19 2003
@@ -39,14 +39,18 @@ DTOR_END='___dtors_end = .;'
 # N.B. We can't use PROVIDE to set the default value in a symbol because
 # the address is needed to place the .stack section, which in turn is needed
 # to hold the sentinel value(s).
-OTHER_SECTIONS="
- .stack ${RELOCATING-0}${RELOCATING+(DEFINED(_stack) ? _stack : ALIGN (0x40000) + 0x40000)} :
+test -z "$CREATE_SHLIB" && OTHER_SECTIONS="
+  .stack ${RELOCATING-0}${RELOCATING+(DEFINED(_stack) ? _stack : ALIGN (0x40000) + 0x40000)} :
   {
     ${RELOCATING+_stack = .;}
     *(.stack)
     LONG(0xdeaddead)
   }
- .cranges 0 : { *(.cranges) }
+  .cranges 0 : { *(.cranges) }
+"
+# We do not need .stack for shared library.
+test -n "$CREATE_SHLIB" && OTHER_SECTIONS="
+  .cranges 0 : { *(.cranges) }
 "
 
 # We need to adjust sizes in the .cranges section after relaxation, so
diff -u3prN ORIG/src/ld/emulparams/shelf64.sh LOCAL/src/ld/emulparams/shelf64.sh
--- ORIG/src/ld/emulparams/shelf64.sh	Sat Jul 19 13:08:11 2003
+++ LOCAL/src/ld/emulparams/shelf64.sh	Sun Jul 27 10:05:17 2003
@@ -6,7 +6,7 @@ EXTRA_EM_FILE=
 . ${srcdir}/emulparams/shelf32.sh
 
 # We do not need .cranges
-OTHER_SECTIONS="
+test -z "$CREATE_SHLIB" && OTHER_SECTIONS="
  .stack ${RELOCATING-0}${RELOCATING+(DEFINED(_stack) ? _stack : ALIGN (0x40000) + 0x40000)} :
   {
     ${RELOCATING+_stack = .;}
@@ -14,3 +14,5 @@ OTHER_SECTIONS="
     LONG(0xdeaddead)
   }
 "
+# We do not need .stack for shared library.
+test -n "$CREATE_SHLIB" && OTHER_SECTIONS=""



More information about the Binutils mailing list