diff options
author | Alan Modra <amodra@gmail.com> | 2005-11-24 06:02:08 +0000 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2005-11-24 06:02:08 +0000 |
commit | 390fbbf109a72362de0ff83ee32aedfe57c71292 (patch) | |
tree | de4002fa585abff2fd2da7d660e05d4bf7949f1f /ld | |
parent | be5291325d6402206276092e018ad6bb4210bcf0 (diff) | |
download | fsf-binutils-gdb-390fbbf109a72362de0ff83ee32aedfe57c71292.zip fsf-binutils-gdb-390fbbf109a72362de0ff83ee32aedfe57c71292.tar.gz fsf-binutils-gdb-390fbbf109a72362de0ff83ee32aedfe57c71292.tar.bz2 |
bfd/
* elf-bfd.h (_bfd_generic_match_sections_by_type): Don't define.
* libbfd-in.h (_bfd_generic_match_sections_by_type): Delete.
* libbfd.c (_bfd_generic_match_sections_by_type): Delete.
* targets.c (bfd_match_sections_by_type): Don't define.
(BFD_JUMP_TABLE_LINK): Remove _bfd_generic_match_sections_by_type.
* coff-rs6000.c (rs6000coff_vec, pmac_xcoff_vec): Likewise.
* coff64-rs6000.c (rs6000coff64_vec, aix5coff64_vec): Likewise.
* bfd-in2.h: Regenerate.
* libbfd.h: Regenerate.
ld/
* ldlang.c (lang_output_section_find_by_flags): Add match_type param.
Run two passes, first using match_type, second without.
* ldlang.h (lang_match_sec_type_func): New typedef.
(lang_output_section_find_by_flags): Update prototype.
bfd_match_sections_by_type and lang_output_section_find_by_flags.
* emultempl/pe.em (place_orphan): Likewise.
Diffstat (limited to 'ld')
-rw-r--r-- | ld/ChangeLog | 9 | ||||
-rw-r--r-- | ld/emultempl/elf32.em | 9 | ||||
-rw-r--r-- | ld/emultempl/pe.em | 2 | ||||
-rw-r--r-- | ld/ldlang.c | 76 | ||||
-rw-r--r-- | ld/ldlang.h | 6 |
5 files changed, 55 insertions, 47 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog index 977af6f..8fd73db 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,5 +1,14 @@ 2005-11-24 Alan Modra <amodra@bigpond.net.au> + * ldlang.c (lang_output_section_find_by_flags): Add match_type param. + Run two passes, first using match_type, second without. + * ldlang.h (lang_match_sec_type_func): New typedef. + (lang_output_section_find_by_flags): Update prototype. + bfd_match_sections_by_type and lang_output_section_find_by_flags. + * emultempl/pe.em (place_orphan): Likewise. + +2005-11-24 Alan Modra <amodra@bigpond.net.au> + * ldlang.c (lang_insert_orphan): Skip first assignment to dot in script when looking for place to insert orphan statements. diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em index d7d2f0e..55e1663 100644 --- a/ld/emultempl/elf32.em +++ b/ld/emultempl/elf32.em @@ -1362,9 +1362,9 @@ gld${EMULATION_NAME}_place_orphan (asection *s) if (os != NULL && (os->bfd_section == NULL || os->bfd_section->flags == 0 - || (bfd_match_sections_by_type (output_bfd, - os->bfd_section, - s->owner, s) + || (_bfd_elf_match_sections_by_type (output_bfd, + os->bfd_section, + s->owner, s) && ((s->flags ^ os->bfd_section->flags) & (SEC_LOAD | SEC_ALLOC)) == 0))) { @@ -1443,7 +1443,8 @@ gld${EMULATION_NAME}_place_orphan (asection *s) } after = place->os; if (after == NULL) - after = lang_output_section_find_by_flags (s, &place->os); + after = lang_output_section_find_by_flags + (s, &place->os, _bfd_elf_match_sections_by_type); if (after == NULL) /* *ABS* is always the first output section statement. */ after = &lang_output_section_statement.head->output_section_statement; diff --git a/ld/emultempl/pe.em b/ld/emultempl/pe.em index bcd7e32..5afa8da 100644 --- a/ld/emultempl/pe.em +++ b/ld/emultempl/pe.em @@ -1621,7 +1621,7 @@ gld_${EMULATION_NAME}_place_orphan (asection *s) place->os = lang_output_section_find (place->name); after = place->os; if (after == NULL) - after = lang_output_section_find_by_flags (s, &place->os); + after = lang_output_section_find_by_flags (s, &place->os, NULL); if (after == NULL) /* *ABS* is always the first output section statement. */ after = (&lang_output_section_statement.head diff --git a/ld/ldlang.c b/ld/ldlang.c index 119fb7a..0e72ab8 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -1147,7 +1147,8 @@ lang_output_section_statement_lookup (const char *const name) lang_output_section_statement_type * lang_output_section_find_by_flags (const asection *sec, - lang_output_section_statement_type **exact) + lang_output_section_statement_type **exact, + lang_match_sec_type_func match_type) { lang_output_section_statement_type *first, *look, *found; flagword flags; @@ -1165,9 +1166,8 @@ lang_output_section_find_by_flags (const asection *sec, if (look->bfd_section != NULL) { flags = look->bfd_section->flags; - if (!bfd_match_sections_by_type (output_bfd, - look->bfd_section, - sec->owner, sec)) + if (match_type && !match_type (output_bfd, look->bfd_section, + sec->owner, sec)) continue; } flags ^= sec->flags; @@ -1177,7 +1177,8 @@ lang_output_section_find_by_flags (const asection *sec, } if (found != NULL) { - *exact = found; + if (exact != NULL) + *exact = found; return found; } @@ -1190,9 +1191,8 @@ lang_output_section_find_by_flags (const asection *sec, if (look->bfd_section != NULL) { flags = look->bfd_section->flags; - if (!bfd_match_sections_by_type (output_bfd, - look->bfd_section, - sec->owner, sec)) + if (match_type && !match_type (output_bfd, look->bfd_section, + sec->owner, sec)) continue; } flags ^= sec->flags; @@ -1200,10 +1200,8 @@ lang_output_section_find_by_flags (const asection *sec, | SEC_CODE | SEC_SMALL_DATA | SEC_THREAD_LOCAL))) found = look; } - return found; } - - if (sec->flags & (SEC_READONLY | SEC_THREAD_LOCAL)) + else if (sec->flags & (SEC_READONLY | SEC_THREAD_LOCAL)) { /* .rodata can go after .text, .sdata2 after .rodata. */ for (look = first; look; look = look->next) @@ -1212,9 +1210,8 @@ lang_output_section_find_by_flags (const asection *sec, if (look->bfd_section != NULL) { flags = look->bfd_section->flags; - if (!bfd_match_sections_by_type (output_bfd, - look->bfd_section, - sec->owner, sec)) + if (match_type && !match_type (output_bfd, look->bfd_section, + sec->owner, sec)) continue; } flags ^= sec->flags; @@ -1223,10 +1220,8 @@ lang_output_section_find_by_flags (const asection *sec, && !(look->flags & (SEC_SMALL_DATA | SEC_THREAD_LOCAL))) found = look; } - return found; } - - if (sec->flags & SEC_SMALL_DATA) + else if (sec->flags & SEC_SMALL_DATA) { /* .sdata goes after .data, .sbss after .sdata. */ for (look = first; look; look = look->next) @@ -1235,9 +1230,8 @@ lang_output_section_find_by_flags (const asection *sec, if (look->bfd_section != NULL) { flags = look->bfd_section->flags; - if (!bfd_match_sections_by_type (output_bfd, - look->bfd_section, - sec->owner, sec)) + if (match_type && !match_type (output_bfd, look->bfd_section, + sec->owner, sec)) continue; } flags ^= sec->flags; @@ -1247,10 +1241,8 @@ lang_output_section_find_by_flags (const asection *sec, && !(sec->flags & SEC_HAS_CONTENTS))) found = look; } - return found; } - - if (sec->flags & SEC_HAS_CONTENTS) + else if (sec->flags & SEC_HAS_CONTENTS) { /* .data goes after .rodata. */ for (look = first; look; look = look->next) @@ -1259,9 +1251,8 @@ lang_output_section_find_by_flags (const asection *sec, if (look->bfd_section != NULL) { flags = look->bfd_section->flags; - if (!bfd_match_sections_by_type (output_bfd, - look->bfd_section, - sec->owner, sec)) + if (match_type && !match_type (output_bfd, look->bfd_section, + sec->owner, sec)) continue; } flags ^= sec->flags; @@ -1269,27 +1260,30 @@ lang_output_section_find_by_flags (const asection *sec, | SEC_SMALL_DATA | SEC_THREAD_LOCAL))) found = look; } - return found; } - - /* .bss goes last. */ - for (look = first; look; look = look->next) + else { - flags = look->flags; - if (look->bfd_section != NULL) + /* .bss goes last. */ + for (look = first; look; look = look->next) { - flags = look->bfd_section->flags; - if (!bfd_match_sections_by_type (output_bfd, - look->bfd_section, - sec->owner, sec)) - continue; + flags = look->flags; + if (look->bfd_section != NULL) + { + flags = look->bfd_section->flags; + if (match_type && !match_type (output_bfd, look->bfd_section, + sec->owner, sec)) + continue; + } + flags ^= sec->flags; + if (!(flags & SEC_ALLOC)) + found = look; } - flags ^= sec->flags; - if (!(flags & SEC_ALLOC)) - found = look; } - return found; + if (found || !match_type) + return found; + + return lang_output_section_find_by_flags (sec, NULL, NULL); } /* Find the last output section before given output statement. diff --git a/ld/ldlang.h b/ld/ldlang.h index 1613541..cf5b01f 100644 --- a/ld/ldlang.h +++ b/ld/ldlang.h @@ -304,6 +304,9 @@ typedef void (*walk_wild_section_handler_t) (lang_wild_statement_type *, callback_t callback, void *data); +typedef bfd_boolean (*lang_match_sec_type_func) (bfd *, const asection *, + bfd *, const asection *); + struct lang_wild_statement_struct { lang_statement_header_type header; @@ -521,7 +524,8 @@ extern void ldlang_add_file extern lang_output_section_statement_type *lang_output_section_find (const char * const); extern lang_output_section_statement_type *lang_output_section_find_by_flags - (const asection *, lang_output_section_statement_type **exact); + (const asection *, lang_output_section_statement_type **, + lang_match_sec_type_func); extern lang_output_section_statement_type *lang_insert_orphan (asection *, const char *, lang_output_section_statement_type *, struct orphan_save *, etree_type *, lang_statement_list_type *); |