aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bfd/ChangeLog18
-rw-r--r--bfd/elf-bfd.h14
-rw-r--r--bfd/elf.c38
-rw-r--r--bfd/elflink.h18
4 files changed, 62 insertions, 26 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index e5a9074..1487314 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,23 @@
2002-06-07 Alan Modra <amodra@bigpond.net.au>
+ * elf-bfd.h (struct bfd_elf_section_data <group_name>): Replace with
+ "group" union.
+ (elf_group_name): Update.
+ (elf_group_id): Define.
+ (bfd_elf_set_group_contents): Declare.
+ * elf.c (elf_fake_sections): Qualify use of elf_group_name.
+ (set_group_contents): Rename to bfd_elf_set_group_contents. Remove
+ ATTRIBUTE_UNUSED from failedptrarg. If elf_group_id is set, use
+ that sym for the signature.
+ (_bfd_elf_compute_section_file_positions): Don't call
+ set_group_contents for "ld -r" case.
+ (swap_out_syms): Use bfd_zalloc.
+ * elflink.h (elf_link_add_archive_symbols): Likewise.
+ (NAME(bfd_elf,size_dynamic_sections)): Likewise.
+ (elf_bfd_final_link): Call bfd_elf_set_group_contents.
+
+2002-06-07 Alan Modra <amodra@bigpond.net.au>
+
* elf64-ppc.c (ppc64_elf_relocate_section): Allow unresolved
relocs in opd for non-shared too.
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index 238a6d6..28dbe83 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -916,8 +916,13 @@ struct bfd_elf_section_data
/* Type of that information. */
enum elf_link_info_type sec_info_type;
- /* Group name, if this section is part of a group. */
- const char *group_name;
+ union {
+ /* Group name, if this section is a member of a group. */
+ const char *name;
+
+ /* Group signature sym, if this is the SHT_GROUP section. */
+ struct symbol_cache_entry *id;
+ } group;
/* A linked list of sections in the group. Circular when used by
the linker. */
@@ -934,7 +939,8 @@ struct bfd_elf_section_data
};
#define elf_section_data(sec) ((struct bfd_elf_section_data*)sec->used_by_bfd)
-#define elf_group_name(sec) (elf_section_data(sec)->group_name)
+#define elf_group_name(sec) (elf_section_data(sec)->group.name)
+#define elf_group_id(sec) (elf_section_data(sec)->group.id)
#define elf_next_in_group(sec) (elf_section_data(sec)->next_in_group)
#define elf_linkonce_p(sec) (elf_section_data(sec)->linkonce_p)
@@ -1265,6 +1271,8 @@ extern boolean _bfd_elf_merge_sections
PARAMS ((bfd *, struct bfd_link_info *));
extern boolean bfd_elf_discard_group
PARAMS ((bfd *, struct sec *));
+extern void bfd_elf_set_group_contents
+ PARAMS ((bfd *, asection *, PTR));
extern void _bfd_elf_link_just_syms
PARAMS ((asection *, struct bfd_link_info *));
extern boolean _bfd_elf_copy_private_symbol_data
diff --git a/bfd/elf.c b/bfd/elf.c
index fd9aa4b..dd1b067 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -54,7 +54,6 @@ static const char *group_signature PARAMS ((bfd *, Elf_Internal_Shdr *));
static boolean setup_group PARAMS ((bfd *, Elf_Internal_Shdr *, asection *));
static void merge_sections_remove_hook PARAMS ((bfd *, asection *));
static void elf_fake_sections PARAMS ((bfd *, asection *, PTR));
-static void set_group_contents PARAMS ((bfd *, asection *, PTR));
static boolean assign_section_numbers PARAMS ((bfd *));
static INLINE int sym_is_global PARAMS ((bfd *, asymbol *));
static boolean elf_map_symbols PARAMS ((bfd *));
@@ -2358,7 +2357,7 @@ elf_fake_sections (abfd, asect, failedptrarg)
if ((asect->flags & SEC_STRINGS) != 0)
this_hdr->sh_flags |= SHF_STRINGS;
}
- if (elf_group_name (asect) != NULL)
+ if ((asect->flags & SEC_GROUP) == 0 && elf_group_name (asect) != NULL)
this_hdr->sh_flags |= SHF_GROUP;
if ((asect->flags & SEC_THREAD_LOCAL) != 0)
this_hdr->sh_flags |= SHF_TLS;
@@ -2382,11 +2381,11 @@ elf_fake_sections (abfd, asect, failedptrarg)
/* Fill in the contents of a SHT_GROUP section. */
-static void
-set_group_contents (abfd, sec, failedptrarg)
+void
+bfd_elf_set_group_contents (abfd, sec, failedptrarg)
bfd *abfd;
asection *sec;
- PTR failedptrarg ATTRIBUTE_UNUSED;
+ PTR failedptrarg;
{
boolean *failedptr = (boolean *) failedptrarg;
unsigned long symindx;
@@ -2399,16 +2398,22 @@ set_group_contents (abfd, sec, failedptrarg)
|| *failedptr)
return;
- /* If called from the assembler, swap_out_syms will have set up
- elf_section_syms; If called for "ld -r", the symbols won't yet
- be mapped, so emulate elf_bfd_final_link. */
- if (elf_section_syms (abfd) != NULL)
- symindx = elf_section_syms (abfd)[sec->index]->udata.i;
- else
- symindx = elf_section_data (sec)->this_idx;
+ symindx = 0;
+ if (elf_group_id (sec) != NULL)
+ symindx = elf_group_id (sec)->udata.i;
+
+ if (symindx == 0)
+ {
+ /* If called from the assembler, swap_out_syms will have set up
+ elf_section_syms; If called for "ld -r", use target_index. */
+ if (elf_section_syms (abfd) != NULL)
+ symindx = elf_section_syms (abfd)[sec->index]->udata.i;
+ else
+ symindx = sec->target_index;
+ }
elf_section_data (sec)->this_hdr.sh_info = symindx;
- /* Nor will the contents be allocated for "ld -r" or objcopy. */
+ /* The contents won't be allocated for "ld -r" or objcopy. */
gas = true;
if (sec->contents == NULL)
{
@@ -2959,9 +2964,9 @@ _bfd_elf_compute_section_file_positions (abfd, link_info)
return false;
}
- if (link_info == NULL || link_info->relocateable)
+ if (link_info == NULL)
{
- bfd_map_over_sections (abfd, set_group_contents, &failed);
+ bfd_map_over_sections (abfd, bfd_elf_set_group_contents, &failed);
if (failed)
return false;
}
@@ -5144,10 +5149,9 @@ swap_out_syms (abfd, sttp, relocatable_p)
if (symtab_shndx_hdr->sh_name != 0)
{
amt = (bfd_size_type) (1 + symcount) * sizeof (Elf_External_Sym_Shndx);
- outbound_shndx = bfd_alloc (abfd, amt);
+ outbound_shndx = bfd_zalloc (abfd, amt);
if (outbound_shndx == NULL)
return false;
- memset (outbound_shndx, 0, (unsigned long) amt);
symtab_shndx_hdr->contents = outbound_shndx;
symtab_shndx_hdr->sh_type = SHT_SYMTAB_SHNDX;
symtab_shndx_hdr->sh_size = amt;
diff --git a/bfd/elflink.h b/bfd/elflink.h
index e80e867..30ba4c1 100644
--- a/bfd/elflink.h
+++ b/bfd/elflink.h
@@ -313,12 +313,10 @@ elf_link_add_archive_symbols (abfd, info)
return true;
amt = c;
amt *= sizeof (boolean);
- defined = (boolean *) bfd_malloc (amt);
- included = (boolean *) bfd_malloc (amt);
+ defined = (boolean *) bfd_zmalloc (amt);
+ included = (boolean *) bfd_zmalloc (amt);
if (defined == (boolean *) NULL || included == (boolean *) NULL)
goto error_return;
- memset (defined, 0, (size_t) amt);
- memset (included, 0, (size_t) amt);
symdefs = bfd_ardata (abfd)->symdefs;
@@ -3665,10 +3663,9 @@ NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath,
BFD_ASSERT (s != NULL);
hash_entry_size = elf_section_data (s)->this_hdr.sh_entsize;
s->_raw_size = ((2 + bucketcount + dynsymcount) * hash_entry_size);
- s->contents = (bfd_byte *) bfd_alloc (output_bfd, s->_raw_size);
+ s->contents = (bfd_byte *) bfd_zalloc (output_bfd, s->_raw_size);
if (s->contents == NULL)
return false;
- memset (s->contents, 0, (size_t) s->_raw_size);
bfd_put (8 * hash_entry_size, output_bfd, (bfd_vma) bucketcount,
s->contents);
@@ -5811,6 +5808,15 @@ elf_bfd_final_link (abfd, info)
}
}
+ if (info->relocateable)
+ {
+ boolean failed = false;
+
+ bfd_map_over_sections (abfd, bfd_elf_set_group_contents, &failed);
+ if (failed)
+ goto error_return;
+ }
+
/* If we have optimized stabs strings, output them. */
if (elf_hash_table (info)->stab_info != NULL)
{