public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Reserve a few .dynamic entries
@ 2001-06-06  9:10 Jakub Jelinek
  2001-06-06 10:15 ` Hans-Peter Nilsson
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Jakub Jelinek @ 2001-06-06  9:10 UTC (permalink / raw)
  To: binutils

Hi!

As .dynamic section is usually located in between sections which may have
relocated relocations against, it is not possible after final link to insert
new .dynamic entries which e.g. prelinking needs to do.

The following patch inserts 6 DT_NULL ElfW(Dyn) entries at the end of
.dynamic (iff .dynamic section is created), so that post-link utilities can
just put the tags they need into those slots and don't have to copy the
whole .dynamic somewhere else (which would require new PT_LOAD segment
usually). It wastes 48 resp. 96 bytes if no prelinking or any other
post-link optimization is done.

Do you agree with this? Can I commit it?

2001-06-06  Jakub Jelinek  <jakub@redhat.com>

	* scripttempl/elf.sc (DYNAMIC): Reserve 6 ElfW(Dyn) entries for
	post-linking tools.

--- ld/scripttempl/elf.sc.jj	Sat Sep  2 22:43:22 2000
+++ ld/scripttempl/elf.sc	Wed Jun  6 17:59:17 2001
@@ -66,7 +66,7 @@ test -z "${ALIGNMENT}" && ALIGNMENT="${E
 test "$LD_FLAG" = "N" && DATA_ADDR=.
 INTERP=".interp   ${RELOCATING-0} : { *(.interp) 	}"
 PLT=".plt    ${RELOCATING-0} : { *(.plt)	}"
-DYNAMIC=".dynamic     ${RELOCATING-0} : { *(.dynamic) }"
+DYNAMIC=".dynamic     ${RELOCATING-0} : { *(.dynamic) ${RELOCATING+FILL(0) . += 6 * ${ELFSIZE} / 4; } }"
 RODATA=".rodata ${RELOCATING-0} : { *(.rodata) ${RELOCATING+*(.rodata.*)} ${RELOCATING+*(.gnu.linkonce.r.*)} }"
 SBSS2=".sbss2 ${RELOCATING-0} : { *(.sbss2) ${RELOCATING+*(.sbss2.*)} ${RELOCATING+*(.gnu.linkonce.sb2.*)} }"
 SDATA2=".sdata2 ${RELOCATING-0} : { *(.sdata2) ${RELOCATING+*(.sdata2.*)} ${RELOCATING+*(.gnu.linkonce.s2.*)} }"

	Jakub

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

* Re: [PATCH] Reserve a few .dynamic entries
  2001-06-06  9:10 [PATCH] Reserve a few .dynamic entries Jakub Jelinek
@ 2001-06-06 10:15 ` Hans-Peter Nilsson
  2001-06-08 11:13   ` [PATCH] Reserve a few .dynamic entries (take 2) Jakub Jelinek
  2001-06-06 10:32 ` [PATCH] Reserve a few .dynamic entries Hans-Peter Nilsson
  2001-06-08 15:04 ` Ulrich Drepper
  2 siblings, 1 reply; 9+ messages in thread
From: Hans-Peter Nilsson @ 2001-06-06 10:15 UTC (permalink / raw)
  To: jakub; +Cc: binutils

> Date: Wed, 6 Jun 2001 18:13:38 +0200
> From: Jakub Jelinek <jakub@redhat.com>

> +DYNAMIC=".dynamic     ${RELOCATING-0} : { *(.dynamic) ${RELOCATING+FILL(0) . += 6 * ${ELFSIZE} / 4; } }"

I think there should be a shell-variable (perhaps default on)
that a ld emulation can (un)set, and which should be tested when
adding that padding.  And a comment.

brgds, H-P

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

* Re: [PATCH] Reserve a few .dynamic entries
  2001-06-06  9:10 [PATCH] Reserve a few .dynamic entries Jakub Jelinek
  2001-06-06 10:15 ` Hans-Peter Nilsson
