1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
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.
--- binutils-2.18/bfd/elf.c.zero 2007-12-17 10:58:04.761792000 +0100
+++ binutils-2.18/bfd/elf.c 2007-12-17 11:49:16.381795000 +0100
@@ -5272,9 +5272,13 @@
matching_lma = 0;
suggested_lma = 0;
- 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))
{
@@ -5319,6 +5323,9 @@
else if (suggested_lma == 0)
suggested_lma = output_section->lma;
}
+
+ if (j == section_count)
+ break;
}
BFD_ASSERT (j == section_count);
@@ -5335,7 +5342,8 @@
*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
@@ -5675,6 +5683,13 @@
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;
--- binutils-2.18/bfd/elfcode.h.zero 2007-10-30 11:48:34.000000000 -0700
+++ binutils-2.18/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);
--- binutils-2.18/bfd/elfxx-ia64.c.zero 2007-12-14 08:46:35.000000000 -0800
+++ binutils-2.18/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
|