summaryrefslogtreecommitdiffstats
path: root/bfd
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2004-06-29 14:13:47 +0000
committerAlan Modra <amodra@gmail.com>2004-06-29 14:13:47 +0000
commit1a23a9e6139ff1d1b19d242cf9c47f06c326df08 (patch)
tree768ba9a14f576385aa26e83c963c55f3a835a777 /bfd
parente87a64e1f0fb7718a214f10d6c31ce2050d4a760 (diff)
downloadppe42-binutils-1a23a9e6139ff1d1b19d242cf9c47f06c326df08.tar.gz
ppe42-binutils-1a23a9e6139ff1d1b19d242cf9c47f06c326df08.zip
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.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog15
-rw-r--r--bfd/bfd-in2.h15
-rw-r--r--bfd/elf64-mmix.c71
-rw-r--r--bfd/linker.c4
-rw-r--r--bfd/section.c17
-rw-r--r--bfd/simple.c3
6 files changed, 49 insertions, 76 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 8e6011447f..c181a37169 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 a3ace1138a..7335774e6f 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 0f9cd36a79..4a0c32169a 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 6ad32ba953..10b4467944 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 70727ac74d..e178f5830a 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 0744215d24..5039911dcf 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;
OpenPOWER on IntegriCloud