This is the mail archive of the binutils@sourceware.org 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]

Re: hppa unwind entries


Hi John,

Sorry, I should have chimed in when I saw Nick's message yesterday.  The
same issue is present for 64-bit hppa targets.  See code in elf-hppa.h.

I have committed the enclosed change. Tested on hppa64-hp-hpux11.00 and hppa-unknown-linux-gnu.

Great minds think alike... I was working on a similar change, except that I moved the segment searching code into elf.c like the attached patch. If you have no objections I will apply this version.


Cheers
  Nick


Index: bfd/elf-bfd.h
===================================================================
RCS file: /cvs/src/src/bfd/elf-bfd.h,v
retrieving revision 1.254
diff -c -3 -p -r1.254 elf-bfd.h
*** bfd/elf-bfd.h	15 Dec 2007 09:42:02 -0000	1.254
--- bfd/elf-bfd.h	29 Dec 2007 09:12:57 -0000
*************** extern bfd_boolean _bfd_elf_map_sections
*** 2076,2081 ****
--- 2076,2084 ----
  
  extern bfd_boolean _bfd_elf_is_function_type (unsigned int);
  
+ extern Elf_Internal_Phdr * _bfd_elf_find_segment_containing_section
+   (bfd * abfd, asection * section);
+ 
  /* Exported interface for writing elf corefile notes. */
  extern char *elfcore_write_note
    (bfd *, char *, int *, const char *, int, const void *, int);
Index: bfd/elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.428
diff -c -3 -p -r1.428 elf.c
*** bfd/elf.c	24 Dec 2007 16:58:23 -0000	1.428
--- bfd/elf.c	29 Dec 2007 09:13:00 -0000
*************** get_program_header_size (bfd *abfd, stru
*** 3426,3431 ****
--- 3426,3454 ----
    return segs * bed->s->sizeof_phdr;
  }
  
+ /* Find the segment that contains the output_section of section.  */
+ 
+ Elf_Internal_Phdr *
+ _bfd_elf_find_segment_containing_section (bfd * abfd, asection * section)
+ {
+   struct elf_segment_map *m;
+   Elf_Internal_Phdr *p;
+ 
+   for (m = elf_tdata (abfd)->segment_map,
+ 	 p = elf_tdata (abfd)->phdr;
+        m != NULL;
+        m = m->next, p++)
+     {
+       int i;
+ 
+       for (i = m->count - 1; i >= 0; i--)
+ 	if (m->sections[i] == section)
+ 	  return p;
+     }
+ 
+   return NULL;
+ }
+ 
  /* Create a mapping from a set of sections to a program segment.  */
  
  static struct elf_segment_map *
