summaryrefslogtreecommitdiff
path: root/bfd/elflink.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl@lucon.org>2005-04-01 03:49:46 +0000
committerH.J. Lu <hjl@lucon.org>2005-04-01 03:49:46 +0000
commite629041a1d172b0083ec86de223c54e038cc4edb (patch)
tree79be41e326a25f50ca1f6d69ce130c72fca5835d /bfd/elflink.c
parent8df50c0738f1a1e93338cb85c69f8edb867aa034 (diff)
downloadbinutils-redhat-e629041a1d172b0083ec86de223c54e038cc4edb.tar.gz
2005-03-31 H.J. Lu <hongjiu.lu@intel.com>
* elf-bfd.h (_bfd_elf_check_kept_section): New. * elf.c (assign_section_numbers): When sh_link points to a discarded section, call _bfd_elf_check_kept_section to see if the kept section can be used. Otherwise reject sh_link pointing to discarded section. * elflink.c (_bfd_elf_check_kept_section): New. (elf_link_input_bfd): Use it.
Diffstat (limited to 'bfd/elflink.c')
-rw-r--r--bfd/elflink.c33
1 files changed, 25 insertions, 8 deletions
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 8134834cd9..d37b19ba92 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -6700,6 +6700,26 @@ match_group_member (asection *sec, asection *group)
return NULL;
}
+/* Check if the kept section of a discarded section SEC can be used
+ to replace it. Return the replacement if it is OK. Otherwise return
+ NULL. */
+
+asection *
+_bfd_elf_check_kept_section (asection *sec)
+{
+ asection *kept;
+
+ kept = sec->kept_section;
+ if (kept != NULL)
+ {
+ if (elf_sec_group (sec) != NULL)
+ kept = match_group_member (sec, kept);
+ if (kept != NULL && sec->size != kept->size)
+ kept = NULL;
+ }
+ return kept;
+}
+
/* Link an input file into the linker output file. This function
handles all the sections and relocations of the input file at once.
This is so that we only have to read the local symbols once, and
@@ -7013,8 +7033,6 @@ elf_link_input_bfd (struct elf_final_link_info *finfo, bfd *input_bfd)
discarded section. */
if ((sec = *ps) != NULL && elf_discarded_section (sec))
{
- asection *kept;
-
BFD_ASSERT (r_symndx != 0);
if (action & COMPLAIN)
{
@@ -7035,13 +7053,12 @@ elf_link_input_bfd (struct elf_final_link_info *finfo, bfd *input_bfd)
is that we warn in non-debug sections, and
debug sections tend to come after other
sections. */
- kept = sec->kept_section;
- if (kept != NULL && (action & PRETEND))
+ if (action & PRETEND)
{
- if (elf_sec_group (sec) != NULL)
- kept = match_group_member (sec, kept);
- if (kept != NULL
- && sec->size == kept->size)
+ asection *kept;
+
+ kept = _bfd_elf_check_kept_section (sec);
+ if (kept != NULL)
{
*ps = kept;
continue;