diff options
author | Ian Lance Taylor <ian@airs.com> | 2000-02-13 22:45:29 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@airs.com> | 2000-02-13 22:45:29 +0000 |
commit | 7f8d5fc90bf3c799976edffa902e03edf1455061 (patch) | |
tree | 50ddd0462bbe7f357e153435e453453caf154675 /bfd/section.c | |
parent | e3c976c4eb27fa23ff52c5d32dceb98ef0891f64 (diff) | |
download | gdb-7f8d5fc90bf3c799976edffa902e03edf1455061.zip gdb-7f8d5fc90bf3c799976edffa902e03edf1455061.tar.gz gdb-7f8d5fc90bf3c799976edffa902e03edf1455061.tar.bz2 |
* section.c (_bfd_strip_section_from_output): Add info parameter.
If it passed as non-NULL, use it to check whether any input BFD
has an input section which uses this output section. Change all
callers.
* bfd-in2.h: Rebuild.
* bfd-in.h: Move declarations of bfd_get_elf_phdr_upper_bound and
bfd_get_elf_phdrs in from bfd-in2.h, correcting patch of
1999-11-29.
* bfd-in2.h: Rebuild.
Diffstat (limited to 'bfd/section.c')
-rw-r--r-- | bfd/section.c | 40 |
1 files changed, 34 insertions, 6 deletions
diff --git a/bfd/section.c b/bfd/section.c index c0bf60d..6e50d16 100644 --- a/bfd/section.c +++ b/bfd/section.c @@ -1100,20 +1100,28 @@ FUNCTION SYNOPSIS void _bfd_strip_section_from_output - (asection *section); + (struct bfd_link_info *info, asection *section); DESCRIPTION - Remove @var{section} from the output. If the output section becomes - empty, remove it from the output bfd. + Remove @var{section} from the output. If the output section + becomes empty, remove it from the output bfd. @var{info} may + be NULL; if it is not, it is used to decide whether the output + section is empty. */ void -_bfd_strip_section_from_output (s) +_bfd_strip_section_from_output (info, s) + struct bfd_link_info *info; asection *s; { asection **spp, *os; struct bfd_link_order *p, *pp; + boolean keep_os; - /* Excise the input section from the link order. */ + /* Excise the input section from the link order. + + FIXME: For all calls that I can see to this function, the link + orders have not yet been set up. So why are we checking them? -- + Ian */ os = s->output_section; for (p = os->link_order_head, pp = NULL; p != NULL; pp = p, p = p->next) if (p->type == bfd_indirect_link_order @@ -1128,10 +1136,30 @@ _bfd_strip_section_from_output (s) break; } + keep_os = os->link_order_head != NULL; + + if (! keep_os && info != NULL) + { + bfd *abfd; + for (abfd = info->input_bfds; abfd != NULL; abfd = abfd->link_next) + { + asection *is; + for (is = abfd->sections; is != NULL; is = is->next) + { + if (is != s && is->output_section == os) + break; + } + if (is != NULL) + break; + } + if (abfd != NULL) + keep_os = true; + } + /* If the output section is empty, remove it too. Careful about sections that have been discarded in the link script -- they are mapped to bfd_abs_section, which has no owner. */ - if (!os->link_order_head && os->owner) + if (!keep_os && os->owner != NULL) { for (spp = &os->owner->sections; *spp; spp = &(*spp)->next) if (*spp == os) |