summaryrefslogtreecommitdiff
path: root/bfd/section.c
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>2000-02-13 22:45:29 +0000
committerIan Lance Taylor <ian@airs.com>2000-02-13 22:45:29 +0000
commitd090c8acf917d83c423f43cff373d3a8be77bc16 (patch)
tree1a8ed164a85abd6b61ec51e0a52872c9552767bc /bfd/section.c
parent5c66581456cab9cbb41d3bc288f8ff3a9566a053 (diff)
downloadgdb-d090c8acf917d83c423f43cff373d3a8be77bc16.tar.gz
* 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.c40
1 files changed, 34 insertions, 6 deletions
diff --git a/bfd/section.c b/bfd/section.c
index c0bf60d29c5..6e50d168ba2 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)