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: PATCH: PR binutils/5449: strip/objcopy doesn't work on ia64/hpux


On Thu, Dec 13, 2007 at 04:33:50PM -0800, H.J. Lu wrote:
> 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.
> ---

Here is the updated patch without the SHT_IA_64_UNWIND/SHF_LINK_ORDER
change. I will deal with it later. Apparently, when fixing

http://sourceware.org/ml/binutils/2002-07/msg00589.html

we didn't really set p_paddr to 0 in output. This patch also fixes
it. Nick, Steve, Reva, what do you think?

Thanks.


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

	PR binutils/5449
	* elf.c (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.

	* elfcode.h (elf_swap_phdr_out): Set p_paddr to 0 if needed.

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

--- bfd/elf.c.zero	2007-12-14 08:46:34.000000000 -0800
+++ bfd/elf.c	2007-12-14 08:46:35.000000000 -0800
@@ -5495,9 +5495,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 +5551,9 @@ rewrite_elf_program_header (bfd *ibfd, b
 		  suggested_lma = output_section->lma;
 		  first_suggested_lma = FALSE;
 		}
+
+	      if (j == section_count)
+		break;
 	    }
 	}
 
@@ -5564,7 +5571,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 +5926,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/elfcode.h.zero	2007-10-30 11:48:34.000000000 -0700
+++ bfd/elfcode.h	2007-12-14 10:49:00.000000000 -0800
@@ -370,11 +370,17 @@ elf_swap_phdr_out (bfd *abfd,
 		   const Elf_Internal_Phdr *src,
 		   Elf_External_Phdr *dst)
 {
+  const struct elf_backend_data *bed;
+  bfd_vma p_paddr;
+
+  bed = get_elf_backend_data (abfd);
+  p_paddr = bed->want_p_paddr_set_to_zero ? 0 : src->p_paddr;
+
   /* note that all elements of dst are *arrays of unsigned char* already...  */
   H_PUT_32 (abfd, src->p_type, dst->p_type);
   H_PUT_WORD (abfd, src->p_offset, dst->p_offset);
   H_PUT_WORD (abfd, src->p_vaddr, dst->p_vaddr);
-  H_PUT_WORD (abfd, src->p_paddr, dst->p_paddr);
+  H_PUT_WORD (abfd, p_paddr, dst->p_paddr);
   H_PUT_WORD (abfd, src->p_filesz, dst->p_filesz);
   H_PUT_WORD (abfd, src->p_memsz, dst->p_memsz);
   H_PUT_32 (abfd, src->p_flags, dst->p_flags);
--- bfd/elfxx-ia64.c.zero	2007-12-14 08:46:35.000000000 -0800
+++ bfd/elfxx-ia64.c	2007-12-14 08:46:35.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]