public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* PATCH: PR 445: A64 linker complains short data segment overflowed
@ 2004-10-13 21:58 H. J. Lu
  2004-10-13 22:02 ` Jakub Jelinek
  0 siblings, 1 reply; 5+ messages in thread
From: H. J. Lu @ 2004-10-13 21:58 UTC (permalink / raw)
  To: jakub; +Cc: binutils

Hi Jakub,

Your patch

http://sources.redhat.com/ml/binutils/2004-05/msg00143.html

caused

http://sources.redhat.com/bugzilla/show_bug.cgi?id=445

This patch seems to work for me.



H.J.
---
2004-10-13  H.J. Lu  <hongjiu.lu@intel.com>

	PR 445
	* scripttempl/elf.sc: If NO_SMALL_DATA is not set, move 
	.ctors/.dtors after .data.

--- ld/scripttempl/elf.sc.small	2004-10-04 10:29:49.000000000 -0700
+++ ld/scripttempl/elf.sc	2004-10-13 14:41:24.716556281 -0700
@@ -347,8 +347,8 @@ cat <<EOF
   .fini_array   ${RELOCATING-0} : { KEEP (*(.fini_array)) }
   ${RELOCATING+${CREATE_SHLIB-PROVIDE (__fini_array_end = .);}}
 
-  ${RELOCATING+${CTOR}}
-  ${RELOCATING+${DTOR}}
+  ${NO_SMALL_DATA+${RELOCATING+${CTOR}}}
+  ${NO_SMALL_DATA+${RELOCATING+${DTOR}}}
   .jcr          ${RELOCATING-0} : { KEEP (*(.jcr)) }
 
   ${RELOCATING+${DATARELRO}}
@@ -372,6 +372,8 @@ cat <<EOF
   .data1        ${RELOCATING-0} : { *(.data1) }
   ${WRITABLE_RODATA+${RODATA}}
   ${OTHER_READWRITE_SECTIONS}
+  ${NO_SMALL_DATA-${RELOCATING+${CTOR}}}
+  ${NO_SMALL_DATA-${RELOCATING+${DTOR}}}
   ${DATA_PLT+${PLT_BEFORE_GOT+${PLT}}}
   ${RELOCATING+${OTHER_GOT_SYMBOLS}}
   ${NO_SMALL_DATA-${GOT}}

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: PATCH: PR 445: A64 linker complains short data segment overflowed
  2004-10-13 21:58 PATCH: PR 445: A64 linker complains short data segment overflowed H. J. Lu
@ 2004-10-13 22:02 ` Jakub Jelinek
  2004-10-13 22:32   ` H. J. Lu
  0 siblings, 1 reply; 5+ messages in thread
From: Jakub Jelinek @ 2004-10-13 22:02 UTC (permalink / raw)
  To: H. J. Lu; +Cc: binutils

On Wed, Oct 13, 2004 at 02:58:07PM -0700, H. J. Lu wrote:
> Hi Jakub,
> 
> Your patch
> 
> http://sources.redhat.com/ml/binutils/2004-05/msg00143.html
> 
> caused
> 
> http://sources.redhat.com/bugzilla/show_bug.cgi?id=445

Any reason why it does that?  If really needed, can't it be done
for IA-64 only?  The more sections protected with relro the better.

> 2004-10-13  H.J. Lu  <hongjiu.lu@intel.com>
> 
> 	PR 445
> 	* scripttempl/elf.sc: If NO_SMALL_DATA is not set, move 
> 	.ctors/.dtors after .data.

	Jakub

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: PATCH: PR 445: A64 linker complains short data segment overflowed
  2004-10-13 22:02 ` Jakub Jelinek
@ 2004-10-13 22:32   ` H. J. Lu
  2004-10-14  0:59     ` James E Wilson
  0 siblings, 1 reply; 5+ messages in thread
From: H. J. Lu @ 2004-10-13 22:32 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: binutils

