diff options
author | Ian Lance Taylor <ian@airs.com> | 1993-01-12 00:38:59 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@airs.com> | 1993-01-12 00:38:59 +0000 |
commit | 0c2fae099af0d4761fdfa79cccff8ec8e40c5fb0 (patch) | |
tree | 54881261b0f06e01ed0b0790c4c1fea1da801618 /bfd/seclet.c | |
parent | 870f29f564eedeb51ed20043c3e828cfeec72b67 (diff) | |
download | gdb-0c2fae099af0d4761fdfa79cccff8ec8e40c5fb0.zip gdb-0c2fae099af0d4761fdfa79cccff8ec8e40c5fb0.tar.gz gdb-0c2fae099af0d4761fdfa79cccff8ec8e40c5fb0.tar.bz2 |
Mon Jan 11 18:32:22 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
* targets.c (bfd_target): Added relocateable argument to
_bfd_get_relocated_section_contents. Added _bfd_seclet_link
target vector for linker use.
* bfd.c (bfd_seclet_link): New macro.
* bfd-in.h (JUMP_TABLE): Added _bfd_seclet_link.
* seclet.c (rel, seclet_dump_seclet): Added relocateable argument
and boolean return value. Made static.
(bfd_generic_seclet_link): Renamed from seclet_dump. Added
relocateable argument.
* reloc.c (bfd_generic_get_relocated_section_contents): Added
relocateable argument (if relocateable, saves relocs).
* bout.c (b_out_get_relocated_section_contents),
reloc16.c (bfd_coff_reloc16_get_relocated_section_contents): Added
relocateable argument (if relocateable, just calls
bfd_generic_get_relocated_section_contents).
* libcoff-in.h (bfd_coff_reloc16_get_value): Added relocateable
argument to prototype.
* All targets: Set new _bfd_seclet_link vector to
bfd_generic_seclet_link.
Diffstat (limited to 'bfd/seclet.c')
-rw-r--r-- | bfd/seclet.c | 119 |
1 files changed, 75 insertions, 44 deletions
diff --git a/bfd/seclet.c b/bfd/seclet.c index 9da4eb0..4615aee 100644 --- a/bfd/seclet.c +++ b/bfd/seclet.c @@ -46,6 +46,9 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "libbfd.h" #include "seclet.h" #include "coff/internal.h" + +/* Create a new seclet and attach it to a section. */ + bfd_seclet_type * DEFUN(bfd_new_seclet,(abfd, section), bfd *abfd AND @@ -64,19 +67,17 @@ DEFUN(bfd_new_seclet,(abfd, section), return n; } +/* Given an indirect seclet which points to an input section, relocate + the contents of the seclet and put the data in its final + destination. */ - - -#define MAX_ERRORS_IN_A_ROW 10 -extern bfd_error_vector_type bfd_error_vector; - - -void -DEFUN(rel,(abfd, seclet, output_section, data), +static boolean +DEFUN(rel,(abfd, seclet, output_section, data, relocateable), bfd *abfd AND bfd_seclet_type *seclet AND asection *output_section AND - PTR data) + PTR data AND + boolean relocateable) { if (output_section->flags & SEC_HAS_CONTENTS @@ -84,7 +85,8 @@ DEFUN(rel,(abfd, seclet, output_section, data), && (output_section->flags & SEC_LOAD) && seclet->size) { - data = (PTR) bfd_get_relocated_section_contents(abfd, seclet, data); + data = (PTR) bfd_get_relocated_section_contents(abfd, seclet, data, + relocateable); if(bfd_set_section_contents(abfd, output_section, data, @@ -94,59 +96,88 @@ DEFUN(rel,(abfd, seclet, output_section, data), abort(); } } + return true; } -void -DEFUN(seclet_dump_seclet,(abfd, seclet, section, data), +/* Put the contents of a seclet in its final destination. */ + +static boolean +DEFUN(seclet_dump_seclet,(abfd, seclet, section, data, relocateable), bfd *abfd AND bfd_seclet_type *seclet AND asection *section AND - PTR data) + PTR data AND + boolean relocateable) { switch (seclet->type) - { - case bfd_indirect_seclet: - /* The contents of this section come from another one somewhere - else */ - rel(abfd, seclet, section, data); - break; - case bfd_fill_seclet: - /* Fill in the section with us */ - { - char *d = bfd_xmalloc(seclet->size); - unsigned int i; - for (i =0; i < seclet->size; i+=2) { - d[i] = seclet->u.fill.value >> 8; - } - for (i = 1; i < seclet->size; i+=2) { - d[i] = seclet->u.fill.value ; - } - bfd_set_section_contents(abfd, section, d, seclet->offset, seclet->size); - - } - break; - default: - abort(); - } + { + case bfd_indirect_seclet: + /* The contents of this section come from another one somewhere + else */ + return rel(abfd, seclet, section, data, relocateable); + + case bfd_fill_seclet: + /* Fill in the section with us */ + { + char *d = bfd_xmalloc(seclet->size); + unsigned int i; + for (i =0; i < seclet->size; i+=2) { + d[i] = seclet->u.fill.value >> 8; + } + for (i = 1; i < seclet->size; i+=2) { + d[i] = seclet->u.fill.value ; + } + return bfd_set_section_contents(abfd, section, d, seclet->offset, + seclet->size); + } + + default: + abort(); + } + + return true; } -void -DEFUN(seclet_dump,(abfd, data), +/* +INTERNAL_FUNCTION + bfd_generic_seclet_link + +SYNOPSIS + boolean bfd_generic_seclet_link + (bfd *abfd, + PTR data, + boolean relocateable); + +DESCRIPTION + + The generic seclet linking routine. The caller should have + set up seclets for all the output sections. The DATA argument + should point to a memory area large enough to hold the largest + section. This function looks through the seclets and moves + the contents into the output sections. If RELOCATEABLE is + true, the orelocation fields of the output sections must + already be initialized. + +*/ + +boolean +DEFUN(bfd_generic_seclet_link,(abfd, data, relocateable), bfd *abfd AND - PTR data) + PTR data AND + boolean relocateable) { - /* Write all the seclets on the bfd out, relocate etc according to the - rules */ - asection *o = abfd->sections; while (o != (asection *)NULL) { bfd_seclet_type *p = o->seclets_head; while (p != (bfd_seclet_type *)NULL) { - seclet_dump_seclet(abfd, p, o, data); + if (seclet_dump_seclet(abfd, p, o, data, relocateable) == false) + return false; p = p ->next; } o = o->next; } + + return true; } |