* elf-eh-frame.c (_bfd_elf_discard_section_eh_frame): Don't zero

relocs for discarded FDEs.  Remove dead code.
	(_bfd_elf_write_section_eh_frame_hdr): Remove dead code.
	* elflink.h (elf_bfd_discard_info): Don't save edited relocs.
	Tidy conditions under which stabs are edited.  Formatting.
	* elf64-sparc.c (sparc64_elf_relocate_section): Ignore overflows
	from discarded relocs.
	* elfxx-ia64.c (elfNN_ia64_install_dyn_reloc): Add reloc output
	section adjustments after testing magic values.
This commit is contained in:
Alan Modra 2002-11-12 06:21:05 +00:00
parent 852f55ac64
commit 99eb2ac83d
5 changed files with 64 additions and 70 deletions

View file

@ -1,3 +1,15 @@
2002-11-12 Alan Modra <amodra@bigpond.net.au>
* elf-eh-frame.c (_bfd_elf_discard_section_eh_frame): Don't zero
relocs for discarded FDEs. Remove dead code.
(_bfd_elf_write_section_eh_frame_hdr): Remove dead code.
* elflink.h (elf_bfd_discard_info): Don't save edited relocs.
Tidy conditions under which stabs are edited. Formatting.
* elf64-sparc.c (sparc64_elf_relocate_section): Ignore overflows
from discarded relocs.
* elfxx-ia64.c (elfNN_ia64_install_dyn_reloc): Add reloc output
section adjustments after testing magic values.
2002-11-12 Thomas Moestl <tmm@FreeBSD.org> 2002-11-12 Thomas Moestl <tmm@FreeBSD.org>
* elf64-sparc.c (sparc64_elf_adjust_dynamic_symbol): Correct * elf64-sparc.c (sparc64_elf_adjust_dynamic_symbol): Correct

View file

