aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bfd/ChangeLog9
-rw-r--r--bfd/coffcode.h45
-rw-r--r--bfd/ieee.c58
3 files changed, 77 insertions, 35 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 68a29dd..b045b6e 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,12 @@
+Mon Aug 24 12:06:31 1992 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * coffcode.h (coff_add_missing_symbols): if symbols don't come
+ from a coff file (csym is null), dont deref them
+
+ * ieee.c (parse_expression): get the answer right when adding an
+ abs+(sec+off), (ieee_generic_stat_arch_elt): call ieee_object_p
+ on elts so that filename is filled in.
+
Thu Aug 20 19:05:48 1992 Ken Raeburn (raeburn@cygnus.com)
* bout.c (howto_align_table): New set of relocs, with enough
diff --git a/bfd/coffcode.h b/bfd/coffcode.h
index 06b1b4e..cd3846f 100644
--- a/bfd/coffcode.h
+++ b/bfd/coffcode.h
@@ -1789,6 +1789,17 @@ DEFUN(coff_write_relocs,(abfd),
struct internal_reloc n;
arelent *q = p[i];
memset((PTR)&n, 0, sizeof(n));
+
+
+#ifndef SWAP_OUT_RELOC_OFFSET
+ /* @@FIXME COFF relocs don't support addends. Code should probably be
+ in the target-independent code, using a target flag to decide whether
+ to fold the addend into the section contents. */
+
+ if (q->addend != 0)
+ abort ();
+#endif
+
n.r_vaddr = q->address + s->vma;
/* The 29k const/consth reloc pair is a real kludge - the consth
part doesn't have a symbol - it has an offset. So rebuilt
@@ -2275,21 +2286,25 @@ coff_add_missing_symbols (abfd)
{
coff_symbol_type *csym = coff_symbol_from (abfd, sympp[i]);
CONST char *name;
-
- if (csym->native && csym->native->u.syment.n_sclass == C_FILE)
+ if (csym)
+ {
+ /* only do this if there is a coff representation of the input
+ symbol */
+ if (csym->native && csym->native->u.syment.n_sclass == C_FILE)
{
need_file = 0;
continue;
}
- name = csym->symbol.name;
- if (!name)
- continue;
- if (!strcmp (name, _TEXT))
- need_text = 0;
- else if (!strcmp (name, _DATA))
- need_data = 0;
- else if (!strcmp (name, _BSS))
- need_bss = 0;
+ name = csym->symbol.name;
+ if (!name)
+ continue;
+ if (!strcmp (name, _TEXT))
+ need_text = 0;
+ else if (!strcmp (name, _DATA))
+ need_data = 0;
+ else if (!strcmp (name, _BSS))
+ need_bss = 0;
+ }
}
/* Now i == bfd_get_symcount (abfd). */
/* @@ For now, don't deal with .file symbol. */
@@ -2311,7 +2326,7 @@ coff_add_missing_symbols (abfd)
sympp2[i++] = coff_section_symbol (abfd, _DATA);
if (need_bss)
sympp2[i++] = coff_section_symbol (abfd, _BSS);
- assert (i == nsyms);
+ BFD_ASSERT (i == nsyms);
bfd_set_symtab (abfd, sympp2, nsyms);
}
#endif /* NO_COFF_SYMBOLS */
@@ -3787,7 +3802,7 @@ DEFUN(perform_slip,(s, slip, input_section, value),
/* This was pointing into this section, so mangle it */
if (p->value > value)
{
- p->value -=2;
+ p->value -= slip;
}
}
s++;
@@ -4027,7 +4042,7 @@ DEFUN(bfd_coff_get_relocated_section_contents,(in_abfd, seclet, data),
*/
if (data[dst_address-1] != 0x6a)
abort();
- switch (data[dst_address] & 0xf0)
+ switch (data[src_address] & 0xf0)
{
case 0x00:
/* Src is memory */
@@ -4072,7 +4087,7 @@ DEFUN(bfd_coff_get_relocated_section_contents,(in_abfd, seclet, data),
case R_RELBYTE:
{
unsigned int gap =get_value(reloc,seclet);
- if (gap > 256)
+ if (gap > 0xff && gap < ~0xff)
{
bfd_error_vector.reloc_value_truncated(reloc, seclet);
}
diff --git a/bfd/ieee.c b/bfd/ieee.c
index 1121422..b4ee623 100644
--- a/bfd/ieee.c
+++ b/bfd/ieee.c
@@ -1,5 +1,6 @@
+
/* bfd back-end for ieee-695 objects.
- Copyright (C) 1990-1991 Free Software Foundation, Inc.
+ Copyright (C) 1990-1992 Free Software Foundation, Inc.
Written by Steve Chamberlain of Cygnus Support.
This file is part of BFD, the Binary File Descriptor library.
@@ -18,6 +19,8 @@ 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. */
+#define KEEPMINUSPCININST 1
+
/* IEEE 695 format is a stream of records, which we parse using a simple one-
token (which is one byte in this lexicon) lookahead recursive decent
parser. */
@@ -28,6 +31,11 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "ieee.h"
#include "libieee.h"
+
+#include "obstack.h"
+#define obstack_chunk_alloc bfd_xmalloc
+#define obstack_chunk_free free
+
/* Functions for writing to ieee files in the strange way that the
standard requires. */
@@ -362,26 +370,29 @@ reloc_howto_type abs8_howto
static
reloc_howto_type rel32_howto
- = HOWTO(1,0,2,32,true,0,false,true,0,"rel32",true,0xffffffff, 0xffffffff,true);
+ = HOWTO(1,0,2,32,true,0,false,true,0,"rel32",true,0xffffffff,
+ 0xffffffff,false);
+
static
reloc_howto_type rel16_howto
- = HOWTO(1,0,1,16,true,0,false,true,0,"rel16",true,0x0000ffff, 0x0000ffff,true);
+ = HOWTO(1,0,1,16,true,0,false,true,0,"rel16",true,0x0000ffff, 0x0000ffff,false);
static
reloc_howto_type rel8_howto
- = HOWTO(1,0,0,8,true,0,false,true,0,"rel8",true,0x000000ff, 0x000000ff,true);
+ = HOWTO(1,0,0,8,true,0,false,true,0,"rel8",true,0x000000ff, 0x000000ff,false);
static ieee_symbol_index_type NOSYMBOL = { 0, 0};
static void
-DEFUN(parse_expression,(ieee, value, symbol, pcrel, extra),
+DEFUN(parse_expression,(ieee, value, symbol, pcrel, extra, section),
ieee_data_type *ieee AND
bfd_vma *value AND
ieee_symbol_index_type *symbol AND
boolean *pcrel AND
- unsigned int *extra)
+ unsigned int *extra AND
+ asection **section)
{
#define POS sp[1]
@@ -467,7 +478,7 @@ DEFUN(parse_expression,(ieee, value, symbol, pcrel, extra),
POP(sy1, section1, value1);
POP(sy2, section2, value2);
- PUSH(sy1.letter ? sy1 : sy2, section1 ? section1: section2, value1+value2);
+ PUSH(sy1.letter ? sy1 : sy2, section1!=&bfd_abs_section ? section1: section2, value1+value2);
}
break;
default:
@@ -497,8 +508,9 @@ DEFUN(parse_expression,(ieee, value, symbol, pcrel, extra),
}
{
asection *dummy;
-
+
POP(*symbol, dummy, *value);
+ if (section) *section = dummy;
}
loop = false;
@@ -639,10 +651,10 @@ DEFUN(ieee_slurp_external_symbols,(abfd),
symbol_name_index = must_parse_int(&(ieee->h));
parse_expression(ieee,
&symbol->symbol.value,
- &symbol->symbol.section,
&symbol_ignore,
&pcrel_ignore,
- &extra);
+ &extra,
+ &symbol->symbol.section);
symbol->symbol.flags = BSF_GLOBAL | BSF_EXPORT;
@@ -981,7 +993,7 @@ DEFUN(ieee_archive_p,(abfd),
unsigned int i;
uint8e_type buffer[512];
-
+ struct obstack ob;
int buffer_offset = 0;
ieee_ar_data_type *save = abfd->tdata.ieee_ar_data;
ieee_ar_data_type *ieee ;
@@ -989,6 +1001,7 @@ uint8e_type buffer[512];
ieee= IEEE_AR_DATA(abfd);
+
bfd_read((PTR)buffer, 1, sizeof(buffer), abfd);
ieee->h.first_byte = buffer;
@@ -1013,6 +1026,10 @@ uint8e_type buffer[512];
free( read_id(&(ieee->h)));
/* This must be an IEEE archive, so we'll buy some space to do
things */
+
+ obstack_begin(&ob, 128);
+
+
ieee->element_count = 0;
ieee->element_index = 0;
@@ -1030,7 +1047,8 @@ uint8e_type buffer[512];
t.file_offset = must_parse_int(&(ieee->h));
t.abfd = (bfd *)NULL;
ieee->element_count++;
- bfd_alloc_grow(abfd, (PTR)&t, sizeof(t));
+
+ obstack_grow(&ob, (PTR)&t, sizeof(t));
/* Make sure that we don't go over the end of the buffer */
@@ -1046,7 +1064,7 @@ uint8e_type buffer[512];
else loop = false;
}
- ieee->elements = (ieee_ar_obstack_type *)bfd_alloc_finish(abfd);
+ ieee->elements = obstack_finish(&ob);
/* Now scan the area again, and replace BB offsets with file */
/* offsets */
@@ -1095,8 +1113,9 @@ DEFUN(ieee_object_p,(abfd),
ieee_data_type *save = IEEE_DATA(abfd);
abfd->tdata.ieee_data = 0;
ieee_mkobject(abfd);
- ieee = IEEE_DATA(abfd);
+ ieee = IEEE_DATA(abfd);
+ bfd_seek(abfd, 0, 0);
/* Read the first few bytes in to see if it makes sense */
bfd_read((PTR)buffer, 1, sizeof(buffer), abfd);
@@ -1278,9 +1297,8 @@ asection *section;
parse_expression(ieee,
&r->relent.addend,
- &section,
&r->symbol,
- &pcrel, &extra);
+ &pcrel, &extra, &section);
r->relent.address = current_map->pc;
s->reloc_count++;
if (r->relent.sym_ptr_ptr == 0) {
@@ -1468,9 +1486,9 @@ DEFUN(ieee_slurp_section_data,(abfd),
next_byte(&(ieee->h));
must_parse_int(&(ieee->h)); /* Thow away section #*/
parse_expression(ieee, &value,
- &dsection,
&symbol,
- &pcrel, &extra);
+ &pcrel, &extra,
+ 0);
current_map->pc = value;
BFD_ASSERT((unsigned)(value - s->vma) <= s->_raw_size);
}
@@ -2848,7 +2866,7 @@ ieee_generic_stat_arch_elt(abfd, buf)
bfd *abfd;
struct stat *buf;
{
- ieee_ar_data_type *ar = IEEE_AR_DATA(abfd);
+ ieee_ar_data_type *ar = abfd->my_archive->tdata.ieee_ar_data;
if (ar == (ieee_ar_data_type *)NULL) {
bfd_error = invalid_operation;
return -1;
@@ -2856,7 +2874,7 @@ struct stat *buf;
else {
buf->st_size = 0x1;
buf->st_mode = 0666;
- return 0;
+ return ! ieee_object_p(abfd);
}
}
static int