summaryrefslogtreecommitdiffstats
path: root/bfd/elf32-ip2k.c
diff options
context:
space:
mode:
Diffstat (limited to 'bfd/elf32-ip2k.c')
-rw-r--r--bfd/elf32-ip2k.c46
1 files changed, 18 insertions, 28 deletions
diff --git a/bfd/elf32-ip2k.c b/bfd/elf32-ip2k.c
index 6493be6995..758842b837 100644
--- a/bfd/elf32-ip2k.c
+++ b/bfd/elf32-ip2k.c
@@ -503,7 +503,7 @@ ip2k_is_switch_table_128 (abfd, sec, addr, contents)
int index = 0;
/* Check current page-jmp. */
- if (addr + 4 > sec->_cooked_size)
+ if (addr + 4 > sec->size)
return -1;
ip2k_get_mem (abfd, contents + addr, 4, code);
@@ -550,7 +550,7 @@ ip2k_relax_switch_table_128 (abfd, sec, irel, again, misc)
addr = irel->r_offset;
while (1)
{
- if (addr + 4 > sec->_cooked_size)
+ if (addr + 4 > sec->size)
break;
ip2k_get_mem (abfd, misc->contents + addr, 4, code);
@@ -656,7 +656,7 @@ ip2k_is_switch_table_256 (abfd, sec, addr, contents)
int index = 0;
/* Check current page-jmp. */
- if (addr + 4 > sec->_cooked_size)
+ if (addr + 4 > sec->size)
return -1;
ip2k_get_mem (abfd, contents + addr, 4, code);
@@ -718,7 +718,7 @@ ip2k_relax_switch_table_256 (abfd, sec, irel, again, misc)
while (1)
{
- if (addr + 4 > sec->_cooked_size)
+ if (addr + 4 > sec->size)
break;
ip2k_get_mem (abfd, misc->contents + addr, 4, code);
@@ -840,11 +840,6 @@ ip2k_elf_relax_section (abfd, sec, link_info, again)
|| (sec->flags & SEC_CODE) == 0)
return TRUE;
- /* If this is the first time we have been called
- for this section, initialise the cooked size. */
- if (sec->_cooked_size == 0)
- sec->_cooked_size = sec->_raw_size;
-
symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
internal_relocs = _bfd_elf_link_read_relocs (abfd, sec, NULL,
@@ -875,12 +870,7 @@ ip2k_elf_relax_section (abfd, sec, link_info, again)
else
{
/* Go get them off disk. */
- contents = (bfd_byte *) bfd_malloc (sec->_raw_size);
- if (contents == NULL)
- goto error_return;
-
- if (! bfd_get_section_contents (abfd, sec, contents,
- (file_ptr) 0, sec->_raw_size))
+ if (!bfd_malloc_and_get_section (abfd, sec, &contents))
goto error_return;
}
}
@@ -917,8 +907,8 @@ ip2k_elf_relax_section (abfd, sec, link_info, again)
search_addr = 0xFFFFFFFF;
}
- if ((BASEADDR (sec) + sec->_cooked_size < search_addr)
- && (BASEADDR (sec) + sec->_cooked_size > page_end))
+ if ((BASEADDR (sec) + sec->size < search_addr)
+ && (BASEADDR (sec) + sec->size > page_end))
{
if (BASEADDR (sec) <= page_end)
search_addr = page_end + 1;
@@ -940,7 +930,7 @@ ip2k_elf_relax_section (abfd, sec, link_info, again)
}
/* Only process sections in range. */
- if ((BASEADDR (sec) + sec->_cooked_size >= page_start)
+ if ((BASEADDR (sec) + sec->size >= page_start)
&& (BASEADDR (sec) <= page_end))
{
if (!ip2k_elf_relax_section_page (abfd, sec, &changed, &misc, page_start, page_end))
@@ -1137,6 +1127,7 @@ adjust_all_relocations (abfd, sec, addr, endaddr, count, noadj)
if (stab)
{
bfd_byte *stabcontents, *stabend, *stabp;
+ bfd_size_type stab_size = stab->rawsize ? stab->rawsize : stab->size;
irelbase = elf_section_data (stab)->relocs;
irelend = irelbase + stab->reloc_count;
@@ -1146,19 +1137,18 @@ adjust_all_relocations (abfd, sec, addr, endaddr, count, noadj)
stabcontents = elf_section_data (stab)->this_hdr.contents;
else
{
- stabcontents = (bfd_byte *) bfd_alloc (abfd, stab->_raw_size);
- if (stabcontents == NULL)
- return;
-
- if (! bfd_get_section_contents (abfd, stab, stabcontents,
- (file_ptr) 0, stab->_raw_size))
- return;
+ if (!bfd_malloc_and_get_section (abfd, stab, &stabcontents))
+ {
+ if (stabcontents != NULL)
+ free (stabcontents);
+ return;
+ }
/* We need to remember this. */
elf_section_data (stab)->this_hdr.contents = stabcontents;
}
- stabend = stabcontents + stab->_raw_size;
+ stabend = stabcontents + stab_size;
for (irel = irelbase; irel < irelend; irel++)
{
@@ -1308,13 +1298,13 @@ ip2k_elf_relax_delete_bytes (abfd, sec, addr, count)
int count;
{
bfd_byte *contents = elf_section_data (sec)->this_hdr.contents;
- bfd_vma endaddr = sec->_cooked_size;
+ bfd_vma endaddr = sec->size;
/* Actually delete the bytes. */
memmove (contents + addr, contents + addr + count,
endaddr - addr - count);
- sec->_cooked_size -= count;
+ sec->size -= count;
adjust_all_relocations (abfd, sec, addr + count, endaddr, -count, 0);
return TRUE;
OpenPOWER on IntegriCloud