@ 2001-06-06 10:32 ` Hans-Peter Nilsson
  2001-06-06 16:45   ` Ben Elliston
  2001-06-08 15:04 ` Ulrich Drepper
  2 siblings, 1 reply; 9+ messages in thread
From: Hans-Peter Nilsson @ 2001-06-06 10:32 UTC (permalink / raw)
  To: jakub; +Cc: binutils

> Date: Wed, 6 Jun 2001 18:13:38 +0200
> From: Jakub Jelinek <jakub@redhat.com>

> +DYNAMIC=".dynamic     ${RELOCATING-0} : { *(.dynamic) ${RELOCATING+FILL(0) . += 6 * ${ELFSIZE} / 4; } }"

Oh, and I think you need tp rewrite that to not have a '}' in
the '+'-part.  IIRC it breaks with solaris /bin/sh.  Ask Alex
Oliva.

brgds, H-P
PS.  Looking forward to that prelinking stuff.

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

* Re: [PATCH] Reserve a few .dynamic entries
  2001-06-06 10:32 ` [PATCH] Reserve a few .dynamic entries Hans-Peter Nilsson
@ 2001-06-06 16:45   ` Ben Elliston
  0 siblings, 0 replies; 9+ messages in thread
From: Ben Elliston @ 2001-06-06 16:45 UTC (permalink / raw)
  To: Hans-Peter Nilsson; +Cc: jakub, binutils

>>>>> "Hans-Peter" == Hans-Peter Nilsson <hans-peter.nilsson@axis.com> writes:

  >> Date: Wed, 6 Jun 2001 18:13:38 +0200
  >> From: Jakub Jelinek <jakub@redhat.com>

  >> +DYNAMIC=".dynamic     ${RELOCATING-0} : { *(.dynamic) ${RELOCATING+FILL(0) . += 6 * ${ELFSIZE} / 4; } }"

  Hans-Peter> Oh, and I think you need tp rewrite that to not have a '}' in
  Hans-Peter> the '+'-part.  IIRC it breaks with solaris /bin/sh.  Ask Alex
  Hans-Peter> Oliva.

Here is a snippet of a patch that explains this situation.  Hopefully
the comment is sufficient.

  -OTHER_RELOCATING_SECTIONS=${OTHER_RELOCATING_SECTIONS-'
  +
  +# Do not use the ${varname-${varname}} construct here; there will be
  +# problems with some shells (e.g. on Solaris) since there is a bug
  +# that trigs when the incoming macro value contains a "}".
  +test -z "$OTHER_RELOCATING_SECTIONS" && OTHER_RELOCATING_SECTIONS='
    .foo 0 : { *(.foo) }
    .stack 0x30000 : { _stack = .; *(.stack) }
  -'}
  +'

Ben

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

* [PATCH] Reserve a few .dynamic entries (take 2)
  2001-06-06 10:15 ` Hans-Peter Nilsson
@ 2001-06-08 11:13   ` Jakub Jelinek
  2001-06-08 12:10     ` Hans-Peter Nilsson
  0 siblings, 1 reply; 9+ messages in thread
From: Jakub Jelinek @ 2001-06-08 11:13 UTC (permalink / raw)
  To: Hans-Peter Nilsson; +Cc: binutils

On Wed, Jun 06, 2001 at 07:15:40PM +0200, Hans-Peter Nilsson wrote:
> > Date: Wed, 6 Jun 2001 18:13:38 +0200
> > From: Jakub Jelinek <jakub@redhat.com>
> 
> > +DYNAMIC=".dynamic     ${RELOCATING-0} : { *(.dynamic) ${RELOCATING+FILL(0) . += 6 * ${ELFSIZE} / 4; } }"
> 
> I think there should be a shell-variable (perhaps default on)
> that a ld emulation can (un)set, and which should be tested when
> adding that padding.  And a comment.

Ok, is this better (ie. can I commit it)?
ld emulations which don't want the reserved entries can just set
DYNAMIC_PAD=" "

2001-06-08  Jakub Jelinek  <jakub@redhat.com>

	* scripttempl/elf.sc (DYNAMIC_PAD): New variable.
	(DYNAMIC): Use it to reserve few dynamic entries for post-linking
	tools.

--- ld/scripttempl/elf.sc.jj	Sat Sep  2 22:43:22 2000
+++ ld/scripttempl/elf.sc	Fri Jun  8 20:07:12 2001
@@ -32,6 +32,8 @@
 # 	combination of .init sections.
 #	FINI_START, FINI_END - statements just before and just after
 # 	combination of .fini sections.
