summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH.J. Lu <hjl@lucon.org>2006-10-30 23:25:51 +0000
committerH.J. Lu <hjl@lucon.org>2006-10-30 23:25:51 +0000
commit149a1a395e951b9706fa50abec9fc8bac7afda4a (patch)
tree5b0537e392315276856e1405937251d7abf28e36
parentd4ac7c1d3f205996a466fd301ea3e74a966d483b (diff)
downloadgdb-149a1a395e951b9706fa50abec9fc8bac7afda4a.tar.gz
bfd/
2006-10-30 H.J. Lu <hongjiu.lu@intel.com> PR ld/3111 * elf-bfd.h (elf_obj_tdata): Add symbuf. (_bfd_elf_section_already_linked): Add struct bfd_link_info *. (_bfd_elf_check_kept_section): Likewise. (bfd_elf_match_symbols_in_sections): Likewise. * elf.c (assign_section_numbers): Updated to add struct bfd_link_info *. (bfd_elf_match_symbols_in_sections): Updated. Cache symbol buffer if info->reduce_memory_overheads is false. * elflink.c (match_group_member): Updated to add struct bfd_link_info *. (_bfd_elf_check_kept_section): Likewise. (elf_link_input_bfd): Likewise. (_bfd_elf_section_already_linked): Likewise. (bfd_elf_final_link): Free symbol buffer if info->reduce_memory_overheads is false. * libbfd-in.h (_bfd_nolink_section_already_linked): Add struct bfd_link_info *. (_bfd_generic_section_already_linked): Likewise. * libbfd.h: Regenerated. * linker.c (bfd_section_already_linked): Add struct bfd_link_info *. (_bfd_generic_section_already_linked): Likewise. * targets.c (bfd_target): Add struct bfd_link_info * to _section_already_linked. * bfd-in2.h: Regenerated. include/ 2006-10-30 H.J. Lu <hongjiu.lu@intel.com> PR ld/3111 * bfdlink.h (bfd_link_info): Add reduce_memory_overheads. ld/ 2006-10-30 H.J. Lu <hongjiu.lu@intel.com> PR ld/3111 * ld.h (args_type): Remove reduce_memory_overheads. * ldlang.c (lang_map): Updated. (section_already_linked): Likewise. (print_input_section): Likewise. * ldmain.c (main): Likewise. * lexsup.c (parse_args): Likewise.
-rw-r--r--bfd/ChangeLog35
-rw-r--r--bfd/bfd-in2.h10
-rw-r--r--bfd/elf-bfd.h9
-rw-r--r--bfd/elf.c58
-rw-r--r--bfd/elflink.c31
-rw-r--r--bfd/libbfd-in.h4
-rw-r--r--bfd/libbfd.h4
-rw-r--r--bfd/linker.c10
-rw-r--r--bfd/targets.c3
-rw-r--r--include/ChangeLog5
-rw-r--r--include/bfdlink.h5
11 files changed, 131 insertions, 43 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index ac69c75a267..cd3a99fdb4d 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,38 @@
+bfd/
+
+2006-10-30 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/3111
+ * elf-bfd.h (elf_obj_tdata): Add symbuf.
+ (_bfd_elf_section_already_linked): Add struct bfd_link_info *.
+ (_bfd_elf_check_kept_section): Likewise.
+ (bfd_elf_match_symbols_in_sections): Likewise.
+
+ * elf.c (assign_section_numbers): Updated to add
+ struct bfd_link_info *.
+ (bfd_elf_match_symbols_in_sections): Updated. Cache symbol
+ buffer if info->reduce_memory_overheads is false.
+
+ * elflink.c (match_group_member): Updated to add
+ struct bfd_link_info *.
+ (_bfd_elf_check_kept_section): Likewise.
+ (elf_link_input_bfd): Likewise.
+ (_bfd_elf_section_already_linked): Likewise.
+ (bfd_elf_final_link): Free symbol buffer if
+ info->reduce_memory_overheads is false.
+
+ * libbfd-in.h (_bfd_nolink_section_already_linked): Add
+ struct bfd_link_info *.
+ (_bfd_generic_section_already_linked): Likewise.
+ * libbfd.h: Regenerated.
+
+ * linker.c (bfd_section_already_linked): Add
+ struct bfd_link_info *.
+ (_bfd_generic_section_already_linked): Likewise.
+ * targets.c (bfd_target): Add struct bfd_link_info * to
+ _section_already_linked.
+ * bfd-in2.h: Regenerated.
+
2006-10-30 Alan Modra <amodra@bigpond.net.au>
* bfd.c (bfd_error_type): Add bfd_error_on_input.
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index eef70d382c4..e4c92d7e339 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -5201,7 +5201,8 @@ typedef struct bfd_target
/* Check if SEC has been already linked during a reloceatable or
final link. */
- void (*_section_already_linked) (bfd *, struct bfd_section *);
+ void (*_section_already_linked) (bfd *, struct bfd_section *,
+ struct bfd_link_info *);
/* Routines to handle dynamic symbols and relocs. */
#define BFD_JUMP_TABLE_DYNAMIC(NAME) \
@@ -5261,10 +5262,11 @@ bfd_boolean bfd_link_split_section (bfd *abfd, asection *sec);
#define bfd_link_split_section(abfd, sec) \
BFD_SEND (abfd, _bfd_link_split_section, (abfd, sec))
-void bfd_section_already_linked (bfd *abfd, asection *sec);
+void bfd_section_already_linked (bfd *abfd, asection *sec,
+ struct bfd_link_info *info);
-#define bfd_section_already_linked(abfd, sec) \
- BFD_SEND (abfd, _section_already_linked, (abfd, sec))
+#define bfd_section_already_linked(abfd, sec, info) \
+ BFD_SEND (abfd, _section_already_linked, (abfd, sec, info))
/* Extracted from simple.c. */
bfd_byte *bfd_simple_get_relocated_section_contents
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index bb86c4e639c..85a76938237 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -1404,6 +1404,9 @@ struct elf_obj_tdata
/* Used to determine if the e_flags field has been initialized */
bfd_boolean flags_init;
+
+ /* Symbol buffer. */
+ Elf_Internal_Sym *symbuf;
};
#define elf_tdata(bfd) ((bfd) -> tdata.elf_obj_data)
@@ -1538,11 +1541,11 @@ extern bfd_boolean _bfd_elf_match_sections_by_type
extern bfd_boolean bfd_elf_is_group_section
(bfd *, const struct bfd_section *);
extern void _bfd_elf_section_already_linked
- (bfd *, struct bfd_section *);
+ (bfd *, struct bfd_section *, struct bfd_link_info *);
extern void bfd_elf_set_group_contents
(bfd *, asection *, void *);
extern asection *_bfd_elf_check_kept_section
- (asection *);
+ (asection *, struct bfd_link_info *);
extern void _bfd_elf_link_just_syms
(asection *, struct bfd_link_info *);
extern bfd_boolean _bfd_elf_copy_private_header_data
@@ -1744,7 +1747,7 @@ extern bfd_boolean _bfd_elf_symbol_refs_local_p
(struct elf_link_hash_entry *, struct bfd_link_info *, bfd_boolean);
extern bfd_boolean bfd_elf_match_symbols_in_sections
- (asection *sec1, asection *sec2);
+ (asection *, asection *, struct bfd_link_info *);
extern bfd_boolean _bfd_elf_setup_sections
(bfd *);
diff --git a/bfd/elf.c b/bfd/elf.c
index 747310bf587..2594e21576b 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -3173,7 +3173,7 @@ assign_section_numbers (bfd *abfd, struct bfd_link_info *link_info)
s, s->owner);
/* Point to the kept section if it has the same
size as the discarded one. */
- kept = _bfd_elf_check_kept_section (s);
+ kept = _bfd_elf_check_kept_section (s, link_info);
if (kept == NULL)
{
bfd_set_error (bfd_error_bad_value);
@@ -8674,7 +8674,8 @@ elf_sym_name_compare (const void *arg1, const void *arg2)
symbols. */
bfd_boolean
-bfd_elf_match_symbols_in_sections (asection *sec1, asection *sec2)
+bfd_elf_match_symbols_in_sections (asection *sec1, asection *sec2,
+ struct bfd_link_info *info)
{
bfd *bfd1, *bfd2;
const struct elf_backend_data *bed1, *bed2;
@@ -8730,21 +8731,37 @@ bfd_elf_match_symbols_in_sections (asection *sec1, asection *sec2)
if (symcount1 == 0 || symcount2 == 0)
return FALSE;
- isymbuf1 = bfd_elf_get_elf_syms (bfd1, hdr1, symcount1, 0,
- NULL, NULL, NULL);
- isymbuf2 = bfd_elf_get_elf_syms (bfd2, hdr2, symcount2, 0,
- NULL, NULL, NULL);
-
result = FALSE;
- if (isymbuf1 == NULL || isymbuf2 == NULL)
- goto done;
+ isymbuf1 = elf_tdata (bfd1)->symbuf;
+ isymbuf2 = elf_tdata (bfd2)->symbuf;
- /* Sort symbols by binding and section. Global definitions are at
- the beginning. */
- qsort (isymbuf1, symcount1, sizeof (Elf_Internal_Sym),
- elf_sort_elf_symbol);
- qsort (isymbuf2, symcount2, sizeof (Elf_Internal_Sym),
- elf_sort_elf_symbol);
+ if (isymbuf1 == NULL)
+ {
+ isymbuf1 = bfd_elf_get_elf_syms (bfd1, hdr1, symcount1, 0,
+ NULL, NULL, NULL);
+ if (isymbuf1 == NULL)
+ goto done;
+ /* Sort symbols by binding and section. Global definitions are at
+ the beginning. */
+ qsort (isymbuf1, symcount1, sizeof (Elf_Internal_Sym),
+ elf_sort_elf_symbol);
+ if (!info->reduce_memory_overheads)
+ elf_tdata (bfd1)->symbuf = isymbuf1;
+ }
+
+ if (isymbuf2 == NULL)
+ {
+ isymbuf2 = bfd_elf_get_elf_syms (bfd2, hdr2, symcount2, 0,
+ NULL, NULL, NULL);
+ if (isymbuf2 == NULL)
+ goto done;
+ /* Sort symbols by binding and section. Global definitions are at
+ the beginning. */
+ qsort (isymbuf2, symcount2, sizeof (Elf_Internal_Sym),
+ elf_sort_elf_symbol);
+ if (!info->reduce_memory_overheads)
+ elf_tdata (bfd2)->symbuf = isymbuf2;
+ }
/* Count definitions in the section. */
count1 = 0;
@@ -8828,10 +8845,13 @@ done:
free (symtable1);
if (symtable2)
free (symtable2);
- if (isymbuf1)
- free (isymbuf1);
- if (isymbuf2)
- free (isymbuf2);
+ if (info->reduce_memory_overheads)
+ {
+ if (isymbuf1)
+ free (isymbuf1);
+ if (isymbuf2)
+ free (isymbuf2);
+ }
return result;
}
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 1dad5047727..df7b899c9a6 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -7267,14 +7267,15 @@ _bfd_elf_default_action_discarded (asection *sec)
/* Find a match between a section and a member of a section group. */
static asection *
-match_group_member (asection *sec, asection *group)
+match_group_member (asection *sec, asection *group,
+ struct bfd_link_info *info)
{
asection *first = elf_next_in_group (group);
asection *s = first;
while (s != NULL)
{
- if (bfd_elf_match_symbols_in_sections (s, sec))
+ if (bfd_elf_match_symbols_in_sections (s, sec, info))
return s;
s = elf_next_in_group (s);
@@ -7290,7 +7291,7 @@ match_group_member (asection *sec, asection *group)
NULL. */
asection *
-_bfd_elf_check_kept_section (asection *sec)
+_bfd_elf_check_kept_section (asection *sec, struct bfd_link_info *info)
{
asection *kept;
@@ -7298,7 +7299,7 @@ _bfd_elf_check_kept_section (asection *sec)
if (kept != NULL)
{
if (elf_sec_group (sec) != NULL)
- kept = match_group_member (sec, kept);
+ kept = match_group_member (sec, kept, info);
if (kept != NULL && sec->size != kept->size)
kept = NULL;
}
@@ -7651,7 +7652,8 @@ elf_link_input_bfd (struct elf_final_link_info *finfo, bfd *input_bfd)
{
asection *kept;
- kept = _bfd_elf_check_kept_section (sec);
+ kept = _bfd_elf_check_kept_section (sec,
+ finfo->info);
if (kept != NULL)
{
*ps = kept;
@@ -8800,6 +8802,17 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info)
}
}
+ /* Free symbol buffer if needed. */
+ if (!info->reduce_memory_overheads)
+ {
+ for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
+ if (elf_tdata (sub)->symbuf)
+ {
+ free (elf_tdata (sub)->symbuf);
+ elf_tdata (sub)->symbuf = NULL;
+ }
+ }
+
/* Output any global symbols that got converted to local in a
version script or due to symbol visibility. We do this in a
separate step since ELF requires all local symbols to appear
@@ -10296,7 +10309,8 @@ bfd_elf_discard_info (bfd *output_bfd, struct bfd_link_info *info)
}
void
-_bfd_elf_section_already_linked (bfd *abfd, struct bfd_section * sec)
+_bfd_elf_section_already_linked (bfd *abfd, struct bfd_section *sec,
+ struct bfd_link_info *info)
{
flagword flags;
const char *name, *p;
@@ -10462,7 +10476,8 @@ _bfd_elf_section_already_linked (bfd *abfd, struct bfd_section * sec)
if ((l->sec->flags & SEC_GROUP) == 0
&& bfd_coff_get_comdat_section (l->sec->owner, l->sec) == NULL
&& bfd_elf_match_symbols_in_sections (l->sec,
- elf_next_in_group (sec)))
+ elf_next_in_group (sec),
+ info))
{
elf_next_in_group (sec)->output_section = bfd_abs_section_ptr;
elf_next_in_group (sec)->kept_section = l->sec;
@@ -10483,7 +10498,7 @@ _bfd_elf_section_already_linked (bfd *abfd, struct bfd_section * sec)
if (first != NULL
&& elf_next_in_group (first) == first
- && bfd_elf_match_symbols_in_sections (first, sec))
+ && bfd_elf_match_symbols_in_sections (first, sec, info))
{
sec->output_section = bfd_abs_section_ptr;
sec->kept_section = l->sec;
diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h
index 52172c1680f..a9c96db4e9f 100644
--- a/bfd/libbfd-in.h
+++ b/bfd/libbfd-in.h
@@ -410,7 +410,7 @@ extern bfd_boolean _bfd_generic_set_section_contents
#define _bfd_nolink_bfd_link_split_section \
((bfd_boolean (*) (bfd *, struct bfd_section *)) bfd_false)
#define _bfd_nolink_section_already_linked \
- ((void (*) (bfd *, struct bfd_section *)) bfd_void)
+ ((void (*) (bfd *, struct bfd_section *, struct bfd_link_info *)) bfd_void)
/* Routines to use for BFD_JUMP_TABLE_DYNAMIC for targets which do not
have dynamic symbols or relocs. Use BFD_JUMP_TABLE_DYNAMIC
@@ -524,7 +524,7 @@ extern bfd_boolean _bfd_generic_link_split_section
(bfd *, struct bfd_section *);
extern void _bfd_generic_section_already_linked
- (bfd *, struct bfd_section *);
+ (bfd *, struct bfd_section *, struct bfd_link_info *);
/* Generic reloc_link_order processing routine. */
extern bfd_boolean _bfd_generic_reloc_link_order
diff --git a/bfd/libbfd.h b/bfd/libbfd.h
index a4c4f011e27..92dfc151de4 100644
--- a/bfd/libbfd.h
+++ b/bfd/libbfd.h
@@ -415,7 +415,7 @@ extern bfd_boolean _bfd_generic_set_section_contents
#define _bfd_nolink_bfd_link_split_section \
((bfd_boolean (*) (bfd *, struct bfd_section *)) bfd_false)
#define _bfd_nolink_section_already_linked \
- ((void (*) (bfd *, struct bfd_section *)) bfd_void)
+ ((void (*) (bfd *, struct bfd_section *, struct bfd_link_info *)) bfd_void)
/* Routines to use for BFD_JUMP_TABLE_DYNAMIC for targets which do not
have dynamic symbols or relocs. Use BFD_JUMP_TABLE_DYNAMIC
@@ -529,7 +529,7 @@ extern bfd_boolean _bfd_generic_link_split_section
(bfd *, struct bfd_section *);
extern void _bfd_generic_section_already_linked
- (bfd *, struct bfd_section *);
+ (bfd *, struct bfd_section *, struct bfd_link_info *);
/* Generic reloc_link_order processing routine. */
extern bfd_boolean _bfd_generic_reloc_link_order
diff --git a/bfd/linker.c b/bfd/linker.c
index 8d881c60606..b9aaf008b37 100644
--- a/bfd/linker.c
+++ b/bfd/linker.c
@@ -2876,14 +2876,15 @@ FUNCTION
bfd_section_already_linked
SYNOPSIS
- void bfd_section_already_linked (bfd *abfd, asection *sec);
+ void bfd_section_already_linked (bfd *abfd, asection *sec,
+ struct bfd_link_info *info);
DESCRIPTION
Check if @var{sec} has been already linked during a reloceatable
or final link.
-.#define bfd_section_already_linked(abfd, sec) \
-. BFD_SEND (abfd, _section_already_linked, (abfd, sec))
+.#define bfd_section_already_linked(abfd, sec, info) \
+. BFD_SEND (abfd, _section_already_linked, (abfd, sec, info))
.
*/
@@ -2969,7 +2970,8 @@ bfd_section_already_linked_table_free (void)
/* This is used on non-ELF inputs. */
void
-_bfd_generic_section_already_linked (bfd *abfd, asection *sec)
+_bfd_generic_section_already_linked (bfd *abfd, asection *sec,
+ struct bfd_link_info *info ATTRIBUTE_UNUSED)
{
flagword flags;
const char *name;
diff --git a/bfd/targets.c b/bfd/targets.c
index dac113631d7..71e3337f4a2 100644
--- a/bfd/targets.c
+++ b/bfd/targets.c
@@ -481,7 +481,8 @@ BFD_JUMP_TABLE macros.
.
. {* Check if SEC has been already linked during a reloceatable or
. final link. *}
-. void (*_section_already_linked) (bfd *, struct bfd_section *);
+. void (*_section_already_linked) (bfd *, struct bfd_section *,
+. struct bfd_link_info *);
.
. {* Routines to handle dynamic symbols and relocs. *}
.#define BFD_JUMP_TABLE_DYNAMIC(NAME) \
diff --git a/include/ChangeLog b/include/ChangeLog
index 23841a58692..3edbe8d069b 100644
--- a/include/ChangeLog
+++ b/include/ChangeLog
@@ -1,3 +1,8 @@
+2006-10-30 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/3111
+ * bfdlink.h (bfd_link_info): Add reduce_memory_overheads.
+
2006-10-25 Trevor Smigiel <Trevor_Smigiel@playstation.sony.com>
Yukishige Shibata <shibata@rd.scei.sony.co.jp>
Nobuhisa Fujinami <fnami@rd.scei.sony.co.jp>
diff --git a/include/bfdlink.h b/include/bfdlink.h
index 0cc91775ae7..228cab8fd97 100644
--- a/include/bfdlink.h
+++ b/include/bfdlink.h
@@ -335,6 +335,11 @@ struct bfd_link_info
/* TRUE if .gnu.hash section should be created. */
unsigned int emit_gnu_hash: 1;
+ /* If TRUE reduce memory overheads, at the expense of speed. This will
+ cause map file generation to use an O(N^2) algorithm and disable
+ caching ELF symbol buffer. */
+ unsigned int reduce_memory_overheads: 1;
+
/* What to do with unresolved symbols in an object file.
When producing executables the default is GENERATE_ERROR.
When producing shared libraries the default is IGNORE. The