diff options
author | Alan Modra <amodra@gmail.com> | 2004-06-29 14:13:47 +0000 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2004-06-29 14:13:47 +0000 |
commit | 1a23a9e6139ff1d1b19d242cf9c47f06c326df08 (patch) | |
tree | 768ba9a14f576385aa26e83c963c55f3a835a777 | |
parent | e87a64e1f0fb7718a214f10d6c31ce2050d4a760 (diff) | |
download | gdb-1a23a9e6139ff1d1b19d242cf9c47f06c326df08.zip gdb-1a23a9e6139ff1d1b19d242cf9c47f06c326df08.tar.gz gdb-1a23a9e6139ff1d1b19d242cf9c47f06c326df08.tar.bz2 |
bfd/
* elf64-mmix.c (mmix_set_relaxable_size): Save original size in
rawsize.
(mmix_elf_perform_relocation): Adjust for above change.
(mmix_elf_relocate_section): Likewise.
(mmix_elf_relax_section): Likewise. Use output_section->rawsize.
(mmix_elf_get_section_contents): Delete.
(bfd_elf64_get_section_contents): Delete.
(mmix_elf_relocate_section): Zero stub area.
* linker.c (default_indirect_link_order): Alloc max of section size
and rawsize.
* simple.c (bfd_simple_get_relocated_section_contents): Likewise.
* section.c (bfd_malloc_and_get_section): Likewise.
(struct bfd_section): Update rawsize comment.
* bfd-in2.h: Regenerate.
ld/
* ldlang.c (lang_reset_memory_regions): Save last relax pass section
size in rawsize.
-rw-r--r-- | bfd/ChangeLog | 15 | ||||
-rw-r--r-- | bfd/bfd-in2.h | 15 | ||||
-rw-r--r-- | bfd/elf64-mmix.c | 71 | ||||
-rw-r--r-- | bfd/linker.c | 4 | ||||
-rw-r--r-- | bfd/section.c | 17 | ||||
-rw-r--r-- | bfd/simple.c | 3 | ||||
-rw-r--r-- | ld/ChangeLog | 5 | ||||
-rw-r--r-- | ld/ldlang.c | 6 |
8 files changed, 59 insertions, 77 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 8e60114..c181a37 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,5 +1,20 @@ 2004-06-29 Alan Modra <amodra@bigpond.net.au> + * elf64-mmix.c (mmix_set_relaxable_size): Save original size in + rawsize. + (mmix_elf_perform_relocation): Adjust for above change. + (mmix_elf_relocate_section): Likewise. + (mmix_elf_relax_section): Likewise. Use output_section->rawsize. + (mmix_elf_get_section_contents): Delete. + (bfd_elf64_get_section_contents): Delete. + (mmix_elf_relocate_section): Zero stub area. + * linker.c (default_indirect_link_order): Alloc max of section size + and rawsize. + * simple.c (bfd_simple_get_relocated_section_contents): Likewise. + * section.c (bfd_malloc_and_get_section): Likewise. + (struct bfd_section): Update rawsize comment. + * bfd-in2.h: Regenerate. + * reloc16.c (bfd_coff_reloc16_relax_section): Set rawsize. 2004-06-29 Alan Modra <amodra@bigpond.net.au> diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index a3ace11..7335774 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -1290,13 +1290,14 @@ typedef struct bfd_section size of <<.bss>>). */ bfd_size_type size; - /* The original size on disk of the section, in octets. This field - is used by the linker relaxation code. It is currently only set - for sections where the linker relaxation scheme doesn't cache - altered section and reloc contents (stabs, eh_frame, SEC_MERGE), - and thus the original size needs to be kept to read the section - multiple times. If non-zero, rawsize will be used in address - checks during relocation and to read section contents. */ + /* For input sections, the original size on disk of the section, in + octets. This field is used by the linker relaxation code. It is + currently only set for sections where the linker relaxation scheme + doesn't cache altered section and reloc contents (stabs, eh_frame, + SEC_MERGE, some coff relaxing targets), and thus the original size + needs to be kept to read the section multiple times. + For output sections, rawsize holds the section size calculated on + a previous linker relaxation pass. */ bfd_size_type rawsize; /* If this section is going to be output, then this value is the diff --git a/bfd/elf64-mmix.c b/bfd/elf64-mmix.c index 0f9cd36..4a0c321 100644 --- a/bfd/elf64-mmix.c +++ b/bfd/elf64-mmix.c @@ -991,10 +991,7 @@ mmix_elf_perform_relocation (isec, howto, datap, addr, value) goto pcrel_mmix_reloc_fits; else { - bfd_size_type size - = (isec->size - - (mmix_elf_section_data (isec)->pjs.n_pushj_relocs - * MAX_PUSHJ_STUB_SIZE)); + bfd_size_type size = isec->rawsize ? isec->rawsize : isec->size; /* We have the bytes at the PUSHJ insn and need to get the position for the stub. There's supposed to be room allocated @@ -1341,16 +1338,20 @@ mmix_elf_relocate_section (output_bfd, info, input_bfd, input_section, struct elf_link_hash_entry **sym_hashes; Elf_Internal_Rela *rel; Elf_Internal_Rela *relend; - bfd_size_type size - = (input_section->size - - (mmix_elf_section_data (input_section)->pjs.n_pushj_relocs - * MAX_PUSHJ_STUB_SIZE)); + bfd_size_type size; size_t pjsno = 0; + size = input_section->rawsize ? input_section->rawsize : input_section->size; symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; sym_hashes = elf_sym_hashes (input_bfd); relend = relocs + input_section->reloc_count; + /* Zero the stub area before we start. */ + if (input_section->rawsize != 0 + && input_section->size > input_section->rawsize) + memset (contents + input_section->rawsize, 0, + input_section->size - input_section->rawsize); + for (rel = relocs; rel < relend; rel ++) { reloc_howto_type *howto; @@ -2308,6 +2309,7 @@ mmix_set_relaxable_size (abfd, sec, ptr) if (mmix_elf_section_data (sec)->pjs.n_pushj_relocs == 0) return; + sec->rawsize = sec->size; sec->size += (mmix_elf_section_data (sec)->pjs.n_pushj_relocs * MAX_PUSHJ_STUB_SIZE); @@ -2587,9 +2589,7 @@ mmix_elf_relax_section (abfd, sec, link_info, again) size_t pjsno = 0; bfd *bpo_greg_owner; Elf_Internal_Sym *isymbuf = NULL; - bfd_size_type size = (sec->size - - (mmix_elf_section_data (sec)->pjs.n_pushj_relocs - * MAX_PUSHJ_STUB_SIZE)); + bfd_size_type size = sec->rawsize ? sec->rawsize : sec->size; mmix_elf_section_data (sec)->pjs.stubs_size_sum = 0; @@ -2667,7 +2667,7 @@ mmix_elf_relax_section (abfd, sec, link_info, again) 0, bfd_arch_bits_per_address (abfd), /* Output-stub location. */ - sec->output_section->size + sec->output_section->rawsize + (mmix_elf_section_data (sec ->output_section) ->pjs.stubs_size_sum) @@ -2908,52 +2908,6 @@ mmix_elf_relax_section (abfd, sec, link_info, again) free (internal_relocs); return FALSE; } - -/* Because we set size to include the max size of pushj stubs, - i.e. larger than the actual section input size (see - mmix_set_relaxablesize), we have to take care of that when reading - the section. */ - -static bfd_boolean -mmix_elf_get_section_contents (abfd, section, location, offset, count) - bfd *abfd; - sec_ptr section; - void *location; - file_ptr offset; - bfd_size_type count; -{ - bfd_size_type size = (section->size - - (mmix_elf_section_data (section)->pjs.n_pushj_relocs - * MAX_PUSHJ_STUB_SIZE)); - - if (offset + count > section->size) - { - abort(); - bfd_set_error (bfd_error_invalid_operation); - return FALSE; - } - - /* Check bounds against the faked size. */ - if (offset + count > size) - { - /* Clear the part in the faked area. */ - memset (location + size - offset, 0, count - (size - offset)); - - /* If there's no initial part within the "real" contents, we're - done. */ - if ((bfd_size_type) offset >= size) - return TRUE; - - /* Else adjust the count and fall through to call the generic - function. */ - count = size - offset; - } - - return - _bfd_generic_get_section_contents (abfd, section, location, offset, - count); -} - #define ELF_ARCH bfd_arch_mmix #define ELF_MACHINE_CODE EM_MMIX @@ -3002,6 +2956,5 @@ mmix_elf_get_section_contents (abfd, section, location, offset, count) #define bfd_elf64_new_section_hook mmix_elf_new_section_hook #define bfd_elf64_bfd_final_link mmix_elf_final_link #define bfd_elf64_bfd_relax_section mmix_elf_relax_section -#define bfd_elf64_get_section_contents mmix_elf_get_section_contents #include "elf64-target.h" diff --git a/bfd/linker.c b/bfd/linker.c index 6ad32ba..10b4467 100644 --- a/bfd/linker.c +++ b/bfd/linker.c @@ -2756,7 +2756,9 @@ default_indirect_link_order (bfd *output_bfd, } /* Get and relocate the section contents. */ - sec_size = input_section->size; + sec_size = (input_section->rawsize > input_section->size + ? input_section->rawsize + : input_section->size); contents = bfd_malloc (sec_size); if (contents == NULL && sec_size != 0) goto error_return; diff --git a/bfd/section.c b/bfd/section.c index 70727ac..e178f58 100644 --- a/bfd/section.c +++ b/bfd/section.c @@ -424,13 +424,14 @@ CODE_FRAGMENT . size of <<.bss>>). *} . bfd_size_type size; . -. {* The original size on disk of the section, in octets. This field -. is used by the linker relaxation code. It is currently only set -. for sections where the linker relaxation scheme doesn't cache -. altered section and reloc contents (stabs, eh_frame, SEC_MERGE), -. and thus the original size needs to be kept to read the section -. multiple times. If non-zero, rawsize will be used in address -. checks during relocation and to read section contents. *} +. {* For input sections, the original size on disk of the section, in +. octets. This field is used by the linker relaxation code. It is +. currently only set for sections where the linker relaxation scheme +. doesn't cache altered section and reloc contents (stabs, eh_frame, +. SEC_MERGE, some coff relaxing targets), and thus the original size +. needs to be kept to read the section multiple times. +. For output sections, rawsize holds the section size calculated on +. a previous linker relaxation pass. *} . bfd_size_type rawsize; . . {* If this section is going to be output, then this value is the @@ -1379,7 +1380,7 @@ bfd_malloc_and_get_section (bfd *abfd, sec_ptr sec, bfd_byte **buf) if (sz == 0) return TRUE; - p = bfd_malloc (sz); + p = bfd_malloc (sec->rawsize > sec->size ? sec->rawsize : sec->size); if (p == NULL) return FALSE; *buf = p; diff --git a/bfd/simple.c b/bfd/simple.c index 0744215..5039911 100644 --- a/bfd/simple.c +++ b/bfd/simple.c @@ -143,10 +143,11 @@ bfd_simple_get_relocated_section_contents (bfd *abfd, if (! (sec->flags & SEC_RELOC)) { + bfd_size_type amt = sec->rawsize > sec->size ? sec->rawsize : sec->size; bfd_size_type size = sec->rawsize ? sec->rawsize : sec->size; if (outbuf == NULL) - contents = bfd_malloc (size); + contents = bfd_malloc (amt); else contents = outbuf; diff --git a/ld/ChangeLog b/ld/ChangeLog index 6495681..9d159db 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,8 @@ +2004-06-29 Alan Modra <amodra@bigpond.net.au> + + * ldlang.c (lang_reset_memory_regions): Save last relax pass section + size in rawsize. + 2004-06-24 Alan Modra <amodra@bigpond.net.au> * ldlang.c (print_output_section_statement): Don't print size before diff --git a/ld/ldlang.c b/ld/ldlang.c index 3d40982..8daf9c5 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -4235,7 +4235,11 @@ lang_reset_memory_regions (void) } for (o = output_bfd->sections; o != NULL; o = o->next) - o->size = 0; + { + /* Save the last size for possible use by bfd_relax_section. */ + o->rawsize = o->size; + o->size = 0; + } } /* Worker for lang_gc_sections_1. */ |