This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


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

opd tags for powerpc64


This patch defines a couple of extra dynamic tags for PowerPC64 ELF,
with the aim of removing .opd section relocs from dynamic objects.

include/elf/ChangeLog
	* ppc.h (DT_PPC64_OPD, DT_PPC64_OPDSZ): Define.

binutils/ChangeLog
	* readelf.c (get_ppc64_dynamic_type): Handle DT_PPC64_OPD and
	DT_PPC64_OPDSZ.

bfd/ChangeLog
	* elf64-ppc.c (ppc64_elf_size_dynamic_sections): Add dynamic
	DT_PPC64_OPD and DT_PPC64_OPDSZ tags.
	(ppc64_elf_finish_dynamic_sections): Set values for them.

I'd like to put this on the branch too.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

Index: include/elf/ppc.h
===================================================================
RCS file: /cvs/src/src/include/elf/ppc.h,v
retrieving revision 1.7
diff -u -p -r1.7 ppc.h
--- ppc.h	2002/01/16 05:48:56	1.7
+++ ppc.h	2002/02/12 06:08:45
@@ -174,6 +174,10 @@ END_RELOC_NUMBERS (R_PPC_max)
 /* Specify the start of the .glink section.  */
 #define DT_PPC64_GLINK		DT_LOPROC
 
+/* Specify the start and size of the .opd section.  */
+#define DT_PPC64_OPD		(DT_LOPROC + 1)
+#define DT_PPC64_OPDSZ		(DT_LOPROC + 2)
+
 /* Processor specific flags for the ELF header e_flags field.  */
 
 #define	EF_PPC_EMB		0x80000000	/* PowerPC embedded flag.  */
Index: binutils/readelf.c
===================================================================
RCS file: /cvs/src/src/binutils/readelf.c,v
retrieving revision 1.149
diff -u -p -r1.149 readelf.c
--- readelf.c	2002/01/31 17:32:57	1.149
+++ readelf.c	2002/02/12 06:15:16
@@ -1193,6 +1193,8 @@ get_ppc64_dynamic_type (type)
   switch (type)
     {
     case DT_PPC64_GLINK: return "PPC64_GLINK";
+    case DT_PPC64_OPD:   return "PPC64_OPD";
+    case DT_PPC64_OPDSZ: return "PPC64_OPDSZ";
     default:
       return NULL;
     }
Index: bfd/elf64-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-ppc.c,v
retrieving revision 1.26
diff -u -p -r1.26 elf64-ppc.c
--- elf64-ppc.c	2002/02/05 00:00:23	1.26
+++ elf64-ppc.c	2002/02/12 06:07:20
@@ -156,11 +156,8 @@ static boolean ppc64_elf_finish_dynamic_
 /* Since .opd is an array of descriptors and each entry will end up
    with identical R_PPC64_RELATIVE relocs, there is really no need to
    propagate .opd relocs;  The dynamic linker should be taught to
-   relocate .opd without reloc entries.  FIXME: the dynamic linker
-   will need to know where and how large .opd is via a couple of new
-   DT_PPC64_* tags, or perhaps just with one reloc that specifies the
-   start of .opd via its offset and the size via its addend.  Also,
-   .opd should be trimmed of unused values.  */
+   relocate .opd without reloc entries.  FIXME: .opd should be trimmed
+   of unused values.  */
 #ifndef NO_OPD_RELOCS
 #define NO_OPD_RELOCS 0
 #endif
@@ -3128,6 +3125,13 @@ ppc64_elf_size_dynamic_sections (output_
 	    return false;
 	}
 
+      if (NO_OPD_RELOCS)
+	{
+	  if (!add_dynamic_entry (DT_PPC64_OPD, 0)
+	      || !add_dynamic_entry (DT_PPC64_OPDSZ, 0))
+	    return false;
+	}
+
       if (relocs)
 	{
 	  if (!add_dynamic_entry (DT_RELA, 0)
@@ -4354,6 +4358,7 @@ ppc64_elf_finish_dynamic_sections (outpu
       for (; dyncon < dynconend; dyncon++)
 	{
 	  Elf_Internal_Dyn dyn;
+	  asection *s;
 
 	  bfd_elf64_swap_dyn_in (dynobj, dyncon, &dyn);
 
@@ -4365,6 +4370,18 @@ ppc64_elf_finish_dynamic_sections (outpu
 	    case DT_PPC64_GLINK:
 	      dyn.d_un.d_ptr = (htab->sglink->output_section->vma
 				+ htab->sglink->output_offset);
+	      break;
+
+	    case DT_PPC64_OPD:
+	      s = bfd_get_section_by_name (output_bfd, ".opd");
+	      if (s != NULL)
+		dyn.d_un.d_ptr = s->vma;
+	      break;
+
+	    case DT_PPC64_OPDSZ:
+	      s = bfd_get_section_by_name (output_bfd, ".opd");
+	      if (s != NULL)
+		dyn.d_un.d_val = s->_raw_size;
 	      break;
 
 	    case DT_PLTGOT:


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