On Thu, Oct 14, 2004 at 12:01:37AM +0200, Jakub Jelinek wrote:
> On Wed, Oct 13, 2004 at 02:58:07PM -0700, H. J. Lu wrote:
> > Hi Jakub,
> > 
> > Your patch
> > 
> > http://sources.redhat.com/ml/binutils/2004-05/msg00143.html
> > 
> > caused
> > 
> > http://sources.redhat.com/bugzilla/show_bug.cgi?id=445
> 
> Any reason why it does that?  If really needed, can't it be done
> for IA-64 only?  The more sections protected with relro the better.
> 

It may be an icc bug. It will be fixed. Here is a patch for ia64 only.


H.J.
----
2004-10-13  H.J. Lu  <hongjiu.lu@intel.com>

	PR 445
	* emulparams/elf64_ia64.sh (SMALL_DATA_CTOR): Set.
	(SMALL_DATA_DTOR): Set
	* scripttempl/elf.sc: If SMALL_DATA_CTOR is set, move .ctors
	after .data. If SMALL_DATA_DTOR is set, move .dtors after .data.

--- ld/emulparams/elf64_ia64.sh.small	2004-01-28 14:46:40.000000000 -0800
+++ ld/emulparams/elf64_ia64.sh	2004-10-13 15:26:06.640157876 -0700
@@ -33,3 +33,5 @@ test -n "$CREATE_PIE" && OTHER_GOT_RELOC
 OTHER_READONLY_SECTIONS="${OTHER_READONLY_SECTIONS}
   .IA_64.unwind_info ${RELOCATING-0} : { *(.IA_64.unwind_info${RELOCATING+* .gnu.linkonce.ia64unwi.*}) }
   .IA_64.unwind ${RELOCATING-0} : { *(.IA_64.unwind${RELOCATING+* .gnu.linkonce.ia64unw.*}) }"
+SMALL_DATA_CTOR=" "
+SMALL_DATA_DTOR=" "
--- ld/scripttempl/elf.sc.small	2004-10-04 10:29:49.000000000 -0700
+++ ld/scripttempl/elf.sc	2004-10-13 15:25:00.653677241 -0700
@@ -347,8 +347,8 @@ cat <<EOF
   .fini_array   ${RELOCATING-0} : { KEEP (*(.fini_array)) }
   ${RELOCATING+${CREATE_SHLIB-PROVIDE (__fini_array_end = .);}}
 
-  ${RELOCATING+${CTOR}}
-  ${RELOCATING+${DTOR}}
+  ${SMALL_DATA_CTOR-${RELOCATING+${CTOR}}}
+  ${SMALL_DATA_DTOR-${RELOCATING+${DTOR}}}
   .jcr          ${RELOCATING-0} : { KEEP (*(.jcr)) }
 
   ${RELOCATING+${DATARELRO}}
@@ -372,6 +372,8 @@ cat <<EOF
   .data1        ${RELOCATING-0} : { *(.data1) }
   ${WRITABLE_RODATA+${RODATA}}
   ${OTHER_READWRITE_SECTIONS}
