* elfcode.h (elf_object_p): If there is a SHT_DYNAMIC section, set

the DYNAMIC flag for the BFD.
	(NAME(bfd_elf,write_object_contents)): Don't try to write out a
	BFD with the DYNAMIC flag set, since we don't generate the program
	header table correctly.
This commit is contained in:
Ian Lance Taylor
1994-01-14 22:35:41 +00:00
parent 46050fe4d0
commit 38a5f510bc
2 changed files with 30 additions and 6 deletions

@ -1,3 +1,16 @@
Fri Jan 14 16:45:43 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
* elfcode.h (elf_object_p): If there is a SHT_DYNAMIC section, set
the DYNAMIC flag for the BFD.
(NAME(bfd_elf,write_object_contents)): Don't try to write out a
BFD with the DYNAMIC flag set, since we don't generate the program
header table correctly.
Fri Jan 14 01:04:36 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
* elfcode.h (elf_slurp_symbol_table): Free x_symp at the end
of the function to avoid storage leak.
Thu Jan 13 23:07:32 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) Thu Jan 13 23:07:32 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
* ecoff.c (ecoff_link_write_external): An ifd can be -1. * ecoff.c (ecoff_link_write_external): An ifd can be -1.

@ -951,6 +951,11 @@ DEFUN (elf_object_p, (abfd), bfd * abfd)
goto got_system_call_error; goto got_system_call_error;
elf_swap_shdr_in (abfd, &x_shdr, i_shdrp + shindex); elf_swap_shdr_in (abfd, &x_shdr, i_shdrp + shindex);
elf_elfsections(abfd)[shindex] = i_shdrp + shindex; elf_elfsections(abfd)[shindex] = i_shdrp + shindex;
/* If this is a .dynamic section, mark the object file as being
dynamically linked. */
if (i_shdrp[shindex].sh_type == SHT_DYNAMIC)
abfd->flags |= DYNAMIC;
} }
if (i_ehdrp->e_shstrndx) if (i_ehdrp->e_shstrndx)
{ {
@ -1123,7 +1128,7 @@ write_relocs (abfd, sec, xxx)
int idx; int idx;
int use_rela_p = get_elf_backend_data (abfd)->use_rela_p; int use_rela_p = get_elf_backend_data (abfd)->use_rela_p;
asymbol *last_sym = 0; asymbol *last_sym = 0;
int last_sym_idx; int last_sym_idx = 9999999; /* should always be written before use */
if ((sec->flags & SEC_RELOC) == 0) if ((sec->flags & SEC_RELOC) == 0)
return; return;
@ -2125,7 +2130,7 @@ swap_out_syms (abfd)
} }
if (bfd_is_com_section (syms[idx]->section)) if (bfd_is_com_section (syms[idx]->section))
sym.st_info = ELF_ST_INFO (STB_GLOBAL, STT_NOTYPE); sym.st_info = ELF_ST_INFO (STB_GLOBAL, STT_OBJECT);
else if (syms[idx]->section == &bfd_und_section) else if (syms[idx]->section == &bfd_und_section)
sym.st_info = ELF_ST_INFO (STB_GLOBAL, STT_NOTYPE); sym.st_info = ELF_ST_INFO (STB_GLOBAL, STT_NOTYPE);
else if (syms[idx]->flags & BSF_SECTION_SYM) else if (syms[idx]->flags & BSF_SECTION_SYM)
@ -2262,6 +2267,15 @@ DEFUN (NAME(bfd_elf,write_object_contents), (abfd), bfd * abfd)
Elf_Internal_Shdr **i_shdrp; Elf_Internal_Shdr **i_shdrp;
int count; int count;
/* We don't know how to write dynamic objects. Specifically, we
don't know how to construct the program header. */
if ((abfd->flags & DYNAMIC) != 0)
{
fprintf (stderr, "Writing ELF dynamic objects is not supported\n");
bfd_error = wrong_format;
return false;
}
if (abfd->output_has_begun == false) if (abfd->output_has_begun == false)
{ {
prep_headers (abfd); prep_headers (abfd);
@ -2473,10 +2487,6 @@ DEFUN (elf_slurp_symbol_table, (abfd, symptrs),
to be prepared to read both (and merge them) or ensure that we to be prepared to read both (and merge them) or ensure that we
only read the full symbol table. Currently we only get called to only read the full symbol table. Currently we only get called to
read the full symbol table. -fnf */ read the full symbol table. -fnf */
if (bfd_get_outsymbols (abfd) != NULL)
{
return true;
}
/* Read each raw ELF symbol, converting from external ELF form to /* Read each raw ELF symbol, converting from external ELF form to
internal ELF form, and then using the information to create a internal ELF form, and then using the information to create a
@ -2608,6 +2618,7 @@ DEFUN (elf_slurp_symbol_table, (abfd, symptrs),
*symptrs = 0; /* Final null pointer */ *symptrs = 0; /* Final null pointer */
} }
free ((PTR) x_symp);
return true; return true;
} }