* elfcode.h (bfd_section_from_shdr): Remove duplicate assignment

to filepos in SHT_STRTAB case.
	(assign_file_position_for_section): Set BFD section filepos as
	well as ELF section sh_offset.
This commit is contained in:
Ian Lance Taylor
1993-11-08 23:33:56 +00:00
parent e2756048da
commit 7b8106b484
2 changed files with 56 additions and 32 deletions

View File

@ -1,5 +1,10 @@
Mon Nov 8 18:13:14 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) Mon Nov 8 18:13:14 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
* elfcode.h (bfd_section_from_shdr): Remove duplicate assignment
to filepos in SHT_STRTAB case.
(assign_file_position_for_section): Set BFD section filepos as
well as ELF section sh_offset.
* reloc.c: Use const instead of CONST. * reloc.c: Use const instead of CONST.
(bfd_perform_relocation): Make variable howto a const pointer. (bfd_perform_relocation): Make variable howto a const pointer.
* bfd-in2.h, libbfd.h: Rebuilt. * bfd-in2.h, libbfd.h: Rebuilt.

View File

@ -584,7 +584,6 @@ DEFUN (bfd_section_from_shdr, (abfd, shindex),
newsect = bfd_make_section (abfd, name); newsect = bfd_make_section (abfd, name);
if (newsect) if (newsect)
{ {
newsect->filepos = hdr->sh_offset; /* so we can read back the bits */
newsect->flags = SEC_HAS_CONTENTS; newsect->flags = SEC_HAS_CONTENTS;
hdr->rawdata = (PTR) newsect; hdr->rawdata = (PTR) newsect;
newsect->_raw_size = hdr->sh_size; newsect->_raw_size = hdr->sh_size;
@ -878,8 +877,10 @@ DEFUN (elf_object_p, (abfd), bfd * abfd)
if (i_ehdrp->e_shoff == 0) if (i_ehdrp->e_shoff == 0)
goto got_wrong_format_error; goto got_wrong_format_error;
if (i_ehdrp->e_type == ET_EXEC || i_ehdrp->e_type == ET_DYN) if (i_ehdrp->e_type == ET_EXEC)
abfd->flags |= EXEC_P; abfd->flags |= EXEC_P;
else if (i_ehdrp->e_type == ET_DYN)
abfd->flags |= DYNAMIC;
/* Retrieve the architecture information from the xvec and verify /* Retrieve the architecture information from the xvec and verify
that it matches the machine info stored in the ELF header. that it matches the machine info stored in the ELF header.
@ -1567,6 +1568,8 @@ assign_file_position_for_section (i_shdrp, offset)
else else
align = 1; align = 1;
i_shdrp->sh_offset = offset = BFD_ALIGN (offset, align); i_shdrp->sh_offset = offset = BFD_ALIGN (offset, align);
if (i_shdrp->rawdata != NULL)
((asection *) i_shdrp->rawdata)->filepos = offset;
if (i_shdrp->sh_type != SHT_NOBITS) if (i_shdrp->sh_type != SHT_NOBITS)
offset += i_shdrp->sh_size; offset += i_shdrp->sh_size;
return offset; return offset;
@ -2659,13 +2662,21 @@ DEFUN (elf_slurp_reloca_table, (abfd, asect, symbols),
/* non-relocatable, so the offset a virtual address */ /* non-relocatable, so the offset a virtual address */
cache_ptr->address = dst.r_offset; cache_ptr->address = dst.r_offset;
} }
/* ELF_R_SYM(dst.r_info) is the symbol table offset; subtract 1
because the first entry is NULL. */ /* ELF_R_SYM(dst.r_info) is the symbol table offset. An offset
cache_ptr->sym_ptr_ptr = symbols + ELF_R_SYM (dst.r_info) - 1; of zero points to the dummy symbol, which was not read into
the symbol table SYMBOLS. */
if (ELF_R_SYM (dst.r_info) == 0)
cache_ptr->sym_ptr_ptr = bfd_abs_section.symbol_ptr_ptr;
else
{ {
/* Is it an ELF section symbol? If so, translate it into a asymbol *s;
BFD section symbol. */
asymbol *s = *(cache_ptr->sym_ptr_ptr); cache_ptr->sym_ptr_ptr = symbols + ELF_R_SYM (dst.r_info) - 1;
/* Translate any ELF section symbol into a BFD section
symbol. */
s = *(cache_ptr->sym_ptr_ptr);
if (s->flags & BSF_SECTION_SYM) if (s->flags & BSF_SECTION_SYM)
{ {
cache_ptr->sym_ptr_ptr = s->section->symbol_ptr_ptr; cache_ptr->sym_ptr_ptr = s->section->symbol_ptr_ptr;
@ -2811,13 +2822,21 @@ DEFUN (elf_slurp_reloc_table, (abfd, asect, symbols),
/* non-relocatable, so the offset a virtual address */ /* non-relocatable, so the offset a virtual address */
cache_ptr->address = dst.r_offset; cache_ptr->address = dst.r_offset;
} }
/* ELF_R_SYM(dst.r_info) is the symbol table offset...
-1 is to skip the dummy symbol table entry */ /* ELF_R_SYM(dst.r_info) is the symbol table offset. An offset
cache_ptr->sym_ptr_ptr = symbols + ELF_R_SYM (dst.r_info) - 1; of zero points to the dummy symbol, which was not read into
the symbol table SYMBOLS. */
if (ELF_R_SYM (dst.r_info) == 0)
cache_ptr->sym_ptr_ptr = bfd_abs_section.symbol_ptr_ptr;
else
{ {
/* Is it an ELF section symbol? If so, translate it into a asymbol *s;
BFD section symbol. */
asymbol *s = *(cache_ptr->sym_ptr_ptr); cache_ptr->sym_ptr_ptr = symbols + ELF_R_SYM (dst.r_info) - 1;
/* Translate any ELF section symbol into a BFD section
symbol. */
s = *(cache_ptr->sym_ptr_ptr);
if (s->flags & BSF_SECTION_SYM) if (s->flags & BSF_SECTION_SYM)
{ {
cache_ptr->sym_ptr_ptr = s->section->symbol_ptr_ptr; cache_ptr->sym_ptr_ptr = s->section->symbol_ptr_ptr;