Preliminary support for generating shared libraries, from Eric

Youngdale <ericy@cais.cais.com>.
	* elfcode.h (prep_headers): If DYNAMIC, set e_type to ET_DYN.
	(elf_link_add_object_symbols): If generating a shared library,
	create dynamic sections for first input BFD with the right format.
	(elf_link_create_dynamic_sections): Don't create .interp section
	if creating a shared library.
	(elf_link_input_bfd): Skip dynamic sections in input file.
	(elf_bfd_final_link): If creating a shared library, it's OK for
	dynobj to have sections which are not SEC_IN_MEMORY.
	* elf32-i386.c (elf_i386_size_dynamic_sections): Only set .interp
	section if not creating a shared library.
	* elf32-sparc.c (elf_sparc_size_dynamic_sections): Likewise.
This commit is contained in:
Ian Lance Taylor
1994-06-23 21:36:03 +00:00
parent 51fc377bab
commit 8af74670df
4 changed files with 85 additions and 22 deletions

View File

@@ -472,10 +472,13 @@ elf32_sparc_size_dynamic_sections (output_bfd, info)
BFD_ASSERT (dynobj != NULL);
/* Set the contents of the .interp section to the interpreter. */
s = bfd_get_section_by_name (dynobj, ".interp");
BFD_ASSERT (s != NULL);
s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER;
s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
if (! info->shared)
{
s = bfd_get_section_by_name (dynobj, ".interp");
BFD_ASSERT (s != NULL);
s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER;
s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
}
/* Make space for the trailing nop in .plt. */
s = bfd_get_section_by_name (dynobj, ".plt");
@@ -492,10 +495,12 @@ elf32_sparc_size_dynamic_sections (output_bfd, info)
return false;
/* Add some entries to the .dynamic section. We fill in the values
later, in elf32_sparc_finish_dynamic_sections, but we must add the
entries now so that we get the correct size for the .dynamic
section. */
if (! bfd_elf32_add_dynamic_entry (info, DT_PLTGOT, 0)
later, in elf32_sparc_finish_dynamic_sections, but we must add
the entries now so that we get the correct size for the .dynamic
section. The DT_DEBUG entry is filled in by the dynamic linker
and used by the debugger. */
if (! bfd_elf32_add_dynamic_entry (info, DT_DEBUG, 0)
|| ! bfd_elf32_add_dynamic_entry (info, DT_PLTGOT, 0)
|| ! bfd_elf32_add_dynamic_entry (info, DT_PLTRELSZ, 0)
|| ! bfd_elf32_add_dynamic_entry (info, DT_PLTREL, DT_RELA)
|| ! bfd_elf32_add_dynamic_entry (info, DT_JMPREL, 0)