aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bfd/ChangeLog21
-rw-r--r--bfd/elf.c36
-rw-r--r--bfd/elf32-arm.c11
-rw-r--r--bfd/elf32-i386.c11
-rw-r--r--bfd/elf32-ppc.c11
-rw-r--r--bfd/elf32-s390.c16
-rw-r--r--bfd/elf32-sh.c11
-rw-r--r--bfd/elf64-alpha.c11
-rw-r--r--bfd/elf64-ppc.c11
-rw-r--r--bfd/elf64-s390.c16
-rw-r--r--bfd/elf64-x86-64.c11
-rw-r--r--bfd/elfxx-sparc.c11
12 files changed, 114 insertions, 63 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 8b32685..61d2d40 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,24 @@
+2006-06-23 Alan Modra <amodra@bigpond.net.au>
+
+ PR ld/2754
+ * elf.c (bfd_elf_mkobject): Don't alloc if already done. Set
+ program_header_size to -1.
+ (_bfd_elf_map_sections_to_segments): Adjust program_header_size check.
+ (assign_file_positions_for_load_sections ): Likewise.
+ (_bfd_elf_sizeof_headers): Use saved program_header_size if
+ available.
+ * elf32-arm.c (elf32_arm_mkobject): Call bfd_elf_mkobject, don't
+ alloc if already done.
+ * elf32-i386.c (elf_i386_mkobject): Likewise.
+ * elf32-ppc.c (ppc_elf_mkobject): Likewise.
+ * elf32-s390.c (elf_s390_mkobject): Likewise.
+ * elf32-sh.c (sh_elf_mkobject): Likewise.
+ * elf64-alpha.c (elf64_alpha_mkobject): Likewise.
+ * elf64-ppc.c (ppc64_elf_mkobject): Likewise.
+ * elf64-s390.c (elf_s390_mkobject): Likewise.
+ * elf64-x86-64.c (elf64_x86_64_mkobject): Likewise.
+ * elfxx-sparc.c (_bfd_sparc_elf_mkobject): Likewise.
+
2006-06-20 Jakub Jelinek <jakub@redhat.com>
* elflink.c (elf_link_add_object_symbols): Don't create .tcommon
diff --git a/bfd/elf.c b/bfd/elf.c
index 8a725c3..abb5082 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -209,13 +209,14 @@ bfd_elf_hash (const char *namearg)
bfd_boolean
bfd_elf_mkobject (bfd *abfd)
{
- /* This just does initialization. */
- /* coff_mkobject zalloc's space for tdata.coff_obj_data ... */
- elf_tdata (abfd) = bfd_zalloc (abfd, sizeof (struct elf_obj_tdata));
- if (elf_tdata (abfd) == 0)
- return FALSE;
- /* Since everything is done at close time, do we need any
- initialization? */
+ if (abfd->tdata.any == NULL)
+ {
+ abfd->tdata.any = bfd_zalloc (abfd, sizeof (struct elf_obj_tdata));
+ if (abfd->tdata.any == NULL)
+ return FALSE;
+ }
+
+ elf_tdata (abfd)->program_header_size = (bfd_size_type) -1;
return TRUE;
}
@@ -3852,7 +3853,7 @@ _bfd_elf_map_sections_to_segments (bfd *abfd, struct bfd_link_info *info)
{
bfd_size_type phdr_size = elf_tdata (abfd)->program_header_size;
- if (phdr_size == 0)
+ if (phdr_size == (bfd_size_type) -1)
phdr_size = get_program_header_size (abfd, info);
if ((abfd->flags & D_PAGED) == 0
|| sections[0]->lma < phdr_size
@@ -4227,7 +4228,7 @@ assign_file_positions_for_load_sections (bfd *abfd,
elf_elfheader (abfd)->e_phentsize = bed->s->sizeof_phdr;
elf_elfheader (abfd)->e_phnum = alloc;
- if (elf_tdata (abfd)->program_header_size == 0)
+ if (elf_tdata (abfd)->program_header_size == (bfd_size_type) -1)
elf_tdata (abfd)->program_header_size = alloc * bed->s->sizeof_phdr;
else
BFD_ASSERT (elf_tdata (abfd)->program_header_size
@@ -7063,14 +7064,19 @@ _bfd_elf_sizeof_headers (bfd *abfd, struct bfd_link_info *info)
if (!info->relocatable)
{
- struct elf_segment_map *m;
- bfd_size_type phdr_size = 0;
+ bfd_size_type phdr_size = elf_tdata (abfd)->program_header_size;
- for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next)
- phdr_size += bed->s->sizeof_phdr;
+ if (phdr_size == (bfd_size_type) -1)
+ {
+ struct elf_segment_map *m;
+
+ phdr_size = 0;
+ for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next)
+ phdr_size += bed->s->sizeof_phdr;
- if (phdr_size == 0)
- phdr_size = get_program_header_size (abfd, info);
+ if (phdr_size == 0)
+ phdr_size = get_program_header_size (abfd, info);
+ }
elf_tdata (abfd)->program_header_size = phdr_size;
ret += phdr_size;
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index 3a76135..a458d46 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -2038,11 +2038,14 @@ struct elf32_arm_obj_tdata
static bfd_boolean
elf32_arm_mkobject (bfd *abfd)
{
- bfd_size_type amt = sizeof (struct elf32_arm_obj_tdata);
- abfd->tdata.any = bfd_zalloc (abfd, amt);
if (abfd->tdata.any == NULL)
- return FALSE;
- return TRUE;
+ {
+ bfd_size_type amt = sizeof (struct elf32_arm_obj_tdata);
+ abfd->tdata.any = bfd_zalloc (abfd, amt);
+ if (abfd->tdata.any == NULL)
+ return FALSE;
+ }
+ return bfd_elf_mkobject (abfd);
}
/* The ARM linker needs to keep track of the number of relocs that it
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index 754aa52..4e9d492 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -626,11 +626,14 @@ struct elf_i386_obj_tdata
static bfd_boolean
elf_i386_mkobject (bfd *abfd)
{
- bfd_size_type amt = sizeof (struct elf_i386_obj_tdata);
- abfd->tdata.any = bfd_zalloc (abfd, amt);
if (abfd->tdata.any == NULL)
- return FALSE;
- return TRUE;
+ {
+ bfd_size_type amt = sizeof (struct elf_i386_obj_tdata);
+ abfd->tdata.any = bfd_zalloc (abfd, amt);
+ if (abfd->tdata.any == NULL)
+ return FALSE;
+ }
+ return bfd_elf_mkobject (abfd);
}
/* i386 ELF linker hash table. */
diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c
index 5d1386e..bc449b3 100644
--- a/bfd/elf32-ppc.c
+++ b/bfd/elf32-ppc.c
@@ -1708,11 +1708,14 @@ struct ppc_elf_obj_tdata
static bfd_boolean
ppc_elf_mkobject (bfd *abfd)
{
- bfd_size_type amt = sizeof (struct ppc_elf_obj_tdata);
- abfd->tdata.any = bfd_zalloc (abfd, amt);
if (abfd->tdata.any == NULL)
- return FALSE;
- return TRUE;
+ {
+ bfd_size_type amt = sizeof (struct ppc_elf_obj_tdata);
+ abfd->tdata.any = bfd_zalloc (abfd, amt);
+ if (abfd->tdata.any == NULL)
+ return FALSE;
+ }
+ return bfd_elf_mkobject (abfd);
}
/* Fix bad default arch selected for a 32 bit input bfd when the
diff --git a/bfd/elf32-s390.c b/bfd/elf32-s390.c
index 9d7004e..e2934cf 100644
--- a/bfd/elf32-s390.c
+++ b/bfd/elf32-s390.c
@@ -73,8 +73,6 @@ static enum elf_reloc_type_class elf_s390_reloc_type_class
PARAMS ((const Elf_Internal_Rela *));
static bfd_boolean elf_s390_finish_dynamic_sections
PARAMS ((bfd *, struct bfd_link_info *));
-static bfd_boolean elf_s390_mkobject
- PARAMS ((bfd *));
static bfd_boolean elf_s390_object_p
PARAMS ((bfd *));
static bfd_boolean elf_s390_grok_prstatus
@@ -678,14 +676,16 @@ struct elf_s390_obj_tdata
(elf_s390_tdata (abfd)->local_got_tls_type)
static bfd_boolean
-elf_s390_mkobject (abfd)
- bfd *abfd;
+elf_s390_mkobject (bfd *abfd)
{
- bfd_size_type amt = sizeof (struct elf_s390_obj_tdata);
- abfd->tdata.any = bfd_zalloc (abfd, amt);
if (abfd->tdata.any == NULL)
- return FALSE;
- return TRUE;
+ {
+ bfd_size_type amt = sizeof (struct elf_s390_obj_tdata);
+ abfd->tdata.any = bfd_zalloc (abfd, amt);
+ if (abfd->tdata.any == NULL)
+ return FALSE;
+ }
+ return bfd_elf_mkobject (abfd);
}
static bfd_boolean
diff --git a/bfd/elf32-sh.c b/bfd/elf32-sh.c
index cf59095..b229b5e 100644
--- a/bfd/elf32-sh.c
+++ b/bfd/elf32-sh.c
@@ -3518,11 +3518,14 @@ struct sh_elf_obj_tdata
static bfd_boolean
sh_elf_mkobject (bfd *abfd)
{
- bfd_size_type amt = sizeof (struct sh_elf_obj_tdata);
- abfd->tdata.any = bfd_zalloc (abfd, amt);
if (abfd->tdata.any == NULL)
- return FALSE;
- return TRUE;
+ {
+ bfd_size_type amt = sizeof (struct sh_elf_obj_tdata);
+ abfd->tdata.any = bfd_zalloc (abfd, amt);
+ if (abfd->tdata.any == NULL)
+ return FALSE;
+ }
+ return bfd_elf_mkobject (abfd);
}
/* sh ELF linker hash table. */
diff --git a/bfd/elf64-alpha.c b/bfd/elf64-alpha.c
index 625d834..0823f5c 100644
--- a/bfd/elf64-alpha.c
+++ b/bfd/elf64-alpha.c
@@ -321,11 +321,14 @@ struct alpha_elf_obj_tdata
static bfd_boolean
elf64_alpha_mkobject (bfd *abfd)
{
- bfd_size_type amt = sizeof (struct alpha_elf_obj_tdata);
- abfd->tdata.any = bfd_zalloc (abfd, amt);
if (abfd->tdata.any == NULL)
- return FALSE;
- return TRUE;
+ {
+ bfd_size_type amt = sizeof (struct alpha_elf_obj_tdata);
+ abfd->tdata.any = bfd_zalloc (abfd, amt);
+ if (abfd->tdata.any == NULL)
+ return FALSE;
+ }
+ return bfd_elf_mkobject (abfd);
}
static bfd_boolean
diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c
index 2c29b57..b5b5fbe 100644
--- a/bfd/elf64-ppc.c
+++ b/bfd/elf64-ppc.c
@@ -2408,11 +2408,14 @@ struct ppc64_elf_obj_tdata
static bfd_boolean
ppc64_elf_mkobject (bfd *abfd)
{
- bfd_size_type amt = sizeof (struct ppc64_elf_obj_tdata);
- abfd->tdata.any = bfd_zalloc (abfd, amt);
if (abfd->tdata.any == NULL)
- return FALSE;
- return TRUE;
+ {
+ bfd_size_type amt = sizeof (struct ppc64_elf_obj_tdata);
+ abfd->tdata.any = bfd_zalloc (abfd, amt);
+ if (abfd->tdata.any == NULL)
+ return FALSE;
+ }
+ return bfd_elf_mkobject (abfd);
}
/* Return 1 if target is one of ours. */
diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c
index bb20397..72d8432 100644
--- a/bfd/elf64-s390.c
+++ b/bfd/elf64-s390.c
@@ -73,8 +73,6 @@ static enum elf_reloc_type_class elf_s390_reloc_type_class
PARAMS ((const Elf_Internal_Rela *));
static bfd_boolean elf_s390_finish_dynamic_sections
PARAMS ((bfd *, struct bfd_link_info *));
-static bfd_boolean elf_s390_mkobject
- PARAMS ((bfd *));
static bfd_boolean elf_s390_object_p
PARAMS ((bfd *));
static int elf_s390_tls_transition
@@ -631,14 +629,16 @@ struct elf_s390_obj_tdata
(elf_s390_tdata (abfd)->local_got_tls_type)
static bfd_boolean
-elf_s390_mkobject (abfd)
- bfd *abfd;
+elf_s390_mkobject (bfd *abfd)
{
- bfd_size_type amt = sizeof (struct elf_s390_obj_tdata);
- abfd->tdata.any = bfd_zalloc (abfd, amt);
if (abfd->tdata.any == NULL)
- return FALSE;
- return TRUE;
+ {
+ bfd_size_type amt = sizeof (struct elf_s390_obj_tdata);
+ abfd->tdata.any = bfd_zalloc (abfd, amt);
+ if (abfd->tdata.any == NULL)
+ return FALSE;
+ }
+ return bfd_elf_mkobject (abfd);
}
static bfd_boolean
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index 5a3f36b..c72a994 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -676,11 +676,14 @@ elf64_x86_64_copy_indirect_symbol (struct bfd_link_info *info,
static bfd_boolean
elf64_x86_64_mkobject (bfd *abfd)
{
- bfd_size_type amt = sizeof (struct elf64_x86_64_obj_tdata);
- abfd->tdata.any = bfd_zalloc (abfd, amt);
if (abfd->tdata.any == NULL)
- return FALSE;
- return TRUE;
+ {
+ bfd_size_type amt = sizeof (struct elf64_x86_64_obj_tdata);
+ abfd->tdata.any = bfd_zalloc (abfd, amt);
+ if (abfd->tdata.any == NULL)
+ return FALSE;
+ }
+ return bfd_elf_mkobject (abfd);
}
static bfd_boolean
diff --git a/bfd/elfxx-sparc.c b/bfd/elfxx-sparc.c
index 73e8eb2..6da70a3 100644
--- a/bfd/elfxx-sparc.c
+++ b/bfd/elfxx-sparc.c
@@ -487,11 +487,14 @@ struct _bfd_sparc_elf_obj_tdata
bfd_boolean
_bfd_sparc_elf_mkobject (bfd *abfd)
{
- bfd_size_type amt = sizeof (struct _bfd_sparc_elf_obj_tdata);
- abfd->tdata.any = bfd_zalloc (abfd, amt);
if (abfd->tdata.any == NULL)
- return FALSE;
- return TRUE;
+ {
+ bfd_size_type amt = sizeof (struct _bfd_sparc_elf_obj_tdata);
+ abfd->tdata.any = bfd_zalloc (abfd, amt);
+ if (abfd->tdata.any == NULL)
+ return FALSE;
+ }
+ return bfd_elf_mkobject (abfd);
}
static void