Line 1... |
Line 1... |
/* COFF information for TI COFF support. Definitions in this file should be
|
/* COFF information for TI COFF support. Definitions in this file should be
|
customized in a target-specific file, and then this file included (see
|
customized in a target-specific file, and then this file included (see
|
tic54x.h for an example).
|
tic54x.h for an example).
|
|
|
Copyright 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
|
Copyright 2000, 2001, 2002, 2003, 2005, 2008, 2009
|
|
Free Software Foundation, Inc.
|
|
|
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
the Free Software Foundation; either version 2 of the License, or
|
the Free Software Foundation; either version 2 of the License, or
|
(at your option) any later version.
|
(at your option) any later version.
|
Line 100... |
Line 101... |
/* we need to read/write an extra field in the coff file header */
|
/* we need to read/write an extra field in the coff file header */
|
#ifndef COFF_ADJUST_FILEHDR_IN_POST
|
#ifndef COFF_ADJUST_FILEHDR_IN_POST
|
#define COFF_ADJUST_FILEHDR_IN_POST(abfd, src, dst) \
|
#define COFF_ADJUST_FILEHDR_IN_POST(abfd, src, dst) \
|
do \
|
do \
|
{ \
|
{ \
|
|
if (!COFF0_P (abfd)) \
|
((struct internal_filehdr *)(dst))->f_target_id = \
|
((struct internal_filehdr *)(dst))->f_target_id = \
|
H_GET_16 (abfd, ((FILHDR *)(src))->f_target_id); \
|
H_GET_16 (abfd, ((FILHDR *)(src))->f_target_id); \
|
} \
|
} \
|
while (0)
|
while (0)
|
#endif
|
#endif
|
|
|
#ifndef COFF_ADJUST_FILEHDR_OUT_POST
|
#ifndef COFF_ADJUST_FILEHDR_OUT_POST
|
#define COFF_ADJUST_FILEHDR_OUT_POST(abfd, src, dst) \
|
#define COFF_ADJUST_FILEHDR_OUT_POST(abfd, src, dst) \
|
do \
|
do \
|
{ \
|
{ \
|
|
if (!COFF0_P (abfd)) \
|
H_PUT_16 (abfd, ((struct internal_filehdr *)(src))->f_target_id, \
|
H_PUT_16 (abfd, ((struct internal_filehdr *)(src))->f_target_id, \
|
((FILHDR *)(dst))->f_target_id); \
|
((FILHDR *)(dst))->f_target_id); \
|
} \
|
} \
|
while (0)
|
while (0)
|
#endif
|
#endif
|
Line 211... |
Line 214... |
#define SCNHSZ_V01 40 /* for v0 and v1 */
|
#define SCNHSZ_V01 40 /* for v0 and v1 */
|
#define SCNHSZ 48
|
#define SCNHSZ 48
|
|
|
/* COFF2 changes the offsets and sizes of these fields
|
/* COFF2 changes the offsets and sizes of these fields
|
Assume we're dealing with the COFF2 scnhdr structure, and adjust
|
Assume we're dealing with the COFF2 scnhdr structure, and adjust
|
accordingly
|
accordingly. Note: The GNU C versions of some of these macros
|
*/
|
are necessary in order to avoid compile time warnings triggered
|
|
gcc's array bounds checking. The PUT_SCNHDR_PAGE macro also has
|
|
the advantage on not evaluating LOC twice. */
|
|
|
#define GET_SCNHDR_NRELOC(ABFD, LOC) \
|
#define GET_SCNHDR_NRELOC(ABFD, LOC) \
|
(COFF2_P (ABFD) ? H_GET_32 (ABFD, LOC) : H_GET_16 (ABFD, LOC))
|
(COFF2_P (ABFD) ? H_GET_32 (ABFD, LOC) : H_GET_16 (ABFD, LOC))
|
#define PUT_SCNHDR_NRELOC(ABFD, VAL, LOC) \
|
#define PUT_SCNHDR_NRELOC(ABFD, VAL, LOC) \
|
(COFF2_P (ABFD) ? H_PUT_32 (ABFD, VAL, LOC) : H_PUT_16 (ABFD, VAL, LOC))
|
(COFF2_P (ABFD) ? H_PUT_32 (ABFD, VAL, LOC) : H_PUT_16 (ABFD, VAL, LOC))
|
|
#ifdef __GNUC__
|
|
#define GET_SCNHDR_NLNNO(ABFD, LOC) \
|
|
({ \
|
|
int nlnno; \
|
|
char * ptr = (LOC); \
|
|
if (COFF2_P (ABFD)) \
|
|
nlnno = H_GET_32 (ABFD, ptr); \
|
|
else \
|
|
nlnno = H_GET_16 (ABFD, ptr - 2); \
|
|
nlnno; \
|
|
})
|
|
#define PUT_SCNHDR_NLNNO(ABFD, VAL, LOC) \
|
|
do \
|
|
{ \
|
|
char * ptr = (LOC); \
|
|
if (COFF2_P (ABFD)) \
|
|
H_PUT_32 (ABFD, VAL, ptr); \
|
|
else \
|
|
H_PUT_16 (ABFD, VAL, ptr - 2); \
|
|
} \
|
|
while (0)
|
|
#define GET_SCNHDR_FLAGS(ABFD, LOC) \
|
|
({ \
|
|
int flags; \
|
|
char * ptr = (LOC); \
|
|
if (COFF2_P (ABFD)) \
|
|
flags = H_GET_32 (ABFD, ptr); \
|
|
else \
|
|
flags = H_GET_16 (ABFD, ptr - 4); \
|
|
flags; \
|
|
})
|
|
#define PUT_SCNHDR_FLAGS(ABFD, VAL, LOC) \
|
|
do \
|
|
{ \
|
|
char * ptr = (LOC); \
|
|
if (COFF2_P (ABFD)) \
|
|
H_PUT_32 (ABFD, VAL, ptr); \
|
|
else \
|
|
H_PUT_16 (ABFD, VAL, ptr - 4); \
|
|
} \
|
|
while (0)
|
|
#define GET_SCNHDR_PAGE(ABFD, LOC) \
|
|
({ \
|
|
unsigned page; \
|
|
char * ptr = (LOC); \
|
|
if (COFF2_P (ABFD)) \
|
|
page = H_GET_16 (ABFD, ptr); \
|
|
else \
|
|
page = (unsigned) H_GET_8 (ABFD, ptr - 7); \
|
|
page; \
|
|
})
|
|
/* On output, make sure that the "reserved" field is zero. */
|
|
#define PUT_SCNHDR_PAGE(ABFD, VAL, LOC) \
|
|
do \
|
|
{ \
|
|
char * ptr = (LOC); \
|
|
if (COFF2_P (ABFD)) \
|
|
H_PUT_16 (ABFD, VAL, ptr); \
|
|
else \
|
|
{ \
|
|
H_PUT_8 (ABFD, VAL, ptr - 7); \
|
|
H_PUT_8 (ABFD, 0, ptr - 8); \
|
|
} \
|
|
} \
|
|
while (0)
|
|
#else
|
#define GET_SCNHDR_NLNNO(ABFD, LOC) \
|
#define GET_SCNHDR_NLNNO(ABFD, LOC) \
|
(COFF2_P (ABFD) ? H_GET_32 (ABFD, LOC) : H_GET_16 (ABFD, (LOC) - 2))
|
(COFF2_P (ABFD) ? H_GET_32 (ABFD, LOC) : H_GET_16 (ABFD, (LOC) - 2))
|
#define PUT_SCNHDR_NLNNO(ABFD, VAL, LOC) \
|
#define PUT_SCNHDR_NLNNO(ABFD, VAL, LOC) \
|
(COFF2_P (ABFD) ? H_PUT_32 (ABFD, VAL, LOC) : H_PUT_16 (ABFD, VAL, (LOC) - 2))
|
(COFF2_P (ABFD) ? H_PUT_32 (ABFD, VAL, LOC) : H_PUT_16 (ABFD, VAL, (LOC) - 2))
|
#define GET_SCNHDR_FLAGS(ABFD, LOC) \
|
#define GET_SCNHDR_FLAGS(ABFD, LOC) \
|
(COFF2_P (ABFD) ? H_GET_32 (ABFD, LOC) : H_GET_16 (ABFD, (LOC) - 4))
|
(COFF2_P (ABFD) ? H_GET_32 (ABFD, LOC) : H_GET_16 (ABFD, (LOC) - 4))
|
#define PUT_SCNHDR_FLAGS(ABFD, VAL, LOC) \
|
#define PUT_SCNHDR_FLAGS(ABFD, VAL, LOC) \
|
(COFF2_P (ABFD) ? H_PUT_32 (ABFD, VAL, LOC) : H_PUT_16 (ABFD, VAL, (LOC) - 4))
|
(COFF2_P (ABFD) ? H_PUT_32 (ABFD, VAL, LOC) : H_PUT_16 (ABFD, VAL, (LOC) - 4))
|
#define GET_SCNHDR_PAGE(ABFD, LOC) \
|
#define GET_SCNHDR_PAGE(ABFD, LOC) \
|
(COFF2_P (ABFD) ? H_GET_16 (ABFD, LOC) : (unsigned) H_GET_8 (ABFD, (LOC) - 7))
|
(COFF2_P (ABFD) ? H_GET_16 (ABFD, LOC) : (unsigned) H_GET_8 (ABFD, (LOC) - 7))
|
/* on output, make sure that the "reserved" field is zero */
|
/* On output, make sure that the "reserved" field is zero. */
|
#define PUT_SCNHDR_PAGE(ABFD, VAL, LOC) \
|
#define PUT_SCNHDR_PAGE(ABFD, VAL, LOC) \
|
(COFF2_P (ABFD) \
|
(COFF2_P (ABFD) \
|
? H_PUT_16 (ABFD, VAL, LOC) \
|
? H_PUT_16 (ABFD, VAL, LOC) \
|
: H_PUT_8 (ABFD, VAL, (LOC) - 7), H_PUT_8 (ABFD, 0, (LOC) - 8))
|
: H_PUT_8 (ABFD, VAL, (LOC) - 7), H_PUT_8 (ABFD, 0, (LOC) - 8))
|
|
#endif
|
|
|
|
|
/* TI COFF stores section size as number of bytes (address units, not octets),
|
/* TI COFF stores section size as number of bytes (address units, not octets),
|
so adjust to be number of octets, which is what BFD expects */
|
so adjust to be number of octets, which is what BFD expects */
|
#define GET_SCNHDR_SIZE(ABFD, SZP) \
|
#define GET_SCNHDR_SIZE(ABFD, SZP) \
|
(H_GET_32 (ABFD, SZP) * bfd_octets_per_byte (ABFD))
|
(H_GET_32 (ABFD, SZP) * bfd_octets_per_byte (ABFD))
|
Line 248... |
Line 322... |
((struct internal_scnhdr *)(INT))->s_page = \
|
((struct internal_scnhdr *)(INT))->s_page = \
|
GET_SCNHDR_PAGE (ABFD, ((SCNHDR *)(EXT))->s_page); \
|
GET_SCNHDR_PAGE (ABFD, ((SCNHDR *)(EXT))->s_page); \
|
} \
|
} \
|
while (0)
|
while (0)
|
|
|
|
/* The entire scnhdr may not be assigned.
|
|
Ensure that everything is initialized. */
|
|
#define COFF_ADJUST_SCNHDR_OUT_PRE(ABFD, INT, EXT) \
|
|
do \
|
|
{ \
|
|
memset((EXT), 0, sizeof (SCNHDR)); \
|
|
} \
|
|
while (0)
|
|
|
/* The line number and reloc overflow checking in coff_swap_scnhdr_out in
|
/* The line number and reloc overflow checking in coff_swap_scnhdr_out in
|
coffswap.h doesn't use PUT_X for s_nlnno and s_nreloc.
|
coffswap.h doesn't use PUT_X for s_nlnno and s_nreloc.
|
Due to different sized v0/v1/v2 section headers, we have to re-write these
|
Due to different sized v0/v1/v2 section headers, we have to re-write these
|
fields.
|
fields.
|
*/
|
*/
|
Line 391... |
Line 474... |
#define PUT_SCN_SCNLEN(ABFD, INT, EXT) \
|
#define PUT_SCN_SCNLEN(ABFD, INT, EXT) \
|
H_PUT_32 (ABFD, (INT) / bfd_octets_per_byte (ABFD), (EXT)->x_scn.x_scnlen)
|
H_PUT_32 (ABFD, (INT) / bfd_octets_per_byte (ABFD), (EXT)->x_scn.x_scnlen)
|
|
|
/* lnsz size is in bits in COFF file, in bytes in BFD */
|
/* lnsz size is in bits in COFF file, in bytes in BFD */
|
#define GET_LNSZ_SIZE(abfd, ext) \
|
#define GET_LNSZ_SIZE(abfd, ext) \
|
(H_GET_16 (abfd, ext->x_sym.x_misc.x_lnsz.x_size) / (class != C_FIELD ? 8 : 1))
|
(H_GET_16 (abfd, ext->x_sym.x_misc.x_lnsz.x_size) / (in_class != C_FIELD ? 8 : 1))
|
|
|
#define PUT_LNSZ_SIZE(abfd, in, ext) \
|
#define PUT_LNSZ_SIZE(abfd, in, ext) \
|
H_PUT_16 (abfd, ((class != C_FIELD) ? (in) * 8 : (in)), \
|
H_PUT_16 (abfd, ((in_class != C_FIELD) ? (in) * 8 : (in)), \
|
ext->x_sym.x_misc.x_lnsz.x_size)
|
ext->x_sym.x_misc.x_lnsz.x_size)
|
|
|
/* TI COFF stores offsets for MOS and MOU in bits; BFD expects bytes
|
/* TI COFF stores offsets for MOS and MOU in bits; BFD expects bytes
|
Also put the load page flag of the section into the symbol value if it's an
|
Also put the load page flag of the section into the symbol value if it's an
|
address. */
|
address. */
|