mirror of
https://github.com/darlinghq/darling-gdb.git
synced 2024-11-25 05:00:01 +00:00
124 lines
3.2 KiB
C
Executable File
124 lines
3.2 KiB
C
Executable File
/* Byte-swapping routines for COFF files */
|
|
|
|
/* Copyright (C) 1990, 1991 Free Software Foundation, Inc.
|
|
|
|
This file is part of BFD, the Binary File Diddler.
|
|
|
|
BFD is free software; you can redistribute it and/or modify it under the
|
|
terms of the GNU General Public License as published by the Free Software
|
|
Foundation; either version 1, or (at your option) any later version.
|
|
|
|
BFD is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
details.
|
|
|
|
You should have received a copy of the GNU General Public License along with
|
|
BFD; see the file COPYING. If not, write to the Free Software Foundation,
|
|
675 Mass Ave, Cambridge, MA 02139, USA.
|
|
*/
|
|
|
|
/* Most of this hacked by Steve Chamberlain, steve@cygnus.com */
|
|
#if 0
|
|
#include <ansidecl.h>
|
|
#include "intel-coff.h"
|
|
#include "bfd.h"
|
|
#include "libcoff.h" /* to allow easier abstraction-breaking */
|
|
|
|
#define sp(x) bfd_h_put_x(abfd, x, &x)
|
|
|
|
/* All the generic swapping routines:
|
|
|
|
FIXME
|
|
These routines cater for the sizes and alignments and offsets of
|
|
all the contained fields. Because of this, the fields can change
|
|
size, so these should be phased out to use the ones specific to the
|
|
file format.
|
|
*/
|
|
|
|
void
|
|
DEFUN(bfd_coff_swap_name,(abfd, ptr),
|
|
bfd *abfd AND
|
|
long *ptr)
|
|
{
|
|
if (ptr[0] == 0) {
|
|
/* There is an index which needs to be swapped */
|
|
bfd_h_put_x(abfd, ptr[1], (ptr + 1));
|
|
}
|
|
else {
|
|
/* This is a string .. leave it alone */
|
|
}
|
|
}
|
|
|
|
void
|
|
DEFUN(bfd_coff_swap_sym,(abfd, se),
|
|
bfd *abfd AND
|
|
struct internal_syment *se)
|
|
{
|
|
bfd_coff_swap_name(abfd, (long*)(se->n_name));
|
|
bfd_h_put_x(abfd, se->n_value, &se->n_value);
|
|
bfd_h_put_x(abfd, se->n_scnum, &se->n_scnum);
|
|
bfd_h_put_x(abfd, se->n_type, &se->n_type);
|
|
bfd_h_put_x(abfd, se->n_sclass, &se->n_sclass);
|
|
bfd_h_put_x(abfd, se->n_numaux, &se->n_numaux);
|
|
}
|
|
|
|
void
|
|
DEFUN(bfd_coff_swap_aux,(abfd, au, type, class),
|
|
bfd *abfd AND
|
|
struct internal_auxent *au AND
|
|
int type AND
|
|
int class)
|
|
{
|
|
switch (class) {
|
|
case C_FILE:
|
|
bfd_coff_swap_name(abfd, (long *)(&au->x_file.x_n));
|
|
break;
|
|
case C_STAT:
|
|
#ifdef C_LEAFSTAT
|
|
case C_LEAFSTAT:
|
|
#endif
|
|
case C_HIDDEN:
|
|
if (type == T_NULL) {
|
|
sp(au->x_scn.x_scnlen);
|
|
sp(au->x_scn.x_nreloc);
|
|
sp(au->x_scn.x_nlinno);
|
|
break;
|
|
}
|
|
default:
|
|
sp(au->x_sym.x_tagndx);
|
|
sp(au->x_sym.x_tvndx);
|
|
|
|
if (ISARY(type) || class == C_BLOCK) {
|
|
sp(au->x_sym.x_fcnary.x_ary.x_dimen[0]);
|
|
sp(au->x_sym.x_fcnary.x_ary.x_dimen[1]);
|
|
sp(au->x_sym.x_fcnary.x_ary.x_dimen[2]);
|
|
sp(au->x_sym.x_fcnary.x_ary.x_dimen[3]);
|
|
}
|
|
else {
|
|
sp(au->x_sym.x_fcnary.x_fcn.x_lnnoptr);
|
|
sp(au->x_sym.x_fcnary.x_fcn.x_endndx);
|
|
}
|
|
if (ISFCN(type)) {
|
|
sp(au->x_sym.x_misc.x_fsize);
|
|
}
|
|
else {
|
|
sp(au->x_sym.x_misc.x_lnsz.x_lnno);
|
|
sp(au->x_sym.x_misc.x_lnsz.x_size);
|
|
}
|
|
}
|
|
}
|
|
|
|
void
|
|
DEFUN(bfd_coff_swap_lineno,(abfd, lineno),
|
|
bfd *abfd AND
|
|
struct internal_lineno *lineno)
|
|
{
|
|
sp(lineno->l_addr.l_symndx);
|
|
sp(lineno->l_lnno);
|
|
}
|
|
|
|
|
|
|
|
#endif
|