Index: bfd/elf32-bfin.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-bfin.c,v
retrieving revision 1.25
diff -c -3 -p -r1.25 elf32-bfin.c
*** bfd/elf32-bfin.c	28 Sep 2007 08:43:45 -0000	1.25
--- bfd/elf32-bfin.c	29 Dec 2007 09:13:01 -0000
*************** _bfinfdpic_add_rofixup (bfd *output_bfd,
*** 1497,1522 ****
  static unsigned
  _bfinfdpic_osec_to_segment (bfd *output_bfd, asection *osec)
  {
!   struct elf_segment_map *m;
!   Elf_Internal_Phdr *p;
! 
!   /* Find the segment that contains the output_section.  */
!   for (m = elf_tdata (output_bfd)->segment_map,
! 	 p = elf_tdata (output_bfd)->phdr;
!        m != NULL;
!        m = m->next, p++)
!     {
!       int i;
! 
!       for (i = m->count - 1; i >= 0; i--)
! 	if (m->sections[i] == osec)
! 	  break;
! 
!       if (i >= 0)
! 	break;
!     }
  
!   return p - elf_tdata (output_bfd)->phdr;
  }
  
  inline static bfd_boolean
--- 1497,1505 ----
  static unsigned
  _bfinfdpic_osec_to_segment (bfd *output_bfd, asection *osec)
  {
!   Elf_Internal_Phdr *p = _bfd_elf_find_segment_containing_section (output_bfd, osec);
  
!   return (p != NULL) ? p - elf_tdata (output_bfd)->phdr : -1;
  }
  
  inline static bfd_boolean
Index: bfd/elf32-frv.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-frv.c,v
retrieving revision 1.58
diff -c -3 -p -r1.58 elf32-frv.c
*** bfd/elf32-frv.c	28 Sep 2007 08:43:45 -0000	1.58
--- bfd/elf32-frv.c	29 Dec 2007 09:13:02 -0000
*************** _frvfdpic_add_rofixup (bfd *output_bfd, 
*** 1341,1366 ****
  static unsigned
  _frvfdpic_osec_to_segment (bfd *output_bfd, asection *osec)
  {
!   struct elf_segment_map *m;
!   Elf_Internal_Phdr *p;
! 
!   /* Find the segment that contains the output_section.  */
!   for (m = elf_tdata (output_bfd)->segment_map,
! 	 p = elf_tdata (output_bfd)->phdr;
!        m != NULL;
!        m = m->next, p++)
!     {
!       int i;
! 
!       for (i = m->count - 1; i >= 0; i--)
! 	if (m->sections[i] == osec)
! 	  break;
! 
!       if (i >= 0)
! 	break;
!     }
  
!   return p - elf_tdata (output_bfd)->phdr;
  }
  
  inline static bfd_boolean
--- 1341,1349 ----
  static unsigned
  _frvfdpic_osec_to_segment (bfd *output_bfd, asection *osec)
  {
!   Elf_Internal_Phdr *p = _bfd_elf_find_segment_containing_section (output_bfd, osec);
  
!   return (p != NULL) ? p - elf_tdata (output_bfd)->phdr : -1;
  }
  
  inline static bfd_boolean
Index: bfd/elf32-hppa.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-hppa.c,v
retrieving revision 1.159
diff -c -3 -p -r1.159 elf32-hppa.c
*** bfd/elf32-hppa.c	28 Dec 2007 23:43:45 -0000	1.159
--- bfd/elf32-hppa.c	29 Dec 2007 09:13:03 -0000
*************** elf32_hppa_final_link (bfd *abfd, struct
*** 3256,3264 ****
  /* Record the lowest address for the data and text segments.  */
  
  static void
! hppa_record_segment_addr (bfd *abfd,
! 			  asection *section,
! 			  void *data)
  {
    struct elf32_hppa_link_hash_table *htab;
  
--- 3256,3262 ----
  /* Record the lowest address for the data and text segments.  */
  
  static void
! hppa_record_segment_addr (bfd *abfd, asection *section, void *data)
  {
    struct elf32_hppa_link_hash_table *htab;
  
*************** hppa_record_segment_addr (bfd *abfd,
*** 3266,3273 ****
  
    if ((section->flags & (SEC_ALLOC | SEC_LOAD)) == (SEC_ALLOC | SEC_LOAD))
      {
!       unsigned seg = elf_hppa_osec_to_segment (abfd, section->output_section);
!       bfd_vma value = elf_tdata (abfd)->phdr[seg].p_vaddr;
  
        if ((section->flags & SEC_READONLY) != 0)
  	{
--- 3264,3277 ----
  
    if ((section->flags & (SEC_ALLOC | SEC_LOAD)) == (SEC_ALLOC | SEC_LOAD))
      {
!       bfd_vma value;
!       Elf_Internal_Phdr *p;
! 
!       p = _bfd_elf_find_segment_containing_section (abfd, section->output_section);
! 
!       if (p == NULL)
!         return;
!       value = p->p_vaddr;
  
        if ((section->flags & SEC_READONLY) != 0)
  	{
Index: bfd/elfxx-ia64.c
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-ia64.c,v
retrieving revision 1.204
diff -c -3 -p -r1.204 elfxx-ia64.c
*** bfd/elfxx-ia64.c	24 Dec 2007 16:55:39 -0000	1.204
--- bfd/elfxx-ia64.c	29 Dec 2007 09:13:05 -0000
*************** elfNN_ia64_relocate_section (bfd *output
*** 4894,4917 ****
  	case R_IA64_SEGREL64MSB:
  	case R_IA64_SEGREL64LSB:
  	    {
- 	      struct elf_segment_map *m;
- 	      Elf_Internal_Phdr *p;
- 
  	      /* Find the segment that contains the output_section.  */
! 	      for (m = elf_tdata (output_bfd)->segment_map,
! 		     p = elf_tdata (output_bfd)->phdr;
! 		   m != NULL;
! 		   m = m->next, p++)
! 		{
! 		  int i;
! 		  for (i = m->count - 1; i >= 0; i--)
! 		    if (m->sections[i] == input_section->output_section)
! 		      break;
! 		  if (i >= 0)
! 		    break;
! 		}
  
! 	      if (m == NULL)
  		{
  		  r = bfd_reloc_notsupported;
  		}
--- 4894,4904 ----
  	case R_IA64_SEGREL64MSB:
  	case R_IA64_SEGREL64LSB:
  	    {
  	      /* Find the segment that contains the output_section.  */
! 	      Elf_Internal_Phdr *p = _bfd_elf_find_segment_containing_section
! 		(input_bfd, input_section->output_section);
  
! 	      if (p == NULL)
  		{
  		  r = bfd_reloc_notsupported;
  		}

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