aboutsummaryrefslogtreecommitdiff
path: root/bfd
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
commit7f8d5fc90bf3c799976edffa902e03edf1455061 (patch)
tree50ddd0462bbe7f357e153435e453453caf154675 /bfd
parente3c976c4eb27fa23ff52c5d32dceb98ef0891f64 (diff)
downloadfsf-binutils-gdb-7f8d5fc90bf3c799976edffa902e03edf1455061.zip
fsf-binutils-gdb-7f8d5fc90bf3c799976edffa902e03edf1455061.tar.gz
fsf-binutils-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')
-rw-r--r--bfd/ChangeLog13
-rw-r--r--bfd/bfd-in.h14
-rw-r--r--bfd/bfd-in2.h42
-rw-r--r--bfd/elf32-i386.c2
-rw-r--r--bfd/elf32-m68k.c2
-rw-r--r--bfd/elf32-mips.c2
-rw-r--r--bfd/elf32-ppc.c2
-rw-r--r--bfd/elf32-sparc.c2
-rw-r--r--bfd/elf64-alpha.c2
-rw-r--r--bfd/elf64-sparc.c2
-rw-r--r--bfd/elflink.h6
-rw-r--r--bfd/section.c40
12 files changed, 91 insertions, 38 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 1fd998b..1b629ea 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,16 @@
+2000-02-13 Ian Lance Taylor <ian@zembu.com>
+
+ * 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.
+
2000-02-10 Timothy Wall <twall@cygnus.com>
* coffswap.h (coff_swap_sym_in): Add hook SWAP_SYM_IN_POST to
diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h
index b5ff7dd..a5312f4 100644
--- a/bfd/bfd-in.h
+++ b/bfd/bfd-in.h
@@ -626,6 +626,20 @@ extern boolean bfd_elf64_size_dynamic_sections
extern void bfd_elf_set_dt_needed_name PARAMS ((bfd *, const char *));
extern const char *bfd_elf_get_dt_soname PARAMS ((bfd *));
+/* Return an upper bound on the number of bytes required to store a
+ copy of ABFD's program header table entries. Return -1 if an error
+ occurs; bfd_get_error will return an appropriate code. */
+extern long bfd_get_elf_phdr_upper_bound PARAMS ((bfd *abfd));
+
+/* Copy ABFD's program header table entries to *PHDRS. The entries
+ will be stored as an array of Elf_Internal_Phdr structures, as
+ defined in include/elf/internal.h. To find out how large the
+ buffer needs to be, call bfd_get_elf_phdr_upper_bound.
+
+ Return the number of program header table entries read, or -1 if an
+ error occurs; bfd_get_error will return an appropriate code. */
+extern int bfd_get_elf_phdrs PARAMS ((bfd *abfd, void *phdrs));
+
/* SunOS shared library support routines for the linker. */
extern struct bfd_link_needed_list *bfd_sunos_get_needed_list
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index 9db6ec6..7ec5d70 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -626,6 +626,20 @@ extern boolean bfd_elf64_size_dynamic_sections
extern void bfd_elf_set_dt_needed_name PARAMS ((bfd *, const char *));
extern const char *bfd_elf_get_dt_soname PARAMS ((bfd *));
+/* Return an upper bound on the number of bytes required to store a
+ copy of ABFD's program header table entries. Return -1 if an error
+ occurs; bfd_get_error will return an appropriate code. */
+extern long bfd_get_elf_phdr_upper_bound PARAMS ((bfd *abfd));
+
+/* Copy ABFD's program header table entries to *PHDRS. The entries
+ will be stored as an array of Elf_Internal_Phdr structures, as
+ defined in include/elf/internal.h. To find out how large the
+ buffer needs to be, call bfd_get_elf_phdr_upper_bound.
+
+ Return the number of program header table entries read, or -1 if an
+ error occurs; bfd_get_error will return an appropriate code. */
+extern int bfd_get_elf_phdrs PARAMS ((bfd *abfd, void *phdrs));
+
/* SunOS shared library support routines for the linker. */
extern struct bfd_link_needed_list *bfd_sunos_get_needed_list
@@ -1084,7 +1098,7 @@ typedef struct sec
target). In most cases, if this was going to start at the
100th octet (8-bit quantity) in the output section, this value
would be 100. However, if the target byte size is 16 bits
- (bfd_octets_per_byte is "2"), this value would be 50. */
+ (bfd_octets_per_byte is "2"), this value would be 50. */
bfd_vma output_offset;
@@ -1254,7 +1268,7 @@ bfd_copy_private_section_data PARAMS ((bfd *ibfd, asection *isec, bfd *obfd, ase
(ibfd, isection, obfd, osection))
void
_bfd_strip_section_from_output
- PARAMS ((asection *section));
+ PARAMS ((struct bfd_link_info *info, asection *section));
enum bfd_architecture
{
@@ -1379,7 +1393,7 @@ enum bfd_architecture
bfd_arch_mn10200, /* Matsushita MN10200 */
bfd_arch_mn10300, /* Matsushita MN10300 */
#define bfd_mach_mn10300 300
-#define bfd_mach_am33 330
+#define bfd_mach_am33 330
bfd_arch_fr30,
#define bfd_mach_fr30 0x46523330
bfd_arch_mcore,
@@ -1454,7 +1468,7 @@ bfd_octets_per_byte PARAMS ((bfd *abfd));
int
bfd_arch_mach_octets_per_byte PARAMS ((enum bfd_architecture arch,
- unsigned long machine));
+ unsigned long machine));
typedef enum bfd_reloc_status
{
@@ -2433,8 +2447,8 @@ bfd_print_symbol_vandf PARAMS ((PTR file, asymbol *symbol));
int
bfd_decode_symclass PARAMS ((asymbol *symbol));
-boolean
-bfd_is_undefined_symclass PARAMS ((int symclass));
+boolean
+bfd_is_undefined_symclass PARAMS ((int symclass));
void
bfd_symbol_info PARAMS ((asymbol *symbol, symbol_info *ret));
@@ -3105,22 +3119,6 @@ bfd_set_format PARAMS ((bfd *abfd, bfd_format format));
CONST char *
bfd_format_string PARAMS ((bfd_format format));
-
-/* Return an upper bound on the number of bytes required to store a
- copy of ABFD's program header table entries. Return -1 if an error
- occurs; bfd_get_error will return an appropriate code. */
-extern long bfd_get_elf_phdr_upper_bound PARAMS ((bfd *abfd));
-
-/* Copy ABFD's program header table entries to *PHDRS. The entries
- will be stored as an array of Elf_Internal_Phdr structures, as
- defined in include/elf/internal.h. To find out how large the
- buffer needs to be, call bfd_get_elf_phdr_upper_bound.
-
- Return the number of program header table entries read, or -1 if an
- error occurs; bfd_get_error will return an appropriate code. */
-extern int bfd_get_elf_phdrs PARAMS ((bfd *abfd, void *phdrs));
-
-
#ifdef __cplusplus
}
#endif
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index 33514ac..0894476 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -1085,7 +1085,7 @@ elf_i386_size_dynamic_sections (output_bfd, info)
if (strip)
{
- _bfd_strip_section_from_output (s);
+ _bfd_strip_section_from_output (info, s);
continue;
}
diff --git a/bfd/elf32-m68k.c b/bfd/elf32-m68k.c
index c87ec7a..06ba12c 100644
--- a/bfd/elf32-m68k.c
+++ b/bfd/elf32-m68k.c
@@ -1262,7 +1262,7 @@ elf_m68k_size_dynamic_sections (output_bfd, info)
if (strip)
{
- _bfd_strip_section_from_output (s);
+ _bfd_strip_section_from_output (info, s);
continue;
}
diff --git a/bfd/elf32-mips.c b/bfd/elf32-mips.c
index 6db9c23..d9832b6 100644
--- a/bfd/elf32-mips.c
+++ b/bfd/elf32-mips.c
@@ -7920,7 +7920,7 @@ _bfd_mips_elf_size_dynamic_sections (output_bfd, info)
if (strip)
{
- _bfd_strip_section_from_output (s);
+ _bfd_strip_section_from_output (info, s);
continue;
}
diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c
index 1de197b..7c5f589 100644
--- a/bfd/elf32-ppc.c
+++ b/bfd/elf32-ppc.c
@@ -2012,7 +2012,7 @@ ppc_elf_size_dynamic_sections (output_bfd, info)
if (strip)
{
- _bfd_strip_section_from_output (s);
+ _bfd_strip_section_from_output (info, s);
continue;
}
diff --git a/bfd/elf32-sparc.c b/bfd/elf32-sparc.c
index 979d25b..bf34782 100644
--- a/bfd/elf32-sparc.c
+++ b/bfd/elf32-sparc.c
@@ -1010,7 +1010,7 @@ elf32_sparc_size_dynamic_sections (output_bfd, info)
if (strip)
{
- _bfd_strip_section_from_output (s);
+ _bfd_strip_section_from_output (info, s);
continue;
}
diff --git a/bfd/elf64-alpha.c b/bfd/elf64-alpha.c
index 3a14bcc..a21d1b9 100644
--- a/bfd/elf64-alpha.c
+++ b/bfd/elf64-alpha.c
@@ -3263,7 +3263,7 @@ elf64_alpha_size_dynamic_sections (output_bfd, info)
}
if (strip)
- _bfd_strip_section_from_output (s);
+ _bfd_strip_section_from_output (info, s);
else
{
/* Allocate memory for the section contents. */
diff --git a/bfd/elf64-sparc.c b/bfd/elf64-sparc.c
index b027897..5ea95e9 100644
--- a/bfd/elf64-sparc.c
+++ b/bfd/elf64-sparc.c
@@ -1752,7 +1752,7 @@ sparc64_elf_size_dynamic_sections (output_bfd, info)
if (strip)
{
- _bfd_strip_section_from_output (s);
+ _bfd_strip_section_from_output (info, s);
continue;
}
diff --git a/bfd/elflink.h b/bfd/elflink.h
index f15c693..ce71d94 100644
--- a/bfd/elflink.h
+++ b/bfd/elflink.h
@@ -2981,7 +2981,7 @@ NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath,
verdefs = asvinfo.verdefs;
if (verdefs == NULL)
- _bfd_strip_section_from_output (s);
+ _bfd_strip_section_from_output (info, s);
else
{
unsigned int cdefs;
@@ -3157,7 +3157,7 @@ NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath,
(PTR) &sinfo);
if (elf_tdata (output_bfd)->verref == NULL)
- _bfd_strip_section_from_output (s);
+ _bfd_strip_section_from_output (info, s);
else
{
Elf_Internal_Verneed *t;
@@ -3261,7 +3261,7 @@ NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath,
if (dynsymcount == 0
|| (verdefs == NULL && elf_tdata (output_bfd)->verref == NULL))
{
- _bfd_strip_section_from_output (s);
+ _bfd_strip_section_from_output (info, s);
/* The DYNSYMCOUNT might have changed if we were going to
output a dynamic symbol table entry for S. */
dynsymcount = _bfd_elf_link_renumber_dynsyms (output_bfd, info);
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)