The .sbss section on ELF/x86

H . J . Lu hjl@lucon.org
Wed Nov 14 04:02:00 GMT 2001


On Mon, Nov 26, 2001 at 04:57:17PM -0800, Geoff Keating wrote:
> > Date: Mon, 26 Nov 2001 16:54:31 -0800
> > From: "H . J . Lu" <hjl@lucon.org>
> 
> > ELF/x86 doesn't use/have the .sbss section. I don't want it in every
> > ELF/x86 binary. To the least, ld should output the .bss section only
> > for targets which actually use it.
> 
> I guess you could have a NO_SBSS shell variable, and conditionalise
> the definition on that...
> 

Like this?

H.J.
----
2001-11-26  H.J. Lu <hjl@gnu.org>

	* emulparams/elf_i386.sh (NO_SMALL_DATA): Set to yes.

	* scripttempl/elf.sc (SBSS): New. Define if ${NO_SMALL_DATA} 
	is not empty.
	(RELOCATION_SMALL_DATA): Likewise.
	(SBSS2): Define if ${NO_SMALL_DATA} is not empty.
	(SDATA2): Likewise.

Index: ld/emulparams/elf_i386.sh
===================================================================
RCS file: /work/cvs/gnu/binutils/ld/emulparams/elf_i386.sh,v
retrieving revision 1.1.1.2
diff -d -u -p -r1.1.1.2 elf_i386.sh
--- ld/emulparams/elf_i386.sh	2001/08/17 16:06:08	1.1.1.2
+++ ld/emulparams/elf_i386.sh	2001/11/27 06:14:19
@@ -8,3 +8,4 @@ MACHINE=
 NOP=0x90909090
 TEMPLATE_NAME=elf32
 GENERATE_SHLIB_SCRIPT=yes
+NOSBSS=yes
Index: ld/scripttempl/elf.sc
===================================================================
RCS file: /work/cvs/gnu/binutils/ld/scripttempl/elf.sc,v
retrieving revision 1.1.1.19
diff -d -u -p -r1.1.1.19 elf.sc
--- ld/scripttempl/elf.sc	2001/11/23 19:31:51	1.1.1.19
+++ ld/scripttempl/elf.sc	2001/11/27 06:14:20
@@ -1,6 +1,7 @@
 #
 # Unusual variables checked by this code:
 #	NOP - four byte opcode for no-op (defaults to 0)
+#	NOSBSS - no .sbss section if not empty.
 #	DATA_ADDR - if end-of-text-plus-one-page isn't right for data start
 #	INITIAL_READONLY_SECTIONS - at start of text segment
 #	OTHER_READONLY_SECTIONS - other than .text .init .rodata ...
@@ -72,8 +73,28 @@ INTERP=".interp       ${RELOCATING-0} : 
 PLT=".plt          ${RELOCATING-0} : { *(.plt) }"
 DYNAMIC=".dynamic      ${RELOCATING-0} : { *(.dynamic) }"
 RODATA=".rodata       ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }"