+#	DYNAMIC_PAD - script to insert pad at end of .dynamic section.
+#		Setting this to " " will result in no .dynamic padding.
 #
 # When adding sections, do note that the names of some sections are used
 # when specifying the start address of the next.
@@ -66,7 +68,14 @@ test -z "${ALIGNMENT}" && ALIGNMENT="${E
 test "$LD_FLAG" = "N" && DATA_ADDR=.
 INTERP=".interp   ${RELOCATING-0} : { *(.interp) 	}"
 PLT=".plt    ${RELOCATING-0} : { *(.plt)	}"
-DYNAMIC=".dynamic     ${RELOCATING-0} : { *(.dynamic) }"
+test -z "$DYNAMIC_PAD" && test -n "$RELOCATING" && DYNAMIC_PAD="
+    /* Leave some space in .dynamic section, so that
+       post-linking utilities can add new dynamic tags.  */
+    FILL(0) . += 6 * ${ELFSIZE} / 4;"
+DYNAMIC=".dynamic     ${RELOCATING-0} :
+  {
+    *(.dynamic) $DYNAMIC_PAD
+  }"
 RODATA=".rodata ${RELOCATING-0} : { *(.rodata) ${RELOCATING+*(.rodata.*)} ${RELOCATING+*(.gnu.linkonce.r.*)} }"
 SBSS2=".sbss2 ${RELOCATING-0} : { *(.sbss2) ${RELOCATING+*(.sbss2.*)} ${RELOCATING+*(.gnu.linkonce.sb2.*)} }"
 SDATA2=".sdata2 ${RELOCATING-0} : { *(.sdata2) ${RELOCATING+*(.sdata2.*)} ${RELOCATING+*(.gnu.linkonce.s2.*)} }"


	Jakub

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

* Re: [PATCH] Reserve a few .dynamic entries (take 2)
  2001-06-08 11:13   ` [PATCH] Reserve a few .dynamic entries (take 2) Jakub Jelinek
@ 2001-06-08 12:10     ` Hans-Peter Nilsson
  0 siblings, 0 replies; 9+ messages in thread
From: Hans-Peter Nilsson @ 2001-06-08 12:10 UTC (permalink / raw)
  To: jakub; +Cc: hans-peter.nilsson, binutils

> Date: Fri, 8 Jun 2001 20:16:57 +0200
> From: Jakub Jelinek <jakub@redhat.com>

> Ok, is this better (ie. can I commit it)?

FWIW, it looks good to me, but I'm not an approver.

brgds, H-P

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

* Re: [PATCH] Reserve a few .dynamic entries
  2001-06-06  9:10 [PATCH] Reserve a few .dynamic entries Jakub Jelinek
  2001-06-06 10:15 ` Hans-Peter Nilsson
  2001-06-06 10:32 ` [PATCH] Reserve a few .dynamic entries Hans-Peter Nilsson
@ 2001-06-08 15:04 ` Ulrich Drepper
  2 siblings, 0 replies; 9+ messages in thread
From: Ulrich Drepper @ 2001-06-08 15:04 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: binutils

Jakub Jelinek <jakub@redhat.com> writes:

> Do you agree with this? Can I commit it?

I think it's no good idea to do this unconditionally.

-- 
---------------.                          ,-.   1325 Chesapeake Terrace
Ulrich Drepper  \    ,-------------------'   \  Sunnyvale, CA 94089 USA
Red Hat          `--' drepper at redhat.com   `------------------------

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

* Re: [PATCH] Reserve a few .dynamic entries (take 2)
  2001-07-03 16:31 [PATCH] Reserve a few .dynamic entries (take 2) H . J . Lu