@ -299,7 +299,6 @@ _bfd_elf_discard_section_eh_frame (abfd, info, sec, ehdrsec,
unsigned int leb128_tmp; unsigned int leb128_tmp;
unsigned int cie_usage_count, last_cie_ndx, i, offset; unsigned int cie_usage_count, last_cie_ndx, i, offset;
unsigned int make_relative, make_lsda_relative; unsigned int make_relative, make_lsda_relative;
Elf_Internal_Rela *rel;
bfd_size_type new_size; bfd_size_type new_size;
unsigned int ptr_size; unsigned int ptr_size;
@ -555,10 +554,9 @@ _bfd_elf_discard_section_eh_frame (abfd, info, sec, ehdrsec,
+ ((buf - ehbuf + per_width - 1) + ((buf - ehbuf + per_width - 1)
& ~((bfd_size_type) per_width - 1))); & ~((bfd_size_type) per_width - 1)));
ENSURE_NO_RELOCS (buf); ENSURE_NO_RELOCS (buf);
rel = GET_RELOC (buf);
/* Ensure we have a reloc here, against /* Ensure we have a reloc here, against
a global symbol. */ a global symbol. */
if (rel != NULL) if (GET_RELOC (buf) != NULL)
{ {
unsigned long r_symndx; unsigned long r_symndx;
@ -626,8 +624,7 @@ _bfd_elf_discard_section_eh_frame (abfd, info, sec, ehdrsec,
goto free_no_table; goto free_no_table;
ENSURE_NO_RELOCS (buf); ENSURE_NO_RELOCS (buf);
rel = GET_RELOC (buf); if (GET_RELOC (buf) == NULL)
if (rel == NULL)
/* This should not happen. */ /* This should not happen. */
goto free_no_table; goto free_no_table;
if ((*reloc_symbol_deleted_p) (buf - ehbuf, cookie)) if ((*reloc_symbol_deleted_p) (buf - ehbuf, cookie))
@ -636,7 +633,6 @@ _bfd_elf_discard_section_eh_frame (abfd, info, sec, ehdrsec,
be deleted. */ be deleted. */
new_size -= hdr.length + 4; new_size -= hdr.length + 4;
sec_info->entry[sec_info->count].removed = 1; sec_info->entry[sec_info->count].removed = 1;
memset (rel, 0, sizeof (*rel));
} }
else else
{ {
@ -654,7 +650,6 @@ _bfd_elf_discard_section_eh_frame (abfd, info, sec, ehdrsec,
cie_usage_count++; cie_usage_count++;
hdr_info->fde_count++; hdr_info->fde_count++;
} }
cookie->rel = rel;
if (cie.lsda_encoding != DW_EH_PE_omit) if (cie.lsda_encoding != DW_EH_PE_omit)
{ {
unsigned int dummy; unsigned int dummy;
@ -751,10 +746,6 @@ _bfd_elf_discard_section_eh_frame_hdr (abfd, info, sec)
asection *sec; asection *sec;
{ {
struct eh_frame_hdr_info *hdr_info; struct eh_frame_hdr_info *hdr_info;
unsigned int ptr_size;
ptr_size = (elf_elfheader (abfd)->e_ident[EI_CLASS]
== ELFCLASS64) ? 8 : 4;
if ((elf_section_data (sec)->sec_info_type if ((elf_section_data (sec)->sec_info_type
!= ELF_INFO_TYPE_EH_FRAME_HDR) != ELF_INFO_TYPE_EH_FRAME_HDR)
@ -1179,14 +1170,10 @@ _bfd_elf_write_section_eh_frame_hdr (abfd, sec)
asection *sec; asection *sec;
{ {
struct eh_frame_hdr_info *hdr_info; struct eh_frame_hdr_info *hdr_info;
unsigned int ptr_size;
bfd_byte *contents; bfd_byte *contents;
asection *eh_frame_sec; asection *eh_frame_sec;
bfd_size_type size; bfd_size_type size;
ptr_size = (elf_elfheader (sec->owner)->e_ident[EI_CLASS]
== ELFCLASS64) ? 8 : 4;
BFD_ASSERT (elf_section_data (sec)->sec_info_type BFD_ASSERT (elf_section_data (sec)->sec_info_type
== ELF_INFO_TYPE_EH_FRAME_HDR); == ELF_INFO_TYPE_EH_FRAME_HDR);
hdr_info = (struct eh_frame_hdr_info *) hdr_info = (struct eh_frame_hdr_info *)

View file

@ -2584,11 +2584,10 @@ sparc64_elf_relocate_section (output_bfd, info, input_bfd, input_section,
/* The Solaris native linker silently disregards /* The Solaris native linker silently disregards
overflows. We don't, but this breaks stabs debugging overflows. We don't, but this breaks stabs debugging
info, whose relocations are only 32-bits wide. Ignore info, whose relocations are only 32-bits wide. Ignore
overflows in this case. */ overflows for discarded entries. */
if (r_type == R_SPARC_32 if (r_type == R_SPARC_32
&& (input_section->flags & SEC_DEBUGGING) != 0 && _bfd_elf_section_offset (output_bfd, info, input_section,
&& strcmp (bfd_section_name (input_bfd, input_section), rel->r_offset) == (bfd_vma) -1)
".stab") == 0)
break; break;
if (h != NULL) if (h != NULL)

View file

@ -8413,8 +8413,8 @@ elf_bfd_discard_info (output_bfd, info)
Elf_Internal_Shdr *symtab_hdr; Elf_Internal_Shdr *symtab_hdr;
struct elf_backend_data *bed; struct elf_backend_data *bed;
bfd *abfd; bfd *abfd;
unsigned int count;
boolean ret = false; boolean ret = false;
boolean strip = info->strip == strip_all || info->strip == strip_debugger;
if (info->relocateable if (info->relocateable
|| info->traditional_format || info->traditional_format
@ -8438,26 +8438,25 @@ elf_bfd_discard_info (output_bfd, info)
continue; continue;
eh = NULL; eh = NULL;
if (ehdr) if (ehdr != NULL)
{ {
eh = bfd_get_section_by_name (abfd, ".eh_frame"); eh = bfd_get_section_by_name (abfd, ".eh_frame");
if (eh && (eh->_raw_size == 0 if (eh != NULL
|| bfd_is_abs_section (eh->output_section))) && (eh->_raw_size == 0
|| bfd_is_abs_section (eh->output_section)))
eh = NULL; eh = NULL;
} }
stab = NULL; stab = bfd_get_section_by_name (abfd, ".stab");
if (!strip) if (stab != NULL
{ && (stab->_raw_size == 0
stab = bfd_get_section_by_name (abfd, ".stab"); || bfd_is_abs_section (stab->output_section)
if (stab && (stab->_raw_size == 0 || elf_section_data (stab)->sec_info_type != ELF_INFO_TYPE_STABS))
|| bfd_is_abs_section (stab->output_section))) stab = NULL;
stab = NULL;
} if (stab == NULL
if ((! stab && eh == NULL
|| elf_section_data(stab)->sec_info_type != ELF_INFO_TYPE_STABS) && bed->elf_backend_discard_info == NULL)
&& ! eh
&& (strip || ! bed->elf_backend_discard_info))
continue; continue;
symtab_hdr = &elf_tdata (abfd)->symtab_hdr; symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
@ -8466,8 +8465,7 @@ elf_bfd_discard_info (output_bfd, info)
cookie.bad_symtab = elf_bad_symtab (abfd); cookie.bad_symtab = elf_bad_symtab (abfd);
if (cookie.bad_symtab) if (cookie.bad_symtab)
{ {
cookie.locsymcount = cookie.locsymcount = symtab_hdr->sh_size / sizeof (Elf_External_Sym);
symtab_hdr->sh_size / sizeof (Elf_External_Sym);
cookie.extsymoff = 0; cookie.extsymoff = 0;
} }
else else
@ -8486,16 +8484,19 @@ elf_bfd_discard_info (output_bfd, info)
return false; return false;
} }
if (stab) if (stab != NULL)
{ {
cookie.rels = (NAME(_bfd_elf,link_read_relocs) cookie.rels = NULL;
(abfd, stab, (PTR) NULL, (Elf_Internal_Rela *) NULL, count = stab->reloc_count;
info->keep_memory)); if (count != 0)
if (cookie.rels) cookie.rels = (NAME(_bfd_elf,link_read_relocs)
(abfd, stab, (PTR) NULL, (Elf_Internal_Rela *) NULL,
info->keep_memory));
if (cookie.rels != NULL)
{ {
cookie.rel = cookie.rels; cookie.rel = cookie.rels;
cookie.relend = cookie.relend = cookie.rels;
cookie.rels + stab->reloc_count * bed->s->int_rels_per_ext_rel; cookie.relend += count * bed->s->int_rels_per_ext_rel;
if (_bfd_discard_section_stabs (abfd, stab, if (_bfd_discard_section_stabs (abfd, stab,
elf_section_data (stab)->sec_info, elf_section_data (stab)->sec_info,
elf_reloc_symbol_deleted_p, elf_reloc_symbol_deleted_p,
@ -8506,39 +8507,32 @@ elf_bfd_discard_info (output_bfd, info)
} }
} }
if (eh) if (eh != NULL)
{ {
cookie.rels = NULL; cookie.rels = NULL;
cookie.rel = NULL; count = eh->reloc_count;
cookie.relend = NULL; if (count != 0)
if (eh->reloc_count)
cookie.rels = (NAME(_bfd_elf,link_read_relocs) cookie.rels = (NAME(_bfd_elf,link_read_relocs)
(abfd, eh, (PTR) NULL, (Elf_Internal_Rela *) NULL, (abfd, eh, (PTR) NULL, (Elf_Internal_Rela *) NULL,
info->keep_memory)); info->keep_memory));
if (cookie.rels) cookie.rel = cookie.rels;
{ cookie.relend = cookie.rels;
cookie.rel = cookie.rels; if (cookie.rels != NULL)
cookie.relend = cookie.relend += count * bed->s->int_rels_per_ext_rel;
cookie.rels + eh->reloc_count * bed->s->int_rels_per_ext_rel;
}
if (_bfd_elf_discard_section_eh_frame (abfd, info, eh, ehdr, if (_bfd_elf_discard_section_eh_frame (abfd, info, eh, ehdr,
elf_reloc_symbol_deleted_p, elf_reloc_symbol_deleted_p,
&cookie)) &cookie))
{ ret = true;
/* Relocs have been edited. Ensure edited version is
used later in relocate_section. */ if (cookie.rels != NULL
elf_section_data (eh)->relocs = cookie.rels; && elf_section_data (eh)->relocs != cookie.rels)
ret = true;
}
if (cookie.rels && elf_section_data (eh)->relocs != cookie.rels)
free (cookie.rels); free (cookie.rels);
} }
if (bed->elf_backend_discard_info) if (bed->elf_backend_discard_info != NULL
{ && (*bed->elf_backend_discard_info) (abfd, &cookie, info))
if (bed->elf_backend_discard_info (abfd, &cookie, info)) ret = true;
ret = true;
}
if (cookie.locsyms != NULL if (cookie.locsyms != NULL
&& symtab_hdr->contents != (unsigned char *) cookie.locsyms) && symtab_hdr->contents != (unsigned char *) cookie.locsyms)
@ -8550,8 +8544,10 @@ elf_bfd_discard_info (output_bfd, info)
} }
} }
if (ehdr && _bfd_elf_discard_section_eh_frame_hdr (output_bfd, info, ehdr)) if (ehdr != NULL
&& _bfd_elf_discard_section_eh_frame_hdr (output_bfd, info, ehdr))
ret = true; ret = true;
return ret; return ret;
} }

View file

@ -3204,13 +3204,11 @@ elfNN_ia64_install_dyn_reloc (abfd, info, sec, srel, offset, type,
{ {
Elf_Internal_Rela outrel; Elf_Internal_Rela outrel;
offset += sec->output_section->vma + sec->output_offset;
BFD_ASSERT (dynindx != -1); BFD_ASSERT (dynindx != -1);
outrel.r_info = ELFNN_R_INFO (dynindx, type); outrel.r_info = ELFNN_R_INFO (dynindx, type);
outrel.r_addend = addend; outrel.r_addend = addend;
outrel.r_offset = _bfd_elf_section_offset (abfd, info, sec, offset); outrel.r_offset = _bfd_elf_section_offset (abfd, info, sec, offset);
if ((outrel.r_offset | 1) == (bfd_vma) -1) if (outrel.r_offset >= (bfd_vma) -2)
{ {
/* Run for the hills. We shouldn't be outputting a relocation /* Run for the hills. We shouldn't be outputting a relocation
for this. So do what everyone else does and output a no-op. */ for this. So do what everyone else does and output a no-op. */
@ -3218,6 +3216,8 @@ elfNN_ia64_install_dyn_reloc (abfd, info, sec, srel, offset, type,
outrel.r_addend = 0; outrel.r_addend = 0;
outrel.r_offset = 0; outrel.r_offset = 0;
} }
else
outrel.r_offset += sec->output_section->vma + sec->output_offset;
bfd_elfNN_swap_reloca_out (abfd, &outrel, bfd_elfNN_swap_reloca_out (abfd, &outrel,
((ElfNN_External_Rela *) srel->contents ((ElfNN_External_Rela *) srel->contents