diff options
author | Alan Modra <amodra@bigpond.net.au> | 2002-11-12 06:21:05 +0000 |
---|---|---|
committer | Alan Modra <amodra@bigpond.net.au> | 2002-11-12 06:21:05 +0000 |
commit | 07a3ce9f1604b10a6c8fad7904ba6744910a100e (patch) | |
tree | 26e9e45c781693807d0c0d170f115828bd33ba38 /bfd | |
parent | 0f2a6ca02771f9aae80ef3fa6f4992ea23803554 (diff) | |
download | gdb-07a3ce9f1604b10a6c8fad7904ba6744910a100e.tar.gz |
* 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.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 12 | ||||
-rw-r--r-- | bfd/elf-eh-frame.c | 17 | ||||
-rw-r--r-- | bfd/elf64-sparc.c | 7 | ||||
-rw-r--r-- | bfd/elflink.h | 92 | ||||
-rw-r--r-- | bfd/elfxx-ia64.c | 6 |
5 files changed, 64 insertions, 70 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index b3a8924b4d1..9cf4abb2885 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -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> * elf64-sparc.c (sparc64_elf_adjust_dynamic_symbol): Correct diff --git a/bfd/elf-eh-frame.c b/bfd/elf-eh-frame.c index b6d2d2f8087..d5f4cc5ad49 100644 --- a/bfd/elf-eh-frame.c +++ b/bfd/elf-eh-frame.c @@ -299,7 +299,6 @@ _bfd_elf_discard_section_eh_frame (abfd, info, sec, ehdrsec, unsigned int leb128_tmp; unsigned int cie_usage_count, last_cie_ndx, i, offset; unsigned int make_relative, make_lsda_relative; - Elf_Internal_Rela *rel; bfd_size_type new_size; unsigned int ptr_size; @@ -555,10 +554,9 @@ _bfd_elf_discard_section_eh_frame (abfd, info, sec, ehdrsec, + ((buf - ehbuf + per_width - 1) & ~((bfd_size_type) per_width - 1))); ENSURE_NO_RELOCS (buf); - rel = GET_RELOC (buf); /* Ensure we have a reloc here, against a global symbol. */ - if (rel != NULL) + if (GET_RELOC (buf) != NULL) { unsigned long r_symndx; @@ -626,8 +624,7 @@ _bfd_elf_discard_section_eh_frame (abfd, info, sec, ehdrsec, goto free_no_table; ENSURE_NO_RELOCS (buf); - rel = GET_RELOC (buf); - if (rel == NULL) + if (GET_RELOC (buf) == NULL) /* This should not happen. */ goto free_no_table; if ((*reloc_symbol_deleted_p) (buf - ehbuf, cookie)) @@ -636,7 +633,6 @@ _bfd_elf_discard_section_eh_frame (abfd, info, sec, ehdrsec, be deleted. */ new_size -= hdr.length + 4; sec_info->entry[sec_info->count].removed = 1; - memset (rel, 0, sizeof (*rel)); } else { @@ -654,7 +650,6 @@ _bfd_elf_discard_section_eh_frame (abfd, info, sec, ehdrsec, cie_usage_count++; hdr_info->fde_count++; } - cookie->rel = rel; if (cie.lsda_encoding != DW_EH_PE_omit) { unsigned int dummy; @@ -751,10 +746,6 @@ _bfd_elf_discard_section_eh_frame_hdr (abfd, info, sec) asection *sec; { 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 != ELF_INFO_TYPE_EH_FRAME_HDR) @@ -1179,14 +1170,10 @@ _bfd_elf_write_section_eh_frame_hdr (abfd, sec) asection *sec; { struct eh_frame_hdr_info *hdr_info; - unsigned int ptr_size; bfd_byte *contents; asection *eh_frame_sec; 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 == ELF_INFO_TYPE_EH_FRAME_HDR); hdr_info = (struct eh_frame_hdr_info *) diff --git a/bfd/elf64-sparc.c b/bfd/elf64-sparc.c index 184179e7b05..ae4e57a2266 100644 --- a/bfd/elf64-sparc.c +++ b/bfd/elf64-sparc.c @@ -2584,11 +2584,10 @@ sparc64_elf_relocate_section (output_bfd, info, input_bfd, input_section, /* The Solaris native linker silently disregards overflows. We don't, but this breaks stabs debugging info, whose relocations are only 32-bits wide. Ignore - overflows in this case. */ + overflows for discarded entries. */ if (r_type == R_SPARC_32 - && (input_section->flags & SEC_DEBUGGING) != 0 - && strcmp (bfd_section_name (input_bfd, input_section), - ".stab") == 0) + && _bfd_elf_section_offset (output_bfd, info, input_section, + rel->r_offset) == (bfd_vma) -1) break; if (h != NULL) diff --git a/bfd/elflink.h b/bfd/elflink.h index c116ed5d44a..339cc23a8e1 100644 --- a/bfd/elflink.h +++ b/bfd/elflink.h @@ -8413,8 +8413,8 @@ elf_bfd_discard_info (output_bfd, info) Elf_Internal_Shdr *symtab_hdr; struct elf_backend_data *bed; bfd *abfd; + unsigned int count; boolean ret = false; - boolean strip = info->strip == strip_all || info->strip == strip_debugger; if (info->relocateable || info->traditional_format @@ -8438,26 +8438,25 @@ elf_bfd_discard_info (output_bfd, info) continue; eh = NULL; - if (ehdr) + if (ehdr != NULL) { eh = bfd_get_section_by_name (abfd, ".eh_frame"); - if (eh && (eh->_raw_size == 0 - || bfd_is_abs_section (eh->output_section))) + if (eh != NULL + && (eh->_raw_size == 0 + || bfd_is_abs_section (eh->output_section))) eh = NULL; } - stab = NULL; - if (!strip) - { - stab = bfd_get_section_by_name (abfd, ".stab"); - if (stab && (stab->_raw_size == 0 - || bfd_is_abs_section (stab->output_section))) - stab = NULL; - } - if ((! stab - || elf_section_data(stab)->sec_info_type != ELF_INFO_TYPE_STABS) - && ! eh - && (strip || ! bed->elf_backend_discard_info)) + stab = bfd_get_section_by_name (abfd, ".stab"); + if (stab != NULL + && (stab->_raw_size == 0 + || bfd_is_abs_section (stab->output_section) + || elf_section_data (stab)->sec_info_type != ELF_INFO_TYPE_STABS)) + stab = NULL; + + if (stab == NULL + && eh == NULL + && bed->elf_backend_discard_info == NULL) continue; 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); if (cookie.bad_symtab) { - cookie.locsymcount = - symtab_hdr->sh_size / sizeof (Elf_External_Sym); + cookie.locsymcount = symtab_hdr->sh_size / sizeof (Elf_External_Sym); cookie.extsymoff = 0; } else @@ -8486,16 +8484,19 @@ elf_bfd_discard_info (output_bfd, info) return false; } - if (stab) + if (stab != NULL) { - cookie.rels = (NAME(_bfd_elf,link_read_relocs) - (abfd, stab, (PTR) NULL, (Elf_Internal_Rela *) NULL, - info->keep_memory)); - if (cookie.rels) + cookie.rels = NULL; + count = stab->reloc_count; + if (count != 0) + 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.relend = - cookie.rels + stab->reloc_count * bed->s->int_rels_per_ext_rel; + cookie.relend = cookie.rels; + cookie.relend += count * bed->s->int_rels_per_ext_rel; if (_bfd_discard_section_stabs (abfd, stab, elf_section_data (stab)->sec_info, 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.rel = NULL; - cookie.relend = NULL; - if (eh->reloc_count) + count = eh->reloc_count; + if (count != 0) cookie.rels = (NAME(_bfd_elf,link_read_relocs) (abfd, eh, (PTR) NULL, (Elf_Internal_Rela *) NULL, info->keep_memory)); - if (cookie.rels) - { - cookie.rel = cookie.rels; - cookie.relend = - cookie.rels + eh->reloc_count * bed->s->int_rels_per_ext_rel; - } + cookie.rel = cookie.rels; + cookie.relend = cookie.rels; + if (cookie.rels != NULL) + cookie.relend += count * bed->s->int_rels_per_ext_rel; + if (_bfd_elf_discard_section_eh_frame (abfd, info, eh, ehdr, elf_reloc_symbol_deleted_p, &cookie)) - { - /* Relocs have been edited. Ensure edited version is - used later in relocate_section. */ - elf_section_data (eh)->relocs = cookie.rels; - ret = true; - } - if (cookie.rels && elf_section_data (eh)->relocs != cookie.rels) + ret = true; + + if (cookie.rels != NULL + && elf_section_data (eh)->relocs != cookie.rels) free (cookie.rels); } - if (bed->elf_backend_discard_info) - { - if (bed->elf_backend_discard_info (abfd, &cookie, info)) - ret = true; - } + if (bed->elf_backend_discard_info != NULL + && (*bed->elf_backend_discard_info) (abfd, &cookie, info)) + ret = true; if (cookie.locsyms != NULL && 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; + return ret; } diff --git a/bfd/elfxx-ia64.c b/bfd/elfxx-ia64.c index 5da8e43b7f8..ddd86fbfda5 100644 --- a/bfd/elfxx-ia64.c +++ b/bfd/elfxx-ia64.c @@ -3204,13 +3204,11 @@ elfNN_ia64_install_dyn_reloc (abfd, info, sec, srel, offset, type, { Elf_Internal_Rela outrel; - offset += sec->output_section->vma + sec->output_offset; - BFD_ASSERT (dynindx != -1); outrel.r_info = ELFNN_R_INFO (dynindx, type); outrel.r_addend = addend; 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 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_offset = 0; } + else + outrel.r_offset += sec->output_section->vma + sec->output_offset; bfd_elfNN_swap_reloca_out (abfd, &outrel, ((ElfNN_External_Rela *) srel->contents |