From 01cc8ff856f0530ce7333a7bdac283c51b0e4f5e Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Fri, 14 Apr 2000 01:58:29 +0000 Subject: Zero start address of orphan ~(SEC_LOAD | SEC_ALLOC) sections. --- ld/emultempl/armelf.em | 39 +++++++++++++++++++-------------------- ld/emultempl/elf32.em | 39 +++++++++++++++++++-------------------- ld/emultempl/pe.em | 7 ++----- 3 files changed, 40 insertions(+), 45 deletions(-) (limited to 'ld/emultempl') diff --git a/ld/emultempl/armelf.em b/ld/emultempl/armelf.em index c66d43f..e5f1514 100644 --- a/ld/emultempl/armelf.em +++ b/ld/emultempl/armelf.em @@ -813,9 +813,6 @@ gld${EMULATION_NAME}_place_orphan (file, s) const char *outsecname; lang_output_section_statement_type *os; - if ((s->flags & SEC_ALLOC) == 0) - return false; - /* Look through the script to see where to place this section. */ hold_section = s; hold_use = NULL; @@ -869,7 +866,7 @@ gld${EMULATION_NAME}_place_orphan (file, s) && hold_text.os != NULL) place = &hold_text; else - return false; + place = NULL; /* Choose a unique name for the section. This will be needed if the same section name appears in the input file with different @@ -901,7 +898,7 @@ gld${EMULATION_NAME}_place_orphan (file, s) if (snew == NULL) einfo ("%P%F: output format %s cannot represent section called %s\n", output_bfd->xvec->name, outsecname); - if (place->os->bfd_section != NULL) + if (place != NULL && place->os->bfd_section != NULL) { /* Unlink it first. */ for (pps = &output_bfd->sections; *pps != snew; pps = &(*pps)->next) @@ -936,10 +933,10 @@ gld${EMULATION_NAME}_place_orphan (file, s) << s->alignment_power)))); } - if (! link_info.relocateable) - address = NULL; - else + if (link_info.relocateable || (s->flags & (SEC_LOAD | SEC_ALLOC)) == 0) address = exp_intop ((bfd_vma) 0); + else + address = NULL; lang_enter_output_section_statement (outsecname, address, 0, (bfd_vma) 0, @@ -965,20 +962,22 @@ gld${EMULATION_NAME}_place_orphan (file, s) exp_nameop (NAME, "."))); } - if (! place->stmt) - { - /* Put the new statement list right at the head. */ - *add.tail = place->os->header.next; - place->os->header.next = add.head; - } - else + if (place != NULL) { - /* Put it after the last orphan statement we added. */ - *add.tail = *place->stmt; - *place->stmt = add.head; + if (! place->stmt) + { + /* Put the new statement list right at the head. */ + *add.tail = place->os->header.next; + place->os->header.next = add.head; + } + else + { + /* Put it after the last orphan statement we added. */ + *add.tail = *place->stmt; + *place->stmt = add.head; + } + place->stmt = add.tail; /* Save the end of this list. */ } - place->stmt = add.tail; /* Save the end of this list. */ - stat_ptr = old; return true; diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em index a25f211..2489779 100644 --- a/ld/emultempl/elf32.em +++ b/ld/emultempl/elf32.em @@ -895,9 +895,6 @@ gld${EMULATION_NAME}_place_orphan (file, s) const char *outsecname; lang_output_section_statement_type *os; - if ((s->flags & SEC_ALLOC) == 0) - return false; - /* Look through the script to see where to place this section. */ hold_section = s; hold_use = NULL; @@ -951,7 +948,7 @@ gld${EMULATION_NAME}_place_orphan (file, s) && hold_text.os != NULL) place = &hold_text; else - return false; + place = NULL; /* Choose a unique name for the section. This will be needed if the same section name appears in the input file with different @@ -983,7 +980,7 @@ gld${EMULATION_NAME}_place_orphan (file, s) if (snew == NULL) einfo ("%P%F: output format %s cannot represent section called %s\n", output_bfd->xvec->name, outsecname); - if (place->os->bfd_section != NULL) + if (place != NULL && place->os->bfd_section != NULL) { /* Unlink it first. */ for (pps = &output_bfd->sections; *pps != snew; pps = &(*pps)->next) @@ -1018,10 +1015,10 @@ gld${EMULATION_NAME}_place_orphan (file, s) << s->alignment_power)))); } - if (! link_info.relocateable) - address = NULL; - else + if (link_info.relocateable || (s->flags & (SEC_LOAD | SEC_ALLOC)) == 0) address = exp_intop ((bfd_vma) 0); + else + address = NULL; lang_enter_output_section_statement (outsecname, address, 0, (bfd_vma) 0, @@ -1047,20 +1044,22 @@ gld${EMULATION_NAME}_place_orphan (file, s) exp_nameop (NAME, "."))); } - if (! place->stmt) - { - /* Put the new statement list right at the head. */ - *add.tail = place->os->header.next; - place->os->header.next = add.head; - } - else + if (place != NULL) { - /* Put it after the last orphan statement we added. */ - *add.tail = *place->stmt; - *place->stmt = add.head; + if (! place->stmt) + { + /* Put the new statement list right at the head. */ + *add.tail = place->os->header.next; + place->os->header.next = add.head; + } + else + { + /* Put it after the last orphan statement we added. */ + *add.tail = *place->stmt; + *place->stmt = add.head; + } + place->stmt = add.tail; /* Save the end of this list. */ } - place->stmt = add.tail; /* Save the end of this list. */ - stat_ptr = old; return true; diff --git a/ld/emultempl/pe.em b/ld/emultempl/pe.em index 02ebd57..0a94f58 100644 --- a/ld/emultempl/pe.em +++ b/ld/emultempl/pe.em @@ -1100,9 +1100,6 @@ gld_${EMULATION_NAME}_place_orphan (file, s) const char *secname; char *dollar = NULL; - if ((s->flags & SEC_ALLOC) == 0) - return false; - secname = bfd_get_section_name (s->owner, s); /* Look through the script to see where to place this section. */ @@ -1199,8 +1196,8 @@ gld_${EMULATION_NAME}_place_orphan (file, s) stat_ptr = &add; lang_list_init (stat_ptr); - if (link_info.relocateable) - address = NULL; + if (link_info.relocateable || (s->flags & (SEC_LOAD | SEC_ALLOC)) == 0) + address = exp_intop ((bfd_vma) 0); else { /* All sections in an executable must be aligned to a page -- cgit v1.1