From: Alan Modra Date: Tue, 9 Oct 2001 13:12:19 +0000 (+0000) Subject: * elf-bfd.h (struct bfd_elf_section_data): Rename "group" to X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=945906ff86c2abf0f631417db3baa2cce93196f5;p=binutils-gdb.git * elf-bfd.h (struct bfd_elf_section_data): Rename "group" to "group_name". (elf_group_name): Define. (elf_next_in_group): Define. * elf.c: Make use of elf_group_name and elf_next_in_group throughout. (setup_group): Don't use sec->lineno for SHT_GROUP section to store first member section; Instead use elf_next_in_group. (bfd_section_from_shdr): Likewise. (set_group_contents): Likewise. Use elf_section_syms, not sec->symbol. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 9aa571c073c..ca340e77771 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,15 @@ +2001-10-09 Alan Modra + + * elf-bfd.h (struct bfd_elf_section_data): Rename "group" to + "group_name". + (elf_group_name): Define. + (elf_next_in_group): Define. + * elf.c: Make use of elf_group_name and elf_next_in_group throughout. + (setup_group): Don't use sec->lineno for SHT_GROUP section to store + first member section; Instead use elf_next_in_group. + (bfd_section_from_shdr): Likewise. + (set_group_contents): Likewise. Use elf_section_syms, not sec->symbol. + 2001-10-09 Alan Modra * elf-bfd.h (struct bfd_elf_section_data): Add "group" and @@ -12,6 +24,7 @@ (set_group_contents): New function. (_bfd_elf_compute_section_file_positions): Call it. (assign_section_numbers): Set sh_link for SHT_GROUP. + * elflink.h (gc_mark_hook): Handle section groups. * elfxx-target.h: Add SEC_GROUP to applicable_flags. * section.c (SEC_GROUP): Define. diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h index 50c8b2b5dd9..fdb69c6097d 100644 --- a/bfd/elf-bfd.h +++ b/bfd/elf-bfd.h @@ -816,7 +816,7 @@ struct bfd_elf_section_data PTR merge_info; /* Group name, if this section is part of a group. */ - const char *group; + const char *group_name; /* A linked list of sections in the group. Circular when used by the linker. */ @@ -830,6 +830,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_next_in_group(sec) (elf_section_data(sec)->next_in_group) #define get_elf_backend_data(abfd) \ ((struct elf_backend_data *) (abfd)->xvec->backend_data) diff --git a/bfd/elf.c b/bfd/elf.c index a3a83e4b32e..30104185a43 100644 --- a/bfd/elf.c +++ b/bfd/elf.c @@ -475,20 +475,15 @@ setup_group (abfd, hdr, newsect) n_elt = shdr->sh_size / 4; while (--n_elt != 0) if ((s = (++idx)->shdr->bfd_section) != NULL - && elf_section_data (s)->next_in_group != NULL) + && elf_next_in_group (s) != NULL) break; if (n_elt != 0) { - const char *gname; - asection *next; - /* Snarf the group name from other member, and insert current section in circular list. */ - gname = elf_section_data (s)->group; - elf_section_data (newsect)->group = gname; - next = elf_section_data (s)->next_in_group; - elf_section_data (newsect)->next_in_group = next; - elf_section_data (s)->next_in_group = newsect; + elf_group_name (newsect) = elf_group_name (s); + elf_next_in_group (newsect) = elf_next_in_group (s); + elf_next_in_group (s) = newsect; } else { @@ -511,20 +506,20 @@ setup_group (abfd, hdr, newsect) return false; iname = H_GET_32 (abfd, ename); gname = elf_string_from_elf_strtab (abfd, iname); - elf_section_data (newsect)->group = gname; + elf_group_name (newsect) = gname; /* Start a circular list with one element. */ - elf_section_data (newsect)->next_in_group = newsect; + elf_next_in_group (newsect) = newsect; } if (shdr->bfd_section != NULL) - shdr->bfd_section->lineno = (alent *) newsect; + elf_next_in_group (shdr->bfd_section) = newsect; i = num_group - 1; break; } } } - if (elf_section_data (newsect)->group == NULL) + if (elf_group_name (newsect) == NULL) { (*_bfd_error_handler) (_("%s: no group info for section %s"), bfd_archive_filename (abfd), newsect->name); @@ -1718,9 +1713,9 @@ bfd_section_from_shdr (abfd, shindex) while (--n_elt != 0) if ((s = (++idx)->shdr->bfd_section) != NULL - && elf_section_data (s)->next_in_group != NULL) + && elf_next_in_group (s) != NULL) { - hdr->bfd_section->lineno = (alent *) s; + elf_next_in_group (hdr->bfd_section) = s; break; } } @@ -2085,7 +2080,7 @@ elf_fake_sections (abfd, asect, failedptrarg) if ((asect->flags & SEC_STRINGS) != 0) this_hdr->sh_flags |= SHF_STRINGS; } - if (elf_section_data (asect)->group != NULL) + if (elf_group_name (asect) != NULL) this_hdr->sh_flags |= SHF_GROUP; /* Check for processor-specific section types. */ @@ -2123,10 +2118,11 @@ set_group_contents (abfd, sec, failedptrarg) return; /* If called from the assembler, swap_out_syms will have set up - udata.i; If called for "ld -r", the symbols won't yet be mapped, - so emulate elf_bfd_final_link. */ - symindx = sec->symbol->udata.i; - if (symindx == 0) + 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; elf_section_data (sec)->this_hdr.sh_info = symindx; @@ -2145,7 +2141,7 @@ set_group_contents (abfd, sec, failedptrarg) /* Get the pointer to the first section in the group that we squirreled away here. */ - elt = (asection *) sec->lineno; + elt = elf_next_in_group (sec); /* First element is a flag word. Rest of section is elf section indices for all the sections of the group. Write them backwards @@ -2155,7 +2151,7 @@ set_group_contents (abfd, sec, failedptrarg) { loc -= 4; H_PUT_32 (abfd, elf_section_data (elt)->this_idx, loc); - elt = elf_section_data (elt)->next_in_group; + elt = elf_next_in_group (elt); } /* If this is a relocatable link, then the above did nothing because @@ -2163,16 +2159,16 @@ set_group_contents (abfd, sec, failedptrarg) instead. */ for (l = sec->link_order_head; l != NULL; l = l->next) if (l->type == bfd_indirect_link_order - && (elt = (asection *) l->u.indirect.section->lineno) != NULL) + && (elt = elf_next_in_group (l->u.indirect.section)) != NULL) do { loc -= 4; H_PUT_32 (abfd, elf_section_data (elt->output_section)->this_idx, loc); - elt = elf_section_data (elt)->next_in_group; + elt = elf_next_in_group (elt); /* During a relocatable link, the lists are circular. */ } - while (elt != (asection *) l->u.indirect.section->lineno); + while (elt != elf_next_in_group (l->u.indirect.section)); loc -= 4; H_PUT_32 (abfd, 0, loc);