@ 2001-07-04 10:48 ` H . J . Lu
  0 siblings, 0 replies; 9+ messages in thread
From: H . J . Lu @ 2001-07-04 10:48 UTC (permalink / raw)
  To: jakub; +Cc: binutils

On Tue, Jul 03, 2001 at 04:29:50PM -0700, H . J . Lu wrote:
> Hi Jakub,
> 
> I don't think this patch is correct. It creates dynamic entries even
> for static binaries. First, they are not necessary for static binaries.
> Secondly,
> 
> # gcc -static foo.c
> 
> dumps core for Linux/mips. I think you should pad .dynamic when you
> create it.
> 
> 
> H.J.
> ----
> 2001-06-08  Jakub Jelinek  <jakub@redhat.com>
> 
> 	* scripttempl/elf.sc (DYNAMIC_PAD): New variable.
> 	(DYNAMIC): Use it to reserve few dynamic entries for post-linking
> 	tools.
> 

Can we add another switch to the ELF linker like

	--reserve-dynamic N


H.J.

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

* Re: [PATCH] Reserve a few .dynamic entries (take 2)
@ 2001-07-03 16:31 H . J . Lu
  2001-07-04 10:48 ` H . J . Lu
  0 siblings, 1 reply; 9+ messages in thread
From: H . J . Lu @ 2001-07-03 16:31 UTC (permalink / raw)
  To: jakub; +Cc: binutils

Hi Jakub,

I don't think this patch is correct. It creates dynamic entries even
for static binaries. First, they are not necessary for static binaries.
Secondly,

# gcc -static foo.c

dumps core for Linux/mips. I think you should pad .dynamic when you
create it.


H.J.
----
2001-06-08  Jakub Jelinek  <jakub@redhat.com>

	* scripttempl/elf.sc (DYNAMIC_PAD): New variable.
	(DYNAMIC): Use it to reserve few dynamic entries for post-linking
	tools.

--- ld/scripttempl/elf.sc.jj	Sat Sep  2 22:43:22 2000
+++ ld/scripttempl/elf.sc	Fri Jun  8 20:07:12 2001
@@ -32,6 +32,8 @@
 # 	combination of .init sections.
 #	FINI_START, FINI_END - statements just before and just after
 # 	combination of .fini sections.
+#	DYNAMIC_PAD - script to insert pad at end of .dynamic section.
+#		Setting this to " " will result in no .dynamic padding.
 #
 # When adding sections, do note that the names of some sections are used
 # when specifying the start address of the next.
@@ -66,7 +68,14 @@ test -z "${ALIGNMENT}" && ALIGNMENT="${E
 test "$LD_FLAG" = "N" && DATA_ADDR=.
 INTERP=".interp   ${RELOCATING-0} : { *(.interp) 	}"
 PLT=".plt    ${RELOCATING-0} : { *(.plt)	}"
-DYNAMIC=".dynamic     ${RELOCATING-0} : { *(.dynamic) }"
+test -z "$DYNAMIC_PAD" && test -n "$RELOCATING" && DYNAMIC_PAD="
+    /* Leave some space in .dynamic section, so that
+       post-linking utilities can add new dynamic tags.  */
+    FILL(0) . += 6 * ${ELFSIZE} / 4;"
+DYNAMIC=".dynamic     ${RELOCATING-0} :
+  {
+    *(.dynamic) $DYNAMIC_PAD
+  }"
 RODATA=".rodata ${RELOCATING-0} : { *(.rodata) ${RELOCATING+*(.rodata.*)} ${RELOCATING+*(.gnu.linkonce.r.*)} }"
 SBSS2=".sbss2 ${RELOCATING-0} : { *(.sbss2) ${RELOCATING+*(.sbss2.*)} ${RELOCATING+*(.gnu.linkonce.sb2.*)} }"
 SDATA2=".sdata2 ${RELOCATING-0} : { *(.sdata2) ${RELOCATING+*(.sdata2.*)} ${RELOCATING+*(.gnu.linkonce.s2.*)} }"

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

end of thread, other threads:[~2001-07-04 10:48 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-06-06  9:10 [PATCH] Reserve a few .dynamic entries Jakub Jelinek
2001-06-06 10:15 ` Hans-Peter Nilsson
2001-06-08 11:13   ` [PATCH] Reserve a few .dynamic entries (take 2) Jakub Jelinek
2001-06-08 12:10     ` Hans-Peter Nilsson
2001-06-06 10:32 ` [PATCH] Reserve a few .dynamic entries Hans-Peter Nilsson
2001-06-06 16:45   ` Ben Elliston
2001-06-08 15:04 ` Ulrich Drepper
2001-07-03 16:31 [PATCH] Reserve a few .dynamic entries (take 2) H . J . Lu
2001-07-04 10:48 ` 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).