public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
From: David Mosberger <davidm@napali.hpl.hp.com>
To: Richard Henderson <rth@redhat.com>, drow@mvista.com
Cc: GNU libc hacker <libc-hacker@sources.redhat.com>,
	binutils@sources.redhat.com
Subject: Re: [David Mosberger <davidm@hpl.hp.com>] problem with unwind info for .init/.fini sections
Date: Fri, 01 Mar 2002 17:36:00 -0000	[thread overview]
Message-ID: <15488.11435.748938.966608@napali.hpl.hp.com> (raw)
In-Reply-To: <20020301172558.A31648@redhat.com>

>>>>> On Fri, 1 Mar 2002 17:25:58 -0800, Richard Henderson <rth@redhat.com> said:

  Rich> On Fri, Mar 01, 2002 at 05:16:12PM -0800, David Mosberger wrote:
  >> OK, that's what I did.  Could this be applied to the relevant branches?

  Rich> Applied to mainline.

Thanks!


  Rich> IIRC, the 2.12 branch is closed.

Daniel, are you overseeing the 2.12 branch?  If so, any chance to make
an exception for this change?  My hope is the patch is trivial enough
to be considered safe and it would certainly help getting the
remaining unwind-related bugs ironed out of ia64 linux.  It should
also help freebsd/ia64 to get this right from the start.

	--david

---
bfd/ChangeLog:

2002-02-28  David Mosberger  <davidm@hpl.hp.com>

	* elflink.h (size_dynamic_sections): If section named
	".preinit_array" exists, create DT_PREINIT_ARRAY and
	DT_PREINIT_ARRAYSZ entries in dynamic table.  Analogously for
	".init_array" and ".fini_array".
	(elf_bfd_final_link): Handle DT_PREINIT_ARRAYSZ, DT_INIT_ARRAYSZ,
	DT_FINI_ARRAYSZ, DT_PREINIT_ARRAY, DT_INIT_ARRAY, and
	DT_FINI_ARRAY.

---
ld/ChangeLog

2002-02-28  David Mosberger  <davidm@hpl.hp.com>

	* scripttempl/elf.sc (SECTIONS): Add entries for .preinit_array,
	.init_array, and .fini_array.

Index: bfd/elflink.h
===================================================================
RCS file: /cvs/src/src/bfd/elflink.h,v
retrieving revision 1.141
diff -u -r1.141 elflink.h
--- bfd/elflink.h	2002/01/21 10:29:07	1.141
+++ bfd/elflink.h	2002/03/02 01:12:38
@@ -3029,7 +3029,9 @@
      struct bfd_elf_version_tree *verdefs;
 {
   bfd_size_type soname_indx;
-  bfd *dynobj;
+  bfd *dynobj, *sub;
+  asection *o;
+  int need_preinit_array = 0, need_init_array = 0, need_fini_array = 0;
   struct elf_backend_data *bed;
   struct elf_assign_sym_version_info asvinfo;
 
@@ -3200,6 +3202,43 @@
 	    return false;
 	}
 