+  ${SMALL_DATA_CTOR+${RELOCATING+${CTOR}}}
+  ${SMALL_DATA_DTOR+${RELOCATING+${DTOR}}}
   ${DATA_PLT+${PLT_BEFORE_GOT+${PLT}}}
   ${RELOCATING+${OTHER_GOT_SYMBOLS}}
   ${NO_SMALL_DATA-${GOT}}

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: PATCH: PR 445: A64 linker complains short data segment overflowed
  2004-10-13 22:32   ` H. J. Lu
@ 2004-10-14  0:59     ` James E Wilson
  2004-10-14 17:05       ` H. J. Lu
  0 siblings, 1 reply; 5+ messages in thread
From: James E Wilson @ 2004-10-14  0:59 UTC (permalink / raw)
  To: H. J. Lu; +Cc: Jakub Jelinek, binutils

On Wed, 2004-10-13 at 15:32, H. J. Lu wrote:
> 	PR 445
> 	* emulparams/elf64_ia64.sh (SMALL_DATA_CTOR): Set.
> 	(SMALL_DATA_DTOR): Set
> 	* scripttempl/elf.sc: If SMALL_DATA_CTOR is set, move .ctors
> 	after .data. If SMALL_DATA_DTOR is set, move .dtors after .data.

The bug report doesn't clearly say what is wrong.  I had to look at
binutils sources and gcc output to figure out what you were trying to
say.  The problem here is that icc sets the SHF_IA_64_SHORT bit on the
ctor/dtor sections, which it shouldn't, and this causes trouble for the
gp calculation because ctor/dtor are now before the data section, and gp
can't span the entire data section.

The readelf output is ambiguous here, as "p" simply means that some
processor specific section header flag is set, and there is more than
one of them.  The objdump output would have been more useful, as objdump
will print SHORT_DATA when the SHF_IA_64_SHORT bit is set.

So icc needs to be fixed, but even if it is fixed, we probably need to
accept libraries/object files compiled with old icc indefinitely, so the
patch seems reasonable.

I think the patch does have one flaw though.  There is no comment
explaining why we are doing this.  There should be a comment in the
elf64_ia64.sh file saying this is necessary because some icc versions
set the short data flag on ctor/dtor sections.  Even better if we can
list the version number when it was fixed.  Otherwise, people looking at
this in the future won't be able to understand why this weirdness is
there.

The patch is OK with a comment added.

By the way, the FreeBSD elf64_ia64_fbsd.sh file includes elf64_ia64.sh. 
If the Intel compiler does not and will not support FreeBSD, then
perhaps we should clear SMALL_DATA_{CTOR,DTOR} in this file.  It isn't
clear to me if this makes enough difference to matter though.
-- 
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: PATCH: PR 445: A64 linker complains short data segment overflowed
  2004-10-14  0:59     ` James E Wilson
