* elf32-sh.c (sh_elf_create_dynamic_sections): Don't call

bfd_make_section for existing sections.
This commit is contained in:
Kaz Kojima
2003-07-04 07:38:33 +00:00
parent 2293c4998c
commit 03151a5a11
2 changed files with 37 additions and 19 deletions

View File

@ -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> 2003-07-04 Alan Modra <amodra@bigpond.net.au>
* elf32-sparc.c (elf32_sparc_check_relocs): Don't call * elf32-sparc.c (elf32_sparc_check_relocs): Don't call

View File

@ -3768,12 +3768,16 @@ sh_elf_create_dynamic_sections (abfd, info)
if (bed->plt_readonly) if (bed->plt_readonly)
pltflags |= SEC_READONLY; pltflags |= SEC_READONLY;
s = bfd_make_section (abfd, ".plt"); s = htab->splt;
htab->splt = s; if (s == NULL)
if (s == NULL {
|| ! bfd_set_section_flags (abfd, s, pltflags) s = bfd_make_section (abfd, ".plt");
|| ! bfd_set_section_alignment (abfd, s, bed->plt_alignment)) htab->splt = s;
return FALSE; 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) if (bed->want_plt_sym)
{ {
@ -3797,13 +3801,17 @@ sh_elf_create_dynamic_sections (abfd, info)
return FALSE; return FALSE;
} }
s = bfd_make_section (abfd, if (htab->srelplt == NULL)
bed->default_use_rela_p ? ".rela.plt" : ".rel.plt"); {
htab->srelplt = s; s = bfd_make_section (abfd,
if (s == NULL (bed->default_use_rela_p ?
|| ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY) ".rela.plt" : ".rel.plt"));
|| ! bfd_set_section_alignment (abfd, s, ptralign)) htab->srelplt = s;
return FALSE; 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 if (htab->sgot == NULL
&& !create_got_section (abfd, info)) && !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); relname = (char *) bfd_malloc ((bfd_size_type) strlen (secname) + 6);
strcpy (relname, ".rela"); strcpy (relname, ".rela");
strcat (relname, secname); strcat (relname, secname);
if (bfd_get_section_by_name (abfd, secname))
continue;
s = bfd_make_section (abfd, relname); s = bfd_make_section (abfd, relname);
if (s == NULL if (s == NULL
|| ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY) || ! 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 image and use a R_*_COPY reloc to tell the dynamic linker to
initialize them at run time. The linker script puts the .dynbss initialize them at run time. The linker script puts the .dynbss
section into the .bss section of the final image. */ section into the .bss section of the final image. */
s = bfd_make_section (abfd, ".dynbss"); if (htab->sdynbss == NULL)
htab->sdynbss = s; {
if (s == NULL s = bfd_make_section (abfd, ".dynbss");
|| ! bfd_set_section_flags (abfd, s, SEC_ALLOC)) htab->sdynbss = s;
return FALSE; 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 /* The .rel[a].bss section holds copy relocs. This section is not
normally needed. We need to create it here, though, so that the 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 be needed, we can discard it later. We will never need this
section when generating a shared object, since they do not use section when generating a shared object, since they do not use
copy relocs. */ copy relocs. */
if (! info->shared) if (! info->shared && htab->srelbss == NULL)
{ {
s = bfd_make_section (abfd, s = bfd_make_section (abfd,
(bed->default_use_rela_p (bed->default_use_rela_p