aboutsummaryrefslogtreecommitdiff
path: root/bfd/elfxx-mips.c
diff options
context:
space:
mode:
authorThiemo Seufer <ths@networkno.de>2002-07-19 21:34:02 +0000
committerThiemo Seufer <ths@networkno.de>2002-07-19 21:34:02 +0000
commitd01414a50120fb244c491c3d0bef4e62877ba01d (patch)
tree2ce1d20909192fa848a5d652db22d048d776393d /bfd/elfxx-mips.c
parentbad9ca53db89e2390fd03169301dda36252fd899 (diff)
downloadgdb-d01414a50120fb244c491c3d0bef4e62877ba01d.zip
gdb-d01414a50120fb244c491c3d0bef4e62877ba01d.tar.gz
gdb-d01414a50120fb244c491c3d0bef4e62877ba01d.tar.bz2
* elfxx-mips.c (_bfd_mips_elf_discard_info): New function, code from
elf32-mips.c. (_bfd_mips_elf_write_section): Likewise. * elfxx-mips.h (_bfd_mips_elf_discard_info): New prototype. (_bfd_mips_elf_write_section): Likewise. * elf32-mips.c (elf32_mips_discard_info): Move to elfxx-mips.c. (elf32_mips_write_section): Likewise. * elf64-mips.c (_bfd_mips_elf_ignore_discarded_relocs): Use it. (_bfd_mips_elf_write_section): Likewise.
Diffstat (limited to 'bfd/elfxx-mips.c')
-rw-r--r--bfd/elfxx-mips.c97
1 files changed, 97 insertions, 0 deletions
diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
index 8ae1930..3084885 100644
--- a/bfd/elfxx-mips.c
+++ b/bfd/elfxx-mips.c
@@ -6415,6 +6415,70 @@ _bfd_mips_elf_hide_symbol (info, entry, force_local)
got->_raw_size += MIPS_ELF_GOT_SIZE (dynobj);
}
+#define PDR_SIZE 32
+
+boolean
+_bfd_mips_elf_discard_info (abfd, cookie, info)
+ bfd *abfd;
+ struct elf_reloc_cookie *cookie;
+ struct bfd_link_info *info;
+{
+ asection *o;
+ boolean ret = false;
+ unsigned char *tdata;
+ size_t i, skip;
+
+ o = bfd_get_section_by_name (abfd, ".pdr");
+ if (! o)
+ return false;
+ if (o->_raw_size == 0)
+ return false;
+ if (o->_raw_size % PDR_SIZE != 0)
+ return false;
+ if (o->output_section != NULL
+ && bfd_is_abs_section (o->output_section))
+ return false;
+
+ tdata = bfd_zmalloc (o->_raw_size / PDR_SIZE);
+ if (! tdata)
+ return false;
+
+ cookie->rels = _bfd_elf32_link_read_relocs (abfd, o, (PTR) NULL,
+ (Elf_Internal_Rela *) NULL,
+ info->keep_memory);
+ if (!cookie->rels)
+ {
+ free (tdata);
+ return false;
+ }
+
+ cookie->rel = cookie->rels;
+ cookie->relend = cookie->rels + o->reloc_count;
+
+ for (i = 0, skip = 0; i < o->_raw_size; i ++)
+ {
+ if (_bfd_elf32_reloc_symbol_deleted_p (i * PDR_SIZE, cookie))
+ {
+ tdata[i] = 1;
+ skip ++;
+ }
+ }
+
+ if (skip != 0)
+ {
+ elf_section_data (o)->tdata = tdata;
+ o->_cooked_size = o->_raw_size - skip * PDR_SIZE;
+ ret = true;
+ }
+ else
+ free (tdata);
+
+ if (! info->keep_memory)
+ free (cookie->rels);
+
+ return ret;
+}
+
boolean
_bfd_mips_elf_ignore_discarded_relocs (sec)
asection *sec;
@@ -6423,6 +6487,39 @@ _bfd_mips_elf_ignore_discarded_relocs (sec)
return true;
return false;
}
+
+boolean
+_bfd_mips_elf_write_section (output_bfd, sec, contents)
+ bfd *output_bfd;
+ asection *sec;
+ bfd_byte *contents;
+{
+ bfd_byte *to, *from, *end;
+ int i;
+
+ if (strcmp (sec->name, ".pdr") != 0)
+ return false;
+
+ if (elf_section_data (sec)->tdata == NULL)
+ return false;
+
+ to = contents;
+ end = contents + sec->_raw_size;
+ for (from = contents, i = 0;
+ from < end;
+ from += PDR_SIZE, i++)
+ {
+ if (((unsigned char *) elf_section_data (sec)->tdata)[i] == 1)
+ continue;
+ if (to != from)
+ memcpy (to, from, PDR_SIZE);
+ to += PDR_SIZE;
+ }
+ bfd_set_section_contents (output_bfd, sec->output_section, contents,
+ (file_ptr) sec->output_offset,
+ sec->_cooked_size);
+ return true;
+}
/* MIPS ELF uses a special find_nearest_line routine in order the
handle the ECOFF debugging information. */