This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
RE: Compact EH Support
- From: "Moore, Catherine" <Catherine_Moore at mentor dot com>
- To: Alan Modra <amodra at gmail dot com>, "bschmidt at redhat dot com" <bschmidt at redhat dot com>, "paul at nowt dot org" <paul at nowt dot org>
- Cc: "binutils at sourceware dot org" <binutils at sourceware dot org>
- Date: Fri, 2 Sep 2016 14:18:57 +0000
- Subject: RE: Compact EH Support
- Authentication-results: sourceware.org; auth=none
- References: <20160826055828.GD3677@bubble.grove.modra.org>
> -----Original Message-----
> From: Alan Modra [mailto:amodra@gmail.com]
> Sent: Friday, August 26, 2016 1:58 AM
> To: Moore, Catherine <Catherine_Moore@mentor.com>;
> bschmidt@redhat.com; paul@nowt.org
> Cc: binutils@sourceware.org
> Subject: Re: Compact EH Support
>
> Re https://sourceware.org/ml/binutils/2015-05/msg00237.html
>
> Would the person responsible for _bfd_elf_section_for_symbol please
> add a comment describing what the function does, in particular why it
> is looking for symbols defined in discarded sections. It doesn't make
> much sense to me..
>
> Please also move the function to elf-eh-frame.c and make it static.
>
> --
> Alan Modra
> Australia Development Lab, IBM
The intent with the addition of _bfd_elf_section_for_symbol was to pull common code from bfd_reloc_symbol_deleted_p and bfd_elf_parse_eh_frame_entry.
This patch adds the comment and updates bfd_reloc_symbol_deleted_p to call _bfd_section_for_symbol.
OK to push?
2016-09-02 Catherine Moore <clm@codesourcery.com>
* elflink.c ( _bfd_elf_section_for_symbol): Add comment.
Merge discard criteria from bfd_elf_reloc_symbol_deleted_p.
(bfd_elf_reloc_symbol_deleted_p): Delete common code. Call
_bfd_section_for_symbol.
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 9e9a33c..00603be 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -58,6 +58,11 @@ struct elf_find_verdep_info
static bfd_boolean _bfd_elf_fix_symbol_flags
(struct elf_link_hash_entry *, struct elf_info_failed *);
+/* Given a relocation cookie and its symndx, return the section
+ that defines the symbol or NULL if the symbol is not defined.
+ When DISCARD is true, a local symbol that has been defined in
+ a discarded section will be treated as an undefined symbol. */
+
asection *
_bfd_elf_section_for_symbol (struct elf_reloc_cookie *cookie,
unsigned long r_symndx,
@@ -92,8 +97,10 @@ _bfd_elf_section_for_symbol (struct elf_reloc_cookie *cookie,
/* Need to: get the symbol; get the section. */
isym = &cookie->locsyms[r_symndx];
isec = bfd_section_from_elf_index (cookie->abfd, isym->st_shndx);
- if (isec != NULL
- && discard ? discarded_section (isec) : 1)
+
+ if (!discard
+ || (isec != NULL
+ && (isec->kept_section != NULL || discarded_section (isec))))
return isec;
}
return NULL;
@@ -13509,40 +13516,8 @@ bfd_elf_reloc_symbol_deleted_p (bfd_vma offset, void *cookie)
if (r_symndx == STN_UNDEF)
return TRUE;
- if (r_symndx >= rcookie->locsymcount
- || ELF_ST_BIND (rcookie->locsyms[r_symndx].st_info) != STB_LOCAL)
- {
- struct elf_link_hash_entry *h;
-
- h = rcookie->sym_hashes[r_symndx - rcookie->extsymoff];
-
- while (h->root.type == bfd_link_hash_indirect
- || h->root.type == bfd_link_hash_warning)
- h = (struct elf_link_hash_entry *) h->root.u.i.link;
-
- if ((h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak)
- && (h->root.u.def.section->owner != rcookie->abfd
- || h->root.u.def.section->kept_section != NULL
- || discarded_section (h->root.u.def.section)))
- return TRUE;
- }
- else
- {
- /* It's not a relocation against a global symbol,
- but it could be a relocation against a local
- symbol for a discarded section. */
- asection *isec;
- Elf_Internal_Sym *isym;
-
- /* Need to: get the symbol; get the section. */
- isym = &rcookie->locsyms[r_symndx];
- isec = bfd_section_from_elf_index (rcookie->abfd, isym->st_shndx);
- if (isec != NULL
- && (isec->kept_section != NULL
- || discarded_section (isec)))
- return TRUE;
- }
+ if (_bfd_elf_section_for_symbol (rcookie, r_symndx, TRUE) != NULL)
+ return TRUE;
return FALSE;
}
return FALSE;