diff options
author | Alan Modra <amodra@gmail.com> | 2010-02-19 01:47:16 +0000 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2010-02-19 01:47:16 +0000 |
commit | d0bf826b37bdeb1ad98dc2d601b450bd5b9043e5 (patch) | |
tree | 6228351f86e84b5f27cf405eaa860fb830cc861a /ld | |
parent | 220453ec97481311a3cfd0d1a191c1bfe24f3b53 (diff) | |
download | gdb-d0bf826b37bdeb1ad98dc2d601b450bd5b9043e5.zip gdb-d0bf826b37bdeb1ad98dc2d601b450bd5b9043e5.tar.gz gdb-d0bf826b37bdeb1ad98dc2d601b450bd5b9043e5.tar.bz2 |
bfd/
* elf.c (_bfd_elf_fixup_group_sections): New function, split out from..
(_bfd_elf_copy_private_header_data): ..here.
* elflink.c (_bfd_elf_size_group_sections): New function.
(bfd_elf_size_dynamic_sections): Call it.
* elf-bfd.h (_bfd_elf_size_group_sections): Declare.
(_bfd_elf_fixup_group_sections): Declare.
ld/
* ldlang.c (unique_section_p): Add os param. Allow group
sections to match /DISCARD/. Update all callers.
* emultempl/genelf.em (gld${EMULATION_NAME}_before_allocation): New.
(LDEMUL_BEFORE_ALLOCATION): Define.
ld/testsuite/
* ld-elf/group.ld: Discard .dropme sections.
* ld-elf/group10.d, * ld-elf/group10.s: New test.
Diffstat (limited to 'ld')
-rw-r--r-- | ld/ChangeLog | 7 | ||||
-rw-r--r-- | ld/emultempl/genelf.em | 10 | ||||
-rw-r--r-- | ld/ldlang.c | 37 | ||||
-rw-r--r-- | ld/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/group.ld | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/group10.d | 11 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/group10.s | 14 |
7 files changed, 72 insertions, 14 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog index cc2b5e6..ce42f17 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,10 @@ +2010-02-19 Alan Modra <amodra@gmail.com> + + * ldlang.c (unique_section_p): Add os param. Allow group + sections to match /DISCARD/. Update all callers. + * emultempl/genelf.em (gld${EMULATION_NAME}_before_allocation): New. + (LDEMUL_BEFORE_ALLOCATION): Define. + 2010-02-15 Nick Clifton <nickc@redhat.com> * po/vi.po: Updated Vietnamese translation. diff --git a/ld/emultempl/genelf.em b/ld/emultempl/genelf.em index 1a6c539..62af4de 100644 --- a/ld/emultempl/genelf.em +++ b/ld/emultempl/genelf.em @@ -48,6 +48,15 @@ gld${EMULATION_NAME}_after_open (void) } static void +gld${EMULATION_NAME}_before_allocation (void) +{ + if (link_info.relocatable + && !_bfd_elf_size_group_sections (&link_info)) + einfo ("%X%P: can not size group sections: %E\n"); + before_allocation_default (); +} + +static void gld${EMULATION_NAME}_after_allocation (void) { gld${EMULATION_NAME}_map_segments (FALSE); @@ -56,4 +65,5 @@ EOF # Put these extra routines in ld_${EMULATION_NAME}_emulation # LDEMUL_AFTER_OPEN=gld${EMULATION_NAME}_after_open +LDEMUL_BEFORE_ALLOCATION=gld${EMULATION_NAME}_before_allocation LDEMUL_AFTER_ALLOCATION=gld${EMULATION_NAME}_after_allocation diff --git a/ld/ldlang.c b/ld/ldlang.c index fd75a5b..ce5a11c 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -195,7 +195,8 @@ input_statement_is_archive_path (const char *file_spec, char *sep, } static bfd_boolean -unique_section_p (const asection *sec) +unique_section_p (const asection *sec, + const lang_output_section_statement_type *os) { struct unique_sections *unam; const char *secnam; @@ -203,7 +204,8 @@ unique_section_p (const asection *sec) if (link_info.relocatable && sec->owner != NULL && bfd_is_group_section (sec->owner, sec)) - return TRUE; + return !(os != NULL + && strcmp (os->name, DISCARD_SECTION_NAME) == 0); secnam = sec->name; for (unam = unique_section_list; unam; unam = unam->next) @@ -445,12 +447,15 @@ output_section_callback_fast (lang_wild_statement_type *ptr, struct wildcard_list *sec, asection *section, lang_input_statement_type *file, - void *output ATTRIBUTE_UNUSED) + void *output) { lang_section_bst_type *node; lang_section_bst_type **tree; + lang_output_section_statement_type *os; - if (unique_section_p (section)) + os = (lang_output_section_statement_type *) output; + + if (unique_section_p (section, os)) return; node = (lang_section_bst_type *) xmalloc (sizeof (lang_section_bst_type)); @@ -2415,9 +2420,12 @@ output_section_callback (lang_wild_statement_type *ptr, void *output) { lang_statement_union_type *before; + lang_output_section_statement_type *os; + + os = (lang_output_section_statement_type *) output; /* Exclude sections that match UNIQUE_SECTION_LIST. */ - if (unique_section_p (section)) + if (unique_section_p (section, os)) return; before = wild_sort (ptr, sec, file, section); @@ -2428,16 +2436,14 @@ output_section_callback (lang_wild_statement_type *ptr, of the current list. */ if (before == NULL) - lang_add_section (&ptr->children, section, - (lang_output_section_statement_type *) output); + lang_add_section (&ptr->children, section, os); else { lang_statement_list_type list; lang_statement_union_type **pp; lang_list_init (&list); - lang_add_section (&list, section, - (lang_output_section_statement_type *) output); + lang_add_section (&list, section, os); /* If we are discarding the section, LIST.HEAD will be NULL. */ @@ -2464,14 +2470,18 @@ check_section_callback (lang_wild_statement_type *ptr ATTRIBUTE_UNUSED, struct wildcard_list *sec ATTRIBUTE_UNUSED, asection *section, lang_input_statement_type *file ATTRIBUTE_UNUSED, - void *data) + void *output) { + lang_output_section_statement_type *os; + + os = (lang_output_section_statement_type *) output; + /* Exclude sections that match UNIQUE_SECTION_LIST. */ - if (unique_section_p (section)) + if (unique_section_p (section, os)) return; if (section->output_section == NULL && (section->flags & SEC_READONLY) == 0) - ((lang_output_section_statement_type *) data)->all_input_readonly = FALSE; + os->all_input_readonly = FALSE; } /* This is passed a file name which must have been seen already and @@ -5848,7 +5858,8 @@ lang_place_orphans (void) const char *name = s->name; int constraint = 0; - if (config.unique_orphan_sections || unique_section_p (s)) + if (config.unique_orphan_sections + || unique_section_p (s, NULL)) constraint = SPECIAL; if (!ldemul_place_orphan (s, name, constraint)) diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index 8e075ed..e170dfc 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-02-19 Alan Modra <amodra@gmail.com> + + * ld-elf/group.ld: Discard .dropme sections. + * ld-elf/group10.d, * ld-elf/group10.s: New test. + 2010-02-18 Matthew Gretton-Dann <matthew.gretton-dann@arm.com> * ld-arm/attr-merge-6.attr: Add new test. Missed off last commit. diff --git a/ld/testsuite/ld-elf/group.ld b/ld/testsuite/ld-elf/group.ld index 58d78da..123ab26 100644 --- a/ld/testsuite/ld-elf/group.ld +++ b/ld/testsuite/ld-elf/group.ld @@ -2,5 +2,5 @@ SECTIONS { . = 0x1000; .text : { *(.text) *(.rodata.brlt) } - /DISCARD/ : { *(.reginfo) } + /DISCARD/ : { *(.dropme) *(.reginfo) } } diff --git a/ld/testsuite/ld-elf/group10.d b/ld/testsuite/ld-elf/group10.d new file mode 100644 index 0000000..d22a70a --- /dev/null +++ b/ld/testsuite/ld-elf/group10.d @@ -0,0 +1,11 @@ +#source: group10.s +#ld: -r -T group.ld +#readelf: -Sg --wide + +#... +group section \[[ 0-9]+\] `foo_group' \[foo_group\] contains 4 sections: + \[Index\] Name + \[[ 0-9]+\] \.text.* + \[[ 0-9]+\] \.rodata\.str.* + \[[ 0-9]+\] \.data.* + \[[ 0-9]+\] \.keepme.* diff --git a/ld/testsuite/ld-elf/group10.s b/ld/testsuite/ld-elf/group10.s new file mode 100644 index 0000000..57704b4 --- /dev/null +++ b/ld/testsuite/ld-elf/group10.s @@ -0,0 +1,14 @@ + .section .text.foo,"axG",%progbits,foo_group + .word 0 + + .section .rodata.str.1,"aMSG",%progbits,1,foo_group + .asciz "abc" + + .section .data.foo,"waG",%progbits,foo_group + .word 1 + + .section .dropme,"G",%progbits,foo_group + .word 2 + + .section .keepme,"G",%progbits,foo_group + .word 3 |