-SBSS2=".sbss2        ${RELOCATING-0} : { *(.sbss2${RELOCATING+ .sbss2.* .gnu.linkonce.sb2.*}) }"
-SDATA2=".sdata2       ${RELOCATING-0} : { *(.sdata2${RELOCATING+ .sdata2.* .gnu.linkonce.s2.*}) }"
+if test -z "${NOSBSS}"; then
+  SBSS=".sbss         ${RELOCATING-0} :
+  {
+    ${RELOCATING+PROVIDE (__sbss_start = .);}
+    ${RELOCATING+PROVIDE (___sbss_start = .);}
+    *(.dynsbss)
+    *(.sbss${RELOCATING+ .sbss.* .gnu.linkonce.sb.*})
+    *(.scommon)
+    ${RELOCATING+PROVIDE (__sbss_end = .);}
+    ${RELOCATING+PROVIDE (___sbss_end = .);}
+  }"
+  SBSS2=".sbss2        ${RELOCATING-0} : { *(.sbss2${RELOCATING+ .sbss2.* .gnu.linkonce.sb2.*}) }"
+  SDATA2=".sdata2       ${RELOCATING-0} : { *(.sdata2${RELOCATING+ .sdata2.* .gnu.linkonce.s2.*}) }"
+  RELOCATION_SMALL_DATA=".rel.sdata    ${RELOCATING-0} : { *(.rel.sdata${RELOCATING+ .rel.sdata.* .rel.gnu.linkonce.s.*}) }
+  .rela.sdata   ${RELOCATING-0} : { *(.rela.sdata${RELOCATING+ .rela.sdata.* .rela.gnu.linkonce.s.*}) }
+  .rel.sbss     ${RELOCATING-0} : { *(.rel.sbss${RELOCATING+ .rel.sbss.* .rel.gnu.linkonce.sb.*}) }
+  .rela.sbss    ${RELOCATING-0} : { *(.rela.sbss${RELOCATING+ .rela.sbss.* .rela.gnu.linkonce.sb.*}) }
+  .rel.sdata2   ${RELOCATING-0} : { *(.rel.sdata2${RELOCATING+ .rel.sdata2.* .rel.gnu.linkonce.s2.*}) }
+  .rela.sdata2  ${RELOCATING-0} : { *(.rela.sdata2${RELOCATING+ .rela.sdata2.* .rela.gnu.linkonce.s2.*}) }
+  .rel.sbss2    ${RELOCATING-0} : { *(.rel.sbss2${RELOCATING+ .rel.sbss2.* .rel.gnu.linkonce.sb2.*}) }
+  .rela.sbss2   ${RELOCATING-0} : { *(.rela.sbss2${RELOCATING+ .rela.sbss2.* .rela.gnu.linkonce.sb2.*}) }"
+fi
 CTOR=".ctors        ${CONSTRUCTING-0} : 
   {
     ${CONSTRUCTING+${CTOR_START}}
@@ -177,14 +198,7 @@ eval $COMBRELOCCAT <<EOF
   .rel.got      ${RELOCATING-0} : { *(.rel.got) }
   .rela.got     ${RELOCATING-0} : { *(.rela.got) }
   ${OTHER_GOT_RELOC_SECTIONS}
-  .rel.sdata    ${RELOCATING-0} : { *(.rel.sdata${RELOCATING+ .rel.sdata.* .rel.gnu.linkonce.s.*}) }
-  .rela.sdata   ${RELOCATING-0} : { *(.rela.sdata${RELOCATING+ .rela.sdata.* .rela.gnu.linkonce.s.*}) }
-  .rel.sbss     ${RELOCATING-0} : { *(.rel.sbss${RELOCATING+ .rel.sbss.* .rel.gnu.linkonce.sb.*}) }
-  .rela.sbss    ${RELOCATING-0} : { *(.rela.sbss${RELOCATING+ .rela.sbss.* .rela.gnu.linkonce.sb.*}) }
-  .rel.sdata2   ${RELOCATING-0} : { *(.rel.sdata2${RELOCATING+ .rel.sdata2.* .rel.gnu.linkonce.s2.*}) }
-  .rela.sdata2  ${RELOCATING-0} : { *(.rela.sdata2${RELOCATING+ .rela.sdata2.* .rela.gnu.linkonce.s2.*}) }
-  .rel.sbss2    ${RELOCATING-0} : { *(.rel.sbss2${RELOCATING+ .rel.sbss2.* .rel.gnu.linkonce.sb2.*}) }
-  .rela.sbss2   ${RELOCATING-0} : { *(.rela.sbss2${RELOCATING+ .rela.sbss2.* .rela.gnu.linkonce.sb2.*}) }
+  ${RELOCATION_SMALL_DATA}
   .rel.bss      ${RELOCATING-0} : { *(.rel.bss${RELOCATING+ .rel.bss.* .rel.gnu.linkonce.b.*}) }
   .rela.bss     ${RELOCATING-0} : { *(.rela.bss${RELOCATING+ .rela.bss.* .rela.gnu.linkonce.b.*}) }
 EOF
@@ -279,16 +293,7 @@ cat <<EOF
   ${RELOCATING+PROVIDE (edata = .);}
   ${RELOCATING+__bss_start = .;}
   ${RELOCATING+${OTHER_BSS_SYMBOLS}}
-  .sbss         ${RELOCATING-0} :
-  {
-    ${RELOCATING+PROVIDE (__sbss_start = .);}
-    ${RELOCATING+PROVIDE (___sbss_start = .);}
-    *(.dynsbss)
-    *(.sbss${RELOCATING+ .sbss.* .gnu.linkonce.sb.*})
-    *(.scommon)
-    ${RELOCATING+PROVIDE (__sbss_end = .);}
-    ${RELOCATING+PROVIDE (___sbss_end = .);}
-  }
+  ${SBSS}
   ${BSS_PLT+${PLT}}
   .bss          ${RELOCATING-0} :
   {



More information about the Binutils mailing list