aboutsummaryrefslogtreecommitdiff
path: root/bfd/oasys.c
diff options
context:
space:
mode:
authorSteve Chamberlain <sac@cygnus>1992-10-08 16:02:09 +0000
committerSteve Chamberlain <sac@cygnus>1992-10-08 16:02:09 +0000
commit294eaca479e9ced9a87b958c37feb2c570aa1595 (patch)
treebb7a6bb0ac1df535df9c7fe230c1a0bc81b85ab3 /bfd/oasys.c
parent0da7012441eaccf157dc44c8cc110fbf2d3f8376 (diff)
downloadgdb-294eaca479e9ced9a87b958c37feb2c570aa1595.zip
gdb-294eaca479e9ced9a87b958c37feb2c570aa1595.tar.gz
gdb-294eaca479e9ced9a87b958c37feb2c570aa1595.tar.bz2
Some of these are guesses, if you know different, just yell.
Thu Oct 8 08:52:48 1992 Steve Chamberlain (sac@thepub.cygnus.com) Now a bfd knows whether underscores are normally prepended to symbols in its file format. Helps with error messages. * aout-adobe.c, aout-target.h, bout.c, coff-a29k.c, coff-h8300.c, coff-z8k.c: targets set so they have leading underscore * coff-i386.c, coff-i960.c, coff-m68k.c, coff-mips.c, coff-m88k.c, coff-rs6000.c, coff-we32k.c, elf.c, ieee.c, srec.c: targets set without leading underscore flag * targets.c: add symbol leading char to xvec description * bfd-in.h (bfd_get_symbol_leading_char): new macro.
Diffstat (limited to 'bfd/oasys.c')
-rw-r--r--bfd/oasys.c62
1 files changed, 42 insertions, 20 deletions
diff --git a/bfd/oasys.c b/bfd/oasys.c
index 7a7d1d4..7a01015 100644
--- a/bfd/oasys.c
+++ b/bfd/oasys.c
@@ -18,8 +18,6 @@ You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-/* $Id$ */
-
#define UNDERSCORE_HACK 1
#include "bfd.h"
#include "sysdep.h"
@@ -871,6 +869,10 @@ DEFUN(oasys_write_syms, (abfd),
}
bfd_h_put_16(abfd, 0, (uint8e_type *)(&symbol.refno[0]));
}
+#ifdef UNDERSCORE_HACK
+ if (src[l] == '_')
+ dst[l++] = '.';
+#endif
while (src[l]) {
dst[l] = src[l];
l++;
@@ -994,7 +996,7 @@ DEFUN(oasys_write_data, (abfd),
unsigned int relocs_to_go = s->reloc_count;
arelent **p = s->orelocation;
if (s->reloc_count != 0) {
- /* Sort the reloc records so it's easy to insert the relocs into the
+/* Sort the reloc records so it's easy to insert the relocs into the
data */
qsort(s->orelocation,
@@ -1013,21 +1015,23 @@ DEFUN(oasys_write_data, (abfd),
uint8e_type *dst = &processed_data.data[1];
unsigned int i;
- unsigned int long_length = 128;
+ *mod = 0;
- bfd_h_put_32(abfd, s->vma + current_byte_index, processed_data.addr);
- if ((size_t)(long_length + current_byte_index) > (size_t)(s->_cooked_size)) {
- long_length = s->_cooked_size - current_byte_index;
- }
- while (long_length > 0 && (dst - (uint8e_type*)&processed_data < 128)) {
-
- unsigned int length = long_length;
- *mod =0;
- if (length > 8)
- length = 8;
+ bfd_h_put_32(abfd, s->vma + current_byte_index,
+ processed_data.addr);
+
+ /* Don't start a relocation unless you're sure you can finish it
+ within the same data record. The worst case relocation is a
+ 4-byte relocatable value which is split across two modification
+ bytes (1 relocation byte + 2 symbol reference bytes + 2 data +
+ 1 modification byte + 2 data = 8 bytes total). That's where
+ the magic number 8 comes from.
+ */
+ while (current_byte_index < s->_raw_size && dst <=
+ (uint8e_type*)&processed_data.data[sizeof(processed_data.data)-8]) {
+
- for (i = 0; i < length; i++) {
if (relocs_to_go != 0) {
arelent *r = *p;
reloc_howto_type *CONST how=r->howto;
@@ -1104,6 +1108,21 @@ DEFUN(oasys_write_data, (abfd),
}
}
+#define ADVANCE { if (++i >= 8) { i = 0; mod = dst++; *mod = 0; } current_byte_index++; }
+ /* relocations never occur from an unloadable section,
+ so we can assume that raw_data is not NULL
+ */
+ *dst++ = *raw_data++;
+ ADVANCE
+ *dst++ = *raw_data++;
+ ADVANCE
+ if (how->size == 2) {
+ *dst++ = *raw_data++;
+ ADVANCE
+ *dst++ = *raw_data++;
+ ADVANCE
+ }
+ continue;
}
}
/* If this is coming from an unloadable section then copy
@@ -1114,10 +1133,12 @@ DEFUN(oasys_write_data, (abfd),
else {
*dst++ = *raw_data++;
}
- current_byte_index++;
- }
- mod = dst++;
- long_length -= length;
+ ADVANCE
+ }
+
+ /* Don't write a useless null modification byte */
+ if (dst == mod+1) {
+ --dst;
}
oasys_write_record(abfd,
@@ -1288,7 +1309,7 @@ return 0;
#define oasys_bfd_debug_info_end bfd_void
#define oasys_bfd_debug_info_accumulate (FOO(void, (*), (bfd *, asection *)))bfd_void
#define oasys_bfd_get_relocated_section_contents bfd_generic_get_relocated_section_contents
-
+#define oasys_bfd_relax_section bfd_generic_relax_section
/*SUPPRESS 460 */
bfd_target oasys_vec =
{
@@ -1301,6 +1322,7 @@ bfd_target oasys_vec =
HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
(SEC_CODE|SEC_DATA|SEC_ROM|SEC_HAS_CONTENTS
|SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
+ 0, /* leading underscore */
' ', /* ar_pad_char */
16, /* ar_max_namelen */
1, /* minimum alignment */