@ 2004-10-14 17:05       ` H. J. Lu
  0 siblings, 0 replies; 5+ messages in thread
From: H. J. Lu @ 2004-10-14 17:05 UTC (permalink / raw)
  To: James E Wilson; +Cc: Jakub Jelinek, binutils

On Wed, Oct 13, 2004 at 05:59:16PM -0700, James E Wilson wrote:
> On Wed, 2004-10-13 at 15:32, H. J. Lu wrote:
> > 	PR 445
> > 	* emulparams/elf64_ia64.sh (SMALL_DATA_CTOR): Set.
> > 	(SMALL_DATA_DTOR): Set
> > 	* scripttempl/elf.sc: If SMALL_DATA_CTOR is set, move .ctors
> > 	after .data. If SMALL_DATA_DTOR is set, move .dtors after .data.
> 
> The bug report doesn't clearly say what is wrong.  I had to look at
> binutils sources and gcc output to figure out what you were trying to
> say.  The problem here is that icc sets the SHF_IA_64_SHORT bit on the
> ctor/dtor sections, which it shouldn't, and this causes trouble for the
> gp calculation because ctor/dtor are now before the data section, and gp
> can't span the entire data section.
> 
> The readelf output is ambiguous here, as "p" simply means that some
> processor specific section header flag is set, and there is more than
> one of them.  The objdump output would have been more useful, as objdump
> will print SHORT_DATA when the SHF_IA_64_SHORT bit is set.
> 
> So icc needs to be fixed, but even if it is fixed, we probably need to
> accept libraries/object files compiled with old icc indefinitely, so the
> patch seems reasonable.
> 
> I think the patch does have one flaw though.  There is no comment
> explaining why we are doing this.  There should be a comment in the
> elf64_ia64.sh file saying this is necessary because some icc versions
> set the short data flag on ctor/dtor sections.  Even better if we can
> list the version number when it was fixed.  Otherwise, people looking at
> this in the future won't be able to understand why this weirdness is
> there.

I will try to get it fixed in the next icc.

> 
> The patch is OK with a comment added.
> 
> By the way, the FreeBSD elf64_ia64_fbsd.sh file includes elf64_ia64.sh. 
> If the Intel compiler does not and will not support FreeBSD, then
> perhaps we should clear SMALL_DATA_{CTOR,DTOR} in this file.  It isn't
> clear to me if this makes enough difference to matter though.

This is the patch I checked in.

Thanks.


H.J.
-----
2004-10-14  H.J. Lu  <hongjiu.lu@intel.com>

	PR 445
	* emulparams/elf64_ia64.sh (SMALL_DATA_CTOR): Set.
	(SMALL_DATA_DTOR): Set.
	* emulparams/elf64_ia64_fbsd.sh (SMALL_DATA_CTOR): Unset.
	(SMALL_DATA_DTOR): Unset.
	* scripttempl/elf.sc: If SMALL_DATA_CTOR is set, move .ctors
	after .data. If SMALL_DATA_DTOR is set, move .dtors after
	.data.

--- ld/emulparams/elf64_ia64.sh.small	2004-01-28 14:46:40.000000000 -0800
+++ ld/emulparams/elf64_ia64.sh	2004-10-14 09:54:20.862938477 -0700
@@ -33,3 +33,7 @@ test -n "$CREATE_PIE" && OTHER_GOT_RELOC
 OTHER_READONLY_SECTIONS="${OTHER_READONLY_SECTIONS}
   .IA_64.unwind_info ${RELOCATING-0} : { *(.IA_64.unwind_info${RELOCATING+* .gnu.linkonce.ia64unwi.*}) }
   .IA_64.unwind ${RELOCATING-0} : { *(.IA_64.unwind${RELOCATING+* .gnu.linkonce.ia64unw.*}) }"
+# Intel C++ compiler, prior to 9.0, puts small data in .ctors and
+# .dtors.  They have to be next to .sbss/.sbss2/.sdata/.sdata2.
+SMALL_DATA_CTOR=" "
+SMALL_DATA_DTOR=" "
--- ld/emulparams/elf64_ia64_fbsd.sh.small	2003-12-04 10:43:27.000000000 -0800
+++ ld/emulparams/elf64_ia64_fbsd.sh	2004-10-14 09:54:54.488591561 -0700
@@ -1,4 +1,6 @@
 . ${srcdir}/emulparams/elf64_ia64.sh
 TEXT_START_ADDR="0x2000000000000000"
 unset DATA_ADDR
+unset SMALL_DATA_CTOR
+unset SMALL_DATA_DTOR
 . ${srcdir}/emulparams/elf_fbsd.sh
--- ld/scripttempl/elf.sc.small	2004-10-04 10:29:49.000000000 -0700
+++ ld/scripttempl/elf.sc	2004-10-14 09:22:24.898622445 -0700
@@ -3,6 +3,8 @@
 #	NOP - four byte opcode for no-op (defaults to 0)
 #	NO_SMALL_DATA - no .sbss/.sbss2/.sdata/.sdata2 sections if not
 #		empty.
+#	SMALL_DATA_CTOR - .ctors contains small data.
+#	SMALL_DATA_DTOR - .dtors contains small data.
 #	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 ...
@@ -347,8 +349,8 @@ cat <<EOF
   .fini_array   ${RELOCATING-0} : { KEEP (*(.fini_array)) }
   ${RELOCATING+${CREATE_SHLIB-PROVIDE (__fini_array_end = .);}}
 
-  ${RELOCATING+${CTOR}}
-  ${RELOCATING+${DTOR}}
+  ${SMALL_DATA_CTOR-${RELOCATING+${CTOR}}}
+  ${SMALL_DATA_DTOR-${RELOCATING+${DTOR}}}
   .jcr          ${RELOCATING-0} : { KEEP (*(.jcr)) }
 
   ${RELOCATING+${DATARELRO}}
@@ -372,6 +374,8 @@ cat <<EOF
   .data1        ${RELOCATING-0} : { *(.data1) }
   ${WRITABLE_RODATA+${RODATA}}
   ${OTHER_READWRITE_SECTIONS}
+  ${SMALL_DATA_CTOR+${RELOCATING+${CTOR}}}
+  ${SMALL_DATA_DTOR+${RELOCATING+${DTOR}}}
   ${DATA_PLT+${PLT_BEFORE_GOT+${PLT}}}
   ${RELOCATING+${OTHER_GOT_SYMBOLS}}
   ${NO_SMALL_DATA-${GOT}}

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-10-14 17:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-13 21:58 PATCH: PR 445: A64 linker complains short data segment overflowed H. J. Lu
2004-10-13 22:02 ` Jakub Jelinek
2004-10-13 22:32   ` H. J. Lu
2004-10-14  0:59     ` James E Wilson
2004-10-14 17:05       ` H. J. Lu

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).