This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [David Mosberger <davidm@hpl.hp.com>] problem with unwind info for .init/.fini sections


>>>>> On Thu, 28 Feb 2002 17:54:26 -0800, Richard Henderson <rth@redhat.com> said:

  Rich> On Thu, Feb 28, 2002 at 05:43:07PM -0800, David Mosberger
  Rich> wrote:

  HJ> I believe glibc is ok. The problem is binutils. I didn't see any
  HJ> supports for DT_INIT_ARRAY, DT_FINI_ARRAY. DT_INIT_ARRAYSZ,
  HJ> DT_FINI_ARRAYSZ, DT_PREINIT_ARRAY nor DT_PREINIT_ARRAYSZ.

  David>  Shouldn't this be easy straight-forward to add?

  Rich> Yes, it should.  I think there's even some code for this for
  Rich> ia64-hpux in the tree already.

OK, how is the attached for a start?

I'm not sure it's 100% correct, so it needs some reviewing, but it
does seem to do the right thing.

There is one more problem in glibc however: each platform's startup
code needs to be modified to handle these sections (since the dynamic
loader doesn't call them; which makes sense given that we need to
handle static binaries at any rate).  But how can the startup code
find to these sections?  Perhaps we should define symbols in the
linker script to mark the beginning and end of each section?  (I don't
know what the ${RELOCATING+${INIT_ARRAY_START}} stuff means in
scripttempl/elf.sc; perhaps this does the right thing?)

Thanks,

	--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:

2001-04-18  David Mosberger  <davidm@hpl.hp.com>

	* emulparams/elf64_ia64.sh (EXECUTABLE_SYMBOLS): Provide default
	value for _FPU_STATUS (initial value of ar.fpsr).



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/01 06:26:19
@@ -3200,6 +3200,33 @@
 	    return false;
 	}
 
+      /* yuck, more matching by name... */
+
+      if (bfd_get_section_by_name (output_bfd, ".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 (bfd_get_section_by_name (output_bfd, ".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 (bfd_get_section_by_name (output_bfd, ".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 +5575,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/01 06:26:29
@@ -246,6 +246,27 @@
     ${RELOCATING+${INIT_END}}
   } =${NOP-0}
 
+  .preinit_array   ${RELOCATING-0} :
+  {
+    ${RELOCATING+${PREINIT_ARRAY_START}}
+    KEEP (*(.preinit_array))
+    ${RELOCATING+${PREINIT_ARRAY_END}}
+  }
+
+  .init_array   ${RELOCATING-0} :
+  {
+    ${RELOCATING+${INIT_ARRAY_START}}
+    KEEP (*(.init_array))
+    ${RELOCATING+${INIT_ARRAY_END}}
+  }
+
+  .fini_array   ${RELOCATING-0} :
+  {
+    ${RELOCATING+${FINI_ARRAY_START}}
+    KEEP (*(.fini_array))
+    ${RELOCATING+${FINI_ARRAY_END}}
+  }
+
   ${DATA_PLT-${BSS_PLT-${PLT}}}
   .text         ${RELOCATING-0} :
   {


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]