diff options
author | Alan Modra <amodra@gmail.com> | 2004-10-12 02:27:53 +0000 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2004-10-12 02:27:53 +0000 |
commit | 9e66c9426beba82f01cd73f117922176058f474d (patch) | |
tree | 7799a91d88cb75d9e9c8470f67c96fd0d5cf4305 /bfd/elflink.c | |
parent | a4e749e9429b2116a572627951d89098f22a7788 (diff) | |
download | gdb-9e66c9426beba82f01cd73f117922176058f474d.zip gdb-9e66c9426beba82f01cd73f117922176058f474d.tar.gz gdb-9e66c9426beba82f01cd73f117922176058f474d.tar.bz2 |
* elflink.c (enum action_discarded): New.
(elf_section_complain_discarded): Delete.
(elf_action_discarded): New function subsuming the above and also
controlling reloc behaviour.
(elf_link_input_bfd): Use it.
Diffstat (limited to 'bfd/elflink.c')
-rw-r--r-- | bfd/elflink.c | 46 |
1 files changed, 27 insertions, 19 deletions
diff --git a/bfd/elflink.c b/bfd/elflink.c index 834f09a..0687eca 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -6374,30 +6374,40 @@ elf_section_ignore_discarded_relocs (asection *sec) return FALSE; } -/* Return TRUE if we should complain about a reloc in SEC against a - symbol defined in a discarded section. */ - -static bfd_boolean -elf_section_complain_discarded (asection *sec) +enum action_discarded + { + COMPLAIN = 1, + PRETEND = 2 + }; + +/* Return a mask saying how ld should treat relocations in SEC against + symbols defined in discarded sections. If this function returns + COMPLAIN set, ld will issue a warning message. If this function + returns PRETEND set, and the discarded section was link-once and the + same size as the kept link-once section, ld will pretend that the + symbol was actually defined in the kept section. Otherwise ld will + zero the reloc (at least that is the intent, but some cooperation by + the target dependent code is needed, particularly for REL targets). */ + +static unsigned int +elf_action_discarded (asection *sec) { - if (strncmp (".stab", sec->name, 5) == 0 - && (!sec->name[5] || - (sec->name[5] == '.' && ISDIGIT (sec->name[6])))) - return FALSE; + if (sec->flags & SEC_DEBUGGING) + return PRETEND; if (strcmp (".eh_frame", sec->name) == 0) - return FALSE; + return 0; if (strcmp (".gcc_except_table", sec->name) == 0) - return FALSE; + return 0; if (strcmp (".PARISC.unwind", sec->name) == 0) - return FALSE; + return 0; if (strcmp (".fixup", sec->name) == 0) - return FALSE; + return 0; - return TRUE; + return COMPLAIN | PRETEND; } /* Find a match between a section and a member of a section group. */ @@ -6692,7 +6702,7 @@ elf_link_input_bfd (struct elf_final_link_info *finfo, bfd *input_bfd) if (!elf_section_ignore_discarded_relocs (o)) { Elf_Internal_Rela *rel, *relend; - bfd_boolean complain = elf_section_complain_discarded (o); + unsigned int action = elf_action_discarded (o); rel = internal_relocs; relend = rel + o->reloc_count * bed->s->int_rels_per_ext_rel; @@ -6736,7 +6746,7 @@ elf_link_input_bfd (struct elf_final_link_info *finfo, bfd *input_bfd) asection *kept; BFD_ASSERT (r_symndx != 0); - if (complain && (o->flags & SEC_DEBUGGING) == 0) + if (action & COMPLAIN) { (*_bfd_error_handler) (_("`%s' referenced in section `%A' of %B: " @@ -6756,9 +6766,7 @@ elf_link_input_bfd (struct elf_final_link_info *finfo, bfd *input_bfd) debug sections tend to come after other sections. */ kept = sec->kept_section; - if (kept != NULL - && (complain - || (o->flags & SEC_DEBUGGING) != 0)) + if (kept != NULL && (action & PRETEND)) { if (elf_sec_group (sec) != NULL) kept = match_group_member (sec, kept); |