From: H.J. Lu Date: Mon, 24 Dec 2007 16:55:39 +0000 (+0000) Subject: 2007-12-24 H.J. Lu X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=147d51c2327f0f36ddab7e2766087a902f8d83c1;p=binutils-gdb.git 2007-12-24 H.J. Lu 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. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index bd611041f88..8ebd721a2df 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,15 @@ +2007-12-24 H.J. Lu + + 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. + 2007-12-21 Bob Wilson * elf32-xtensa.c (relax_section): Update DIFF relocations in the diff --git a/bfd/elf.c b/bfd/elf.c index f0b2e4d9fa1..a4607e50fb9 100644 --- a/bfd/elf.c +++ b/bfd/elf.c @@ -5392,9 +5392,13 @@ rewrite_elf_program_header (bfd *ibfd, bfd *obfd) 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)) { @@ -5444,6 +5448,9 @@ rewrite_elf_program_header (bfd *ibfd, bfd *obfd) suggested_lma = output_section->lma; first_suggested_lma = FALSE; } + + if (j == section_count) + break; } } @@ -5461,7 +5468,8 @@ rewrite_elf_program_header (bfd *ibfd, bfd *obfd) *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 @@ -5815,6 +5823,13 @@ copy_private_bfd_data (bfd *ibfd, bfd *obfd) 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; diff --git a/bfd/elfcode.h b/bfd/elfcode.h index ea2a6d3dada..969c25aa0cb 100644 --- a/bfd/elfcode.h +++ b/bfd/elfcode.h @@ -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); diff --git a/bfd/elfxx-ia64.c b/bfd/elfxx-ia64.c index 0c975c551c6..5aa1a0ab391 100644 --- a/bfd/elfxx-ia64.c +++ b/bfd/elfxx-ia64.c @@ -5715,8 +5715,6 @@ elfNN_hpux_backend_symbol_processing (bfd *abfd ATTRIBUTE_UNUSED, #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