+      for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
+	for (o = sub->sections; o != NULL; o = o->next)
+	  {
+	    /* yuck, more matching by name... */
+
+	    if (strcmp (bfd_section_name (sub, o), ".preinit_array") == 0)
+	      need_preinit_array = 1;
+	    if (strcmp (bfd_section_name (sub, o), ".init_array") == 0)
+	      need_init_array = 1;
+	    if (strcmp (bfd_section_name (sub, o), ".fini_array") == 0)
+	      need_fini_array = 1;
+	  }
+      if (need_preinit_array)
+	{
+	  if (!elf_add_dynamic_entry (info, (bfd_vma) DT_PREINIT_ARRAY,
+				      (bfd_vma) 0)
+	      || !elf_add_dynamic_entry (info, (bfd_vma) DT_PREINIT_ARRAYSZ,
+					 (bfd_vma) 0))
+	    return false;
+	}
+      if (need_init_array)
+	{
+	  if (!elf_add_dynamic_entry (info, (bfd_vma) DT_INIT_ARRAY,
+				      (bfd_vma) 0)
+	      || !elf_add_dynamic_entry (info, (bfd_vma) DT_INIT_ARRAYSZ,
+					 (bfd_vma) 0))
+	    return false;
+	}
+      if (need_fini_array)
+	{
+	  if (!elf_add_dynamic_entry (info, (bfd_vma) DT_FINI_ARRAY,
+				      (bfd_vma) 0)
+	      || !elf_add_dynamic_entry (info, (bfd_vma) DT_FINI_ARRAYSZ,
+					 (bfd_vma) 0))
+	    return false;
+	}
+
       dynstr = bfd_get_section_by_name (dynobj, ".dynstr");
       /* If .dynstr is excluded from the link, we don't want any of
 	 these tags.  Strictly, we should be checking each section
@@ -5548,6 +5587,31 @@
 		  }
 	      }
 	      break;
+
+	    case DT_PREINIT_ARRAYSZ:
+	      name = ".preinit_array";
+	      goto get_size;
+	    case DT_INIT_ARRAYSZ:
+	      name = ".init_array";
+	      goto get_size;
+	    case DT_FINI_ARRAYSZ:
+	      name = ".fini_array";
+	    get_size:
+	      o = bfd_get_section_by_name (abfd, name);
+	      BFD_ASSERT (o != NULL);
+	      dyn.d_un.d_val = o->_raw_size;
+	      elf_swap_dyn_out (dynobj, &dyn, dyncon);
+	      break;
+
+	    case DT_PREINIT_ARRAY:
+	      name = ".preinit_array";
+	      goto get_vma;
+	    case DT_INIT_ARRAY:
+	      name = ".init_array";
+	      goto get_vma;
+	    case DT_FINI_ARRAY:
+	      name = ".fini_array";
+	      goto get_vma;
 
 	    case DT_HASH:
 	      name = ".hash";
Index: ld/scripttempl/elf.sc
===================================================================
RCS file: /cvs/src/src/ld/scripttempl/elf.sc,v
retrieving revision 1.26
diff -u -r1.26 elf.sc
--- ld/scripttempl/elf.sc	2002/02/12 14:50:08	1.26
+++ ld/scripttempl/elf.sc	2002/03/02 01:12:39
@@ -246,6 +246,23 @@
     ${RELOCATING+${INIT_END}}
   } =${NOP-0}
 
+  /* Ensure the __preinit_array_start label is properly aligned.  We
+     could instead move the label definition inside the section, but
+     the linker would then create the section even if it turns out to
+     be empty, which isn't pretty.  */
+  ${RELOCATING+. = ALIGN(${ALIGNMENT})}
+  ${RELOCATING+${CREATE_SHLIB-PROVIDE (__preinit_array_start = .);}}
+  .preinit_array   ${RELOCATING-0} : { *(.preinit_array) }
+  ${RELOCATING+${CREATE_SHLIB-PROVIDE (__preinit_array_end = .);}}
+
+  ${RELOCATING+${CREATE_SHLIB-PROVIDE (__init_array_start = .)}};
+  .init_array   ${RELOCATING-0} : { *(.init_array) }
+  ${RELOCATING+${CREATE_SHLIB-PROVIDE (__init_array_end = .);}}
+
+  ${RELOCATING+${CREATE_SHLIB-PROVIDE (__fini_array_start = .);}}
+  .fini_array   ${RELOCATING-0} : { *(.fini_array) }
+  ${RELOCATING+${CREATE_SHLIB-PROVIDE (__fini_array_end = .);}}
+
   ${DATA_PLT-${BSS_PLT-${PLT}}}
   .text         ${RELOCATING-0} :
   {

  parent reply	other threads:[~2002-03-02  1:36 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-02-28 14:38 Ulrich Drepper
2002-02-28 16:58 ` H . J . Lu
2002-02-28 17:19   ` David Mosberger
2002-02-28 17:28     ` Ulrich Drepper
2002-02-28 17:33     ` H . J . Lu
2002-02-28 17:43       ` David Mosberger
     [not found]         ` <20020228175426.A30756@redhat.com>
2002-02-28 18:01           ` David Mosberger
2002-02-28 18:11           ` H . J . Lu
2002-02-28 22:42           ` David Mosberger
     [not found]             ` <20020228225757.A30933@redhat.com>
2002-03-01 10:24               ` David Mosberger
     [not found]                 ` <20020301164725.C31581@redhat.com>
2002-03-01 16:56                   ` David Mosberger
     [not found]                     ` <20020301170010.A31610@redhat.com>
2002-03-01 17:20                       ` David Mosberger
     [not found]                         ` <20020301172558.A31648@redhat.com>
2002-03-01 17:36                           ` David Mosberger [this message]
2002-03-02  0:36                 ` H . J . Lu
     [not found]                   ` <20020302101931.GM1059@bubble.sa.bigpond.net.au>
2002-03-02  9:24                     ` David Mosberger
2002-03-02 10:59                       ` H . J . Lu
2002-03-02 11:13                         ` David Mosberger
2002-03-02 11:27                           ` H . J . Lu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=15488.11435.748938.966608@napali.hpl.hp.com \
    --to=davidm@napali.hpl.hp.com \
    --cc=binutils@sources.redhat.com \
    --cc=davidm@hpl.hp.com \
    --cc=drow@mvista.com \
    --cc=libc-hacker@sources.redhat.com \
    --cc=rth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).