From efa77952c8f99a5a6e0233e935a24ef6bad495b9 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Mon, 8 Jan 1996 22:02:36 +0000 Subject: [PATCH] * ieee.c (ieee_write_debug_part): Change return type to boolean. If there is a SEC_DEBUGGING section, get the contents of the debug information part from it. (ieee_set_section_contents): Store the contents of a SEC_DEBUGGING section in memory. (ieee_write_object_contents): Check ieee_write_debug_part return. --- bfd/ChangeLog | 9 ++++++ bfd/ieee.c | 83 +++++++++++++++++++++------------------------------ 2 files changed, 43 insertions(+), 49 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index c7a7bd777e0..ea3016a3c4f 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,12 @@ +Mon Jan 8 17:00:57 1996 Ian Lance Taylor + + * ieee.c (ieee_write_debug_part): Change return type to boolean. + If there is a SEC_DEBUGGING section, get the contents of the debug + information part from it. + (ieee_set_section_contents): Store the contents of a SEC_DEBUGGING + section in memory. + (ieee_write_object_contents): Check ieee_write_debug_part return. + Thu Jan 4 17:12:37 1996 Fred Fish * config.bfd (i[345]86-*-freebsd*): Add target. diff --git a/bfd/ieee.c b/bfd/ieee.c index 98e5b6eac5d..0defd3daaa3 100644 --- a/bfd/ieee.c +++ b/bfd/ieee.c @@ -44,6 +44,7 @@ static boolean do_as_repeat PARAMS ((bfd *, asection *)); static boolean do_without_relocs PARAMS ((bfd *, asection *)); static boolean ieee_write_external_part PARAMS ((bfd *)); static boolean ieee_write_data_part PARAMS ((bfd *)); +static boolean ieee_write_debug_part PARAMS ((bfd *)); static boolean ieee_write_me_part PARAMS ((bfd *)); static boolean ieee_slurp_debug PARAMS ((bfd *)); @@ -2905,7 +2906,7 @@ relocate_debug (output, input) the debug info in each, and copy it out, relocating it as we go. */ -static void +static boolean ieee_write_debug_part (abfd) bfd *abfd; { @@ -2922,53 +2923,20 @@ ieee_write_debug_part (abfd) if (chain == (bfd_chain_type *) NULL) { -#if 0 - /* There is no debug info, so we'll fake some up */ - CONST static char fake[] = - { - 0xf8, 0xa, 0, 5, 't', 't', 't', 't', 't', 0, 2, 3, - '1', '.', '1', 0x82, 1991 >> 8, 1991 & 0xff, 9, 20, 11, 07, 50}; - ieee->w.r.debug_information_part = 0; - - - here; - - - /* bfd_write(fake, 1, sizeof(fake), abfd);*/ - /* Now write a header for each section */ - { - int i = 0; - asection *s = abfd->sections; - while (s) - { - if (s != abfd->abs_section - && (s->flags & SEC_DEBUGGING) == 0) - { + asection *s; - if (! ieee_write_byte (abfd, 0xf8) - || ! ieee_write_byte (abfd, 0x0b) - || ! ieee_write_byte (abfd, 0) - || ! ieee_write_byte (abfd, 0) - || ! ieee_write_byte (abfd, 1) - || ! ieee_write_byte (abfd, i + IEEE_SECTION_NUMBER_BASE) - || ! ieee_write_expression (abfd, 0, s->symbol, 0, 0, 0) - || ! ieee_write_byte (abfd, 0) - || ! ieee_write_byte (abfd, 0xf9) - || ! ieee_write_expression (abfd, s->size, - bfd_abs_section_ptr->symbol, - 0, 0, 0)) - return false; - i++; - } - - s = s->next; + for (s = abfd->sections; s != NULL; s = s->next) + if ((s->flags & SEC_DEBUGGING) != 0) + break; + if (s == NULL) + { + ieee->w.r.debug_information_part = 0; + return true; + } - } - /* Close the scope */ - if (! ieee_write_byte (abfd, 0xf9)) - return false; - } -#endif + ieee->w.r.debug_information_part = here; + if (bfd_write (s->contents, 1, s->_raw_size, abfd) != s->_raw_size) + return false; } else { @@ -2981,7 +2949,7 @@ ieee_write_debug_part (abfd) if (bfd_seek (entry, entry_ieee->w.r.debug_information_part, SEEK_SET) != 0) - abort (); + return false; relocate_debug (abfd, entry); } @@ -2995,9 +2963,11 @@ ieee_write_debug_part (abfd) { ieee->w.r.debug_information_part = 0; } + + flush (); } - flush (); + return true; } /* Write the data in an ieee way. */ @@ -3063,6 +3033,20 @@ ieee_set_section_contents (abfd, section, location, offset, count) file_ptr offset; bfd_size_type count; { + if ((section->flags & SEC_DEBUGGING) != 0) + { + if (section->contents == NULL) + { + section->contents = bfd_alloc (abfd, section->_raw_size); + if (section->contents == NULL) + return false; + } + /* bfd_set_section_contents has already checked that everything + is within range. */ + memcpy (section->contents + offset, location, count); + return true; + } + if (ieee_per_section (section)->data == (bfd_byte *) NULL) { if (!init_for_output (abfd)) @@ -3300,7 +3284,8 @@ ieee_write_object_contents (abfd) /* Write any debugs we have been told about. */ - ieee_write_debug_part (abfd); + if (! ieee_write_debug_part (abfd)) + return false; /* Can only write the data once the symbols have been written, since the data contains relocation information which points to the -- 2.30.2