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]

PATCH: PR binutils/5449: "data not in region 1 for SHARE_MAGIC" after strip with 2.18


The problem is we are trying to adjust p_paddr when it is set to
0. Also max page size for ia64/hpux is 64k, like other ia64 targets.

We also need to deal with HPUX uses sh_info instead of sh_link
for SHT_IA_64_UNWIND/SHF_LINK_ORDER. I guess we should add a
backend function to deal with it.

H.J.
---
2007-12-13  H.J. Lu  <hongjiu.lu@intel.com>

	PR binutils/5449
	* elf.c (_bfd_elf_setup_sections): Try the sh_info field for
	SHF_LINK_ORDER.
	(rewrite_elf_program_header): Don't adjust p_paddr if p_paddr
	is set to 0.
	(copy_private_bfd_data): Call rewrite_elf_program_header if
	p_paddr is set to 0.

	* elfxx-ia64.c (ELF_MAXPAGESIZE): Don't redefine it for HPUX.

--- bfd/elf.c.5449	2007-12-13 12:59:40.000000000 -0800
+++ bfd/elf.c	2007-12-13 16:20:52.000000000 -0800
@@ -695,7 +695,10 @@ _bfd_elf_setup_sections (bfd *abfd)
 	  unsigned int elfsec = this_hdr->sh_link;
 	  /* FIXME: The old Intel compiler and old strip/objcopy may
 	     not set the sh_link or sh_info fields.  Hence we could
-	     get the situation where elfsec is 0.  */
+	     get the situation where elfsec is 0.  Also check sh_info
+	     since HP-UX uses sh_info instead of sh_link.  */
+	  if (elfsec == 0)
+	    elfsec = this_hdr->sh_info;
 	  if (elfsec == 0)
 	    {
 	      const struct elf_backend_data *bed
@@ -5495,9 +5498,13 @@ rewrite_elf_program_header (bfd *ibfd, b
       first_matching_lma = TRUE;
       first_suggested_lma = TRUE;
 
-      for (j = 0, section = ibfd->sections;
+      for (section = ibfd->sections;
 	   section != NULL;
 	   section = section->next)
+	if (section == first_section)
+	  break;
+
+      for (j = 0; section != NULL; section = section->next)
 	{
 	  if (INCLUDE_SECTION_IN_SEGMENT (section, segment, bed))
 	    {
@@ -5547,6 +5554,9 @@ rewrite_elf_program_header (bfd *ibfd, b
 		  suggested_lma = output_section->lma;
 		  first_suggested_lma = FALSE;
 		}
+
+	      if (j == section_count)
+		break;
 	    }
 	}
 
@@ -5564,7 +5574,8 @@ rewrite_elf_program_header (bfd *ibfd, b
 	  *pointer_to_map = map;
 	  pointer_to_map = &map->next;
 
-	  if (matching_lma != map->p_paddr
+	  if (!bed->want_p_paddr_set_to_zero
+	      && matching_lma != map->p_paddr
 	      && !map->includes_filehdr && !map->includes_phdrs)
 	    /* There is some padding before the first section in the
 	       segment.  So, we must account for that in the output
@@ -5918,6 +5929,13 @@ copy_private_bfd_data (bfd *ibfd, bfd *o
       asection *section, *osec;
       unsigned int i, num_segments;
       Elf_Internal_Shdr *this_hdr;
+      const struct elf_backend_data *bed;
+
+      bed = get_elf_backend_data (ibfd);
+
+      /* Regenerate the segment map if p_paddr is set to 0.  */
+      if (bed->want_p_paddr_set_to_zero)
+	goto rewrite;
 
       /* Initialize the segment mark field.  */
       for (section = obfd->sections; section != NULL;
--- bfd/elfxx-ia64.c.5449	2007-12-13 12:59:41.000000000 -0800
+++ bfd/elfxx-ia64.c	2007-12-13 16:05:46.000000000 -0800
@@ -5729,8 +5729,6 @@ elfNN_hpux_backend_symbol_processing (bf
 #undef  elf_backend_want_p_paddr_set_to_zero
 #define elf_backend_want_p_paddr_set_to_zero 1
 
-#undef  ELF_MAXPAGESIZE
-#define ELF_MAXPAGESIZE                 0x1000  /* 4K */
 #undef ELF_COMMONPAGESIZE
 #undef ELF_OSABI
 #define ELF_OSABI			ELFOSABI_HPUX


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