aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaz Kojima <kkojima@rr.iij4u.or.jp>2003-07-04 07:38:33 +0000
committerKaz Kojima <kkojima@rr.iij4u.or.jp>2003-07-04 07:38:33 +0000
commit03151a5a117d288e01d3118697154c307d407fd7 (patch)
tree204535bce5828945ff20f2c65a837b41df596590
parent2293c4998ce237a8a235fb9efb3b756c9666e0dc (diff)
downloadgdb-03151a5a117d288e01d3118697154c307d407fd7.zip
gdb-03151a5a117d288e01d3118697154c307d407fd7.tar.gz
gdb-03151a5a117d288e01d3118697154c307d407fd7.tar.bz2
* elf32-sh.c (sh_elf_create_dynamic_sections): Don't call
bfd_make_section for existing sections.
-rw-r--r--bfd/ChangeLog5
-rw-r--r--bfd/elf32-sh.c51
2 files changed, 37 insertions, 19 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index b58c7af..b497118 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,8 @@
+2003-07-04 Kaz Kojima <kkojima@rr.iij4u.or.jp>
+
+ * elf32-sh.c (sh_elf_create_dynamic_sections): Don't call
+ bfd_make_section for existing sections.
+
2003-07-04 Alan Modra <amodra@bigpond.net.au>
* elf32-sparc.c (elf32_sparc_check_relocs): Don't call
diff --git a/bfd/elf32-sh.c b/bfd/elf32-sh.c
index 0c27a75..2d1698c 100644
--- a/bfd/elf32-sh.c
+++ b/bfd/elf32-sh.c
@@ -3768,12 +3768,16 @@ sh_elf_create_dynamic_sections (abfd, info)
if (bed->plt_readonly)
pltflags |= SEC_READONLY;
- s = bfd_make_section (abfd, ".plt");
- htab->splt = s;
- if (s == NULL
- || ! bfd_set_section_flags (abfd, s, pltflags)
- || ! bfd_set_section_alignment (abfd, s, bed->plt_alignment))
- return FALSE;
+ s = htab->splt;
+ if (s == NULL)
+ {
+ s = bfd_make_section (abfd, ".plt");
+ htab->splt = s;
+ if (s == NULL
+ || ! bfd_set_section_flags (abfd, s, pltflags)
+ || ! bfd_set_section_alignment (abfd, s, bed->plt_alignment))
+ return FALSE;
+ }
if (bed->want_plt_sym)
{
@@ -3797,13 +3801,17 @@ sh_elf_create_dynamic_sections (abfd, info)
return FALSE;
}
- s = bfd_make_section (abfd,
- bed->default_use_rela_p ? ".rela.plt" : ".rel.plt");
- htab->srelplt = s;
- if (s == NULL
- || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
- || ! bfd_set_section_alignment (abfd, s, ptralign))
- return FALSE;
+ if (htab->srelplt == NULL)
+ {
+ s = bfd_make_section (abfd,
+ (bed->default_use_rela_p ?
+ ".rela.plt" : ".rel.plt"));
+ htab->srelplt = s;
+ if (s == NULL
+ || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
+ || ! bfd_set_section_alignment (abfd, s, ptralign))
+ return FALSE;
+ }
if (htab->sgot == NULL
&& !create_got_section (abfd, info))
@@ -3825,6 +3833,8 @@ sh_elf_create_dynamic_sections (abfd, info)
relname = (char *) bfd_malloc ((bfd_size_type) strlen (secname) + 6);
strcpy (relname, ".rela");
strcat (relname, secname);
+ if (bfd_get_section_by_name (abfd, secname))
+ continue;
s = bfd_make_section (abfd, relname);
if (s == NULL
|| ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
@@ -3841,11 +3851,14 @@ sh_elf_create_dynamic_sections (abfd, info)
image and use a R_*_COPY reloc to tell the dynamic linker to
initialize them at run time. The linker script puts the .dynbss
section into the .bss section of the final image. */
- s = bfd_make_section (abfd, ".dynbss");
- htab->sdynbss = s;
- if (s == NULL
- || ! bfd_set_section_flags (abfd, s, SEC_ALLOC))
- return FALSE;
+ if (htab->sdynbss == NULL)
+ {
+ s = bfd_make_section (abfd, ".dynbss");
+ htab->sdynbss = s;
+ if (s == NULL
+ || ! bfd_set_section_flags (abfd, s, SEC_ALLOC))
+ return FALSE;
+ }
/* The .rel[a].bss section holds copy relocs. This section is not
normally needed. We need to create it here, though, so that the
@@ -3858,7 +3871,7 @@ sh_elf_create_dynamic_sections (abfd, info)
be needed, we can discard it later. We will never need this
section when generating a shared object, since they do not use
copy relocs. */
- if (! info->shared)
+ if (! info->shared && htab->srelbss == NULL)
{
s = bfd_make_section (abfd,
(bed->default_use_rela_p