/[gcl]/gcl/binutils/bfd/i386lynx.c
ViewVC logotype

Diff of /gcl/binutils/bfd/i386lynx.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1.1.1 by camm, Fri Aug 9 05:35:32 2002 UTC revision 1.2 by camm, Fri Sep 9 23:32:14 2005 UTC
# Line 1  Line 1 
1  /* BFD back-end for i386 a.out binaries under LynxOS.  /* BFD back-end for i386 a.out binaries under LynxOS.
2     Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 2001, 2002     Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1999, 2001, 2002,
3     Free Software Foundation, Inc.     2003 Free Software Foundation, Inc.
4    
5  This file is part of BFD, the Binary File Descriptor library.  This file is part of BFD, the Binary File Descriptor library.
6    
# Line 18  You should have received a copy of the G Line 18  You should have received a copy of the G
18  along with this program; if not, write to the Free Software  along with this program; if not, write to the Free Software
19  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
20    
 #define BYTES_IN_WORD 4  
21  #define N_SHARED_LIB(x) 0  #define N_SHARED_LIB(x) 0
22    
23  #define TEXT_START_ADDR 0  #define TEXT_START_ADDR 0
# Line 56  Foundation, Inc., 59 Temple Place - Suit Line 55  Foundation, Inc., 59 Temple Place - Suit
55          if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0                      \          if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0                      \
56              || bfd_bwrite ((PTR) &exec_bytes, (bfd_size_type) EXEC_BYTES_SIZE, \              || bfd_bwrite ((PTR) &exec_bytes, (bfd_size_type) EXEC_BYTES_SIZE, \
57                            abfd) != EXEC_BYTES_SIZE)                           \                            abfd) != EXEC_BYTES_SIZE)                           \
58            return false;                                                       \            return FALSE;                                                       \
59          /* Now write out reloc info, followed by syms and strings */          \          /* Now write out reloc info, followed by syms and strings */          \
60                                                                                \                                                                                \
61          if (bfd_get_symcount (abfd) != 0)                                     \          if (bfd_get_symcount (abfd) != 0)                                     \
62              {                                                                 \              {                                                                 \
63                if (bfd_seek (abfd, (file_ptr) (N_SYMOFF(*execp)), SEEK_SET)    \                if (bfd_seek (abfd, (file_ptr) (N_SYMOFF(*execp)), SEEK_SET)    \
64                    != 0)                                                       \                    != 0)                                                       \
65                  return false;                                                 \                  return FALSE;                                                 \
66                                                                                \                                                                                \
67                if (! NAME(aout,write_syms) (abfd)) return false;               \                if (! NAME(aout,write_syms) (abfd)) return FALSE;               \
68                                                                                \                                                                                \
69                if (bfd_seek (abfd, (file_ptr) (N_TRELOFF(*execp)), SEEK_SET)   \                if (bfd_seek (abfd, (file_ptr) (N_TRELOFF(*execp)), SEEK_SET)   \
70                    != 0)                                                       \                    != 0)                                                       \
71                  return false;                                                 \                  return FALSE;                                                 \
72                                                                                \                                                                                \
73                if (!NAME(lynx,squirt_out_relocs) (abfd, obj_textsec (abfd)))   \                if (!NAME(lynx,squirt_out_relocs) (abfd, obj_textsec (abfd)))   \
74                  return false;                                                 \                  return FALSE;                                                 \
75                if (bfd_seek (abfd, (file_ptr) (N_DRELOFF(*execp)), SEEK_SET)   \                if (bfd_seek (abfd, (file_ptr) (N_DRELOFF(*execp)), SEEK_SET)   \
76                    != 0)                                                       \                    != 0)                                                       \
77                  return 0;                                                     \                  return 0;                                                     \
78                                                                                \                                                                                \
79                if (!NAME(lynx,squirt_out_relocs) (abfd, obj_datasec (abfd)))   \                if (!NAME(lynx,squirt_out_relocs) (abfd, obj_datasec (abfd)))   \
80                  return false;                                                 \                  return FALSE;                                                 \
81              }                                                                 \              }                                                                 \
82        }        }
83  #endif  #endif
# Line 86  Foundation, Inc., 59 Temple Place - Suit Line 85  Foundation, Inc., 59 Temple Place - Suit
85  #include "libaout.h"  #include "libaout.h"
86  #include "aout/aout64.h"  #include "aout/aout64.h"
87    
88  void NAME (lynx,swap_std_reloc_out) PARAMS ((bfd *, arelent *, struct reloc_std_external *));  void NAME (lynx,swap_std_reloc_out)
89  void NAME (lynx,swap_ext_reloc_out) PARAMS ((bfd *, arelent *, struct reloc_ext_external *));    PARAMS ((bfd *, arelent *, struct reloc_std_external *));
90  void NAME (lynx,swap_ext_reloc_in)  PARAMS ((bfd *, struct reloc_ext_external *, arelent *, asymbol **, bfd_size_type));  void NAME (lynx,swap_ext_reloc_out)
91  void NAME (lynx,swap_std_reloc_in)  PARAMS ((bfd *, struct reloc_std_external *, arelent *, asymbol **, bfd_size_type));    PARAMS ((bfd *, arelent *, struct reloc_ext_external *));
92  boolean NAME (lynx,slurp_reloc_table) PARAMS ((bfd *, sec_ptr, asymbol **));  void NAME (lynx,swap_ext_reloc_in)
93  boolean NAME (lynx,squirt_out_relocs) PARAMS ((bfd *, asection *));    PARAMS ((bfd *, struct reloc_ext_external *, arelent *, asymbol **,
94  long NAME (lynx,canonicalize_reloc) PARAMS ((bfd *, sec_ptr, arelent **, asymbol **));             bfd_size_type));
95    void NAME (lynx,swap_std_reloc_in)
96      PARAMS ((bfd *, struct reloc_std_external *, arelent *, asymbol **,
97               bfd_size_type));
98    bfd_boolean NAME (lynx,slurp_reloc_table)
99      PARAMS ((bfd *, sec_ptr, asymbol **));
100    bfd_boolean NAME (lynx,squirt_out_relocs)
101      PARAMS ((bfd *, asection *));
102    long NAME (lynx,canonicalize_reloc)
103      PARAMS ((bfd *, sec_ptr, arelent **, asymbol **));
104    
105  #ifdef LYNX_CORE  #ifdef LYNX_CORE
106    
107  char *lynx_core_file_failing_command ();  char *lynx_core_file_failing_command ();
108  int lynx_core_file_failing_signal ();  int lynx_core_file_failing_signal ();
109  boolean lynx_core_file_matches_executable_p ();  bfd_boolean lynx_core_file_matches_executable_p ();
110  const bfd_target *lynx_core_file_p ();  const bfd_target *lynx_core_file_p ();
111    
112  #define MY_core_file_failing_command lynx_core_file_failing_command  #define MY_core_file_failing_command lynx_core_file_failing_command
# Line 151  NAME(lynx,swap_std_reloc_out) (abfd, g, Line 159  NAME(lynx,swap_std_reloc_out) (abfd, g,
159       Absolute symbols can come in in two ways, either as an offset       Absolute symbols can come in in two ways, either as an offset
160       from the abs section, or as a symbol which has an abs value.       from the abs section, or as a symbol which has an abs value.
161       check for that here       check for that here
162       */    */
163    
164    
165    if (bfd_is_com_section (output_section)    if (bfd_is_com_section (output_section)
# Line 161  NAME(lynx,swap_std_reloc_out) (abfd, g, Line 169  NAME(lynx,swap_std_reloc_out) (abfd, g,
169        if (bfd_abs_section_ptr->symbol == sym)        if (bfd_abs_section_ptr->symbol == sym)
170          {          {
171            /* Whoops, looked like an abs symbol, but is really an offset            /* Whoops, looked like an abs symbol, but is really an offset
172             from the abs section */               from the abs section */
173            r_index = 0;            r_index = 0;
174            r_extern = 0;            r_extern = 0;
175          }          }
# Line 388  NAME(lynx,swap_std_reloc_in) (abfd, byte Line 396  NAME(lynx,swap_std_reloc_in) (abfd, byte
396    
397  /* Reloc hackery */  /* Reloc hackery */
398    
399  boolean  bfd_boolean
400  NAME(lynx,slurp_reloc_table) (abfd, asect, symbols)  NAME(lynx,slurp_reloc_table) (abfd, asect, symbols)
401       bfd *abfd;       bfd *abfd;
402       sec_ptr asect;       sec_ptr asect;
# Line 401  NAME(lynx,slurp_reloc_table) (abfd, asec Line 409  NAME(lynx,slurp_reloc_table) (abfd, asec
409    size_t each_size;    size_t each_size;
410    
411    if (asect->relocation)    if (asect->relocation)
412      return true;      return TRUE;
413    
414    if (asect->flags & SEC_CONSTRUCTOR)    if (asect->flags & SEC_CONSTRUCTOR)
415      return true;      return TRUE;
416    
417    if (asect == obj_datasec (abfd))    if (asect == obj_datasec (abfd))
418      {      {
# Line 419  NAME(lynx,slurp_reloc_table) (abfd, asec Line 427  NAME(lynx,slurp_reloc_table) (abfd, asec
427      }      }
428    
429    bfd_set_error (bfd_error_invalid_operation);    bfd_set_error (bfd_error_invalid_operation);
430    return false;    return FALSE;
431    
432  doit:  doit:
433    if (bfd_seek (abfd, asect->rel_filepos, SEEK_SET) != 0)    if (bfd_seek (abfd, asect->rel_filepos, SEEK_SET) != 0)
434      return false;      return FALSE;
435    each_size = obj_reloc_entry_size (abfd);    each_size = obj_reloc_entry_size (abfd);
436    
437    count = reloc_size / each_size;    count = reloc_size / each_size;
# Line 431  doit: Line 439  doit:
439    
440    reloc_cache = (arelent *) bfd_zmalloc (count * sizeof (arelent));    reloc_cache = (arelent *) bfd_zmalloc (count * sizeof (arelent));
441    if (!reloc_cache && count != 0)    if (!reloc_cache && count != 0)
442      return false;      return FALSE;
443    
444    relocs = (PTR) bfd_alloc (abfd, reloc_size);    relocs = (PTR) bfd_alloc (abfd, reloc_size);
445    if (!relocs && reloc_size != 0)    if (!relocs && reloc_size != 0)
446      {      {
447        free (reloc_cache);        free (reloc_cache);
448        return false;        return FALSE;
449      }      }
450    
451    if (bfd_bread (relocs, reloc_size, abfd) != reloc_size)    if (bfd_bread (relocs, reloc_size, abfd) != reloc_size)
452      {      {
453        bfd_release (abfd, relocs);        bfd_release (abfd, relocs);
454        free (reloc_cache);        free (reloc_cache);
455        return false;        return FALSE;
456      }      }
457    
458    if (each_size == RELOC_EXT_SIZE)    if (each_size == RELOC_EXT_SIZE)
# Line 476  doit: Line 484  doit:
484    bfd_release (abfd, relocs);    bfd_release (abfd, relocs);
485    asect->relocation = reloc_cache;    asect->relocation = reloc_cache;
486    asect->reloc_count = count;    asect->reloc_count = count;
487    return true;    return TRUE;
488  }  }
489    
490    
491    
492  /* Write out a relocation section into an object file.  */  /* Write out a relocation section into an object file.  */
493    
494  boolean  bfd_boolean
495  NAME(lynx,squirt_out_relocs) (abfd, section)  NAME(lynx,squirt_out_relocs) (abfd, section)
496       bfd *abfd;       bfd *abfd;
497       asection *section;       asection *section;
# Line 496  NAME(lynx,squirt_out_relocs) (abfd, sect Line 504  NAME(lynx,squirt_out_relocs) (abfd, sect
504    bfd_size_type natsize;    bfd_size_type natsize;
505    
506    if (count == 0)    if (count == 0)
507      return true;      return TRUE;
508    
509    each_size = obj_reloc_entry_size (abfd);    each_size = obj_reloc_entry_size (abfd);
510    natsize = count;    natsize = count;
511    natsize *= each_size;    natsize *= each_size;
512    native = (unsigned char *) bfd_zalloc (abfd, natsize);    native = (unsigned char *) bfd_zalloc (abfd, natsize);
513    if (!native)    if (!native)
514      return false;      return FALSE;
515    
516    generic = section->orelocation;    generic = section->orelocation;
517    
# Line 525  NAME(lynx,squirt_out_relocs) (abfd, sect Line 533  NAME(lynx,squirt_out_relocs) (abfd, sect
533    if (bfd_bwrite ((PTR) native, natsize, abfd) != natsize)    if (bfd_bwrite ((PTR) native, natsize, abfd) != natsize)
534      {      {
535        bfd_release (abfd, native);        bfd_release (abfd, native);
536        return false;        return FALSE;
537      }      }
538    bfd_release (abfd, native);    bfd_release (abfd, native);
539    
540    return true;    return TRUE;
541  }  }
542    
543  /* This is stupid.  This function should be a boolean predicate */  /* This is stupid.  This function should be a boolean predicate */

Legend:
Removed from v.1.1.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26