First round ld support for PPC PE
This commit is contained in:
parent
ccb98a5afd
commit
d6f41a7d3e
|
@ -1,3 +1,36 @@
|
||||||
|
Tue Nov 7 11:53:48 1995 Kim Knuttila <krk@cygnus.com>
|
||||||
|
|
||||||
|
* coff-ppc.c (ppc_record_toc_entry): new function.
|
||||||
|
(in_reloc_p): changed return value.
|
||||||
|
(coff_ppc_relocate_section): much rework.
|
||||||
|
(ppc_allocate_toc_section): new function.
|
||||||
|
(ppc_process_before_allocation): new function.
|
||||||
|
(ppc_coff_swap_sym_in_hook): new function.
|
||||||
|
|
||||||
|
* cofflink.c (_bfd_coff_link_hash_newfunc): initialize toc_offset.
|
||||||
|
(coff_link_add_symbols): initialize toc_offset.
|
||||||
|
|
||||||
|
* peicode.h (coff_swap_sym_in): Added coff_swap_sym_in_hook
|
||||||
|
(coff_swap_aouthdr_out): Added more sections to the data
|
||||||
|
dictionary for the pe file header. Also changed linker version
|
||||||
|
number on the ppc side.
|
||||||
|
(dir_names): small improvements to the dictionary printing.
|
||||||
|
(pe_mkobject_hook): save the file level flags.
|
||||||
|
|
||||||
|
* libcoff-in.h (coff_link_hash_entry): added toc_offset field
|
||||||
|
(pe_tdata): added real_flags field
|
||||||
|
(coff_tdata): added local_toc_sym_map and access macro
|
||||||
|
|
||||||
|
* libcoff.h (coff_link_hash_entry): added toc_offset field
|
||||||
|
(pe_tdata): added real_flags field
|
||||||
|
(coff_tdata): added local_toc_sym_map and access macro
|
||||||
|
|
||||||
|
* coffcode.h (coff_set_alignment_hook): added hook for PE.
|
||||||
|
(coff_mkobject): init for local_toc_sym_map
|
||||||
|
(coff_write_object_contents): set the internal_a.magic to
|
||||||
|
IMAGE_NT_OPTIONAL_HDR_MAGIC which appears to be what other
|
||||||
|
ppc compilers use.
|
||||||
|
|
||||||
Tue Nov 7 13:48:58 1995 Ian Lance Taylor <ian@cygnus.com>
|
Tue Nov 7 13:48:58 1995 Ian Lance Taylor <ian@cygnus.com>
|
||||||
|
|
||||||
* configure.in: Call AC_CHECK_PROG to find and cache AR.
|
* configure.in: Call AC_CHECK_PROG to find and cache AR.
|
||||||
|
|
1378
bfd/coff-ppc.c
1378
bfd/coff-ppc.c
File diff suppressed because it is too large
Load Diff
|
@ -928,6 +928,40 @@ coff_set_alignment_hook (abfd, section, scnhdr)
|
||||||
section->alignment_power = i;
|
section->alignment_power = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#elif defined(COFF_WITH_PE)
|
||||||
|
|
||||||
|
/* a couple of macros to help setting the alignment power field */
|
||||||
|
#define ALIGN_SET(field,x,y) \
|
||||||
|
if (((field) & IMAGE_SCN_ALIGN_64BYTES) == x )\
|
||||||
|
{\
|
||||||
|
section->alignment_power = y;\
|
||||||
|
}
|
||||||
|
|
||||||
|
#define ELIFALIGN_SET(field,x,y) \
|
||||||
|
else if (( (field) & IMAGE_SCN_ALIGN_64BYTES) == x ) \
|
||||||
|
{\
|
||||||
|
section->alignment_power = y;\
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
coff_set_alignment_hook (abfd, section, scnhdr)
|
||||||
|
bfd * abfd;
|
||||||
|
asection * section;
|
||||||
|
PTR scnhdr;
|
||||||
|
{
|
||||||
|
struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
|
||||||
|
|
||||||
|
ALIGN_SET (hdr->s_flags, IMAGE_SCN_ALIGN_64BYTES, 6)
|
||||||
|
ELIFALIGN_SET (hdr->s_flags, IMAGE_SCN_ALIGN_32BYTES, 5)
|
||||||
|
ELIFALIGN_SET (hdr->s_flags, IMAGE_SCN_ALIGN_16BYTES, 4)
|
||||||
|
ELIFALIGN_SET (hdr->s_flags, IMAGE_SCN_ALIGN_8BYTES, 3)
|
||||||
|
ELIFALIGN_SET (hdr->s_flags, IMAGE_SCN_ALIGN_4BYTES, 2)
|
||||||
|
ELIFALIGN_SET (hdr->s_flags, IMAGE_SCN_ALIGN_2BYTES, 1)
|
||||||
|
ELIFALIGN_SET (hdr->s_flags, IMAGE_SCN_ALIGN_1BYTES, 0)
|
||||||
|
}
|
||||||
|
#undef ALIGN_SET
|
||||||
|
#undef ELIFALIGN_SET
|
||||||
|
|
||||||
#else /* ! I960 */
|
#else /* ! I960 */
|
||||||
|
|
||||||
#define coff_set_alignment_hook \
|
#define coff_set_alignment_hook \
|
||||||
|
@ -953,6 +987,8 @@ coff_mkobject (abfd)
|
||||||
coff->conversion_table = (unsigned int *) NULL;
|
coff->conversion_table = (unsigned int *) NULL;
|
||||||
coff->raw_syments = (struct coff_ptr_struct *) NULL;
|
coff->raw_syments = (struct coff_ptr_struct *) NULL;
|
||||||
coff->relocbase = 0;
|
coff->relocbase = 0;
|
||||||
|
coff->local_toc_sym_map = 0;
|
||||||
|
|
||||||
/* make_abs_section(abfd);*/
|
/* make_abs_section(abfd);*/
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -2176,6 +2212,7 @@ coff_write_object_contents (abfd)
|
||||||
if (abfd->flags & EXEC_P)
|
if (abfd->flags & EXEC_P)
|
||||||
internal_f.f_flags |= F_EXEC;
|
internal_f.f_flags |= F_EXEC;
|
||||||
|
|
||||||
|
/* FIXME: this is wrong for PPC_PE! */
|
||||||
if (!abfd->xvec->byteorder_big_p)
|
if (!abfd->xvec->byteorder_big_p)
|
||||||
internal_f.f_flags |= F_AR32WR;
|
internal_f.f_flags |= F_AR32WR;
|
||||||
else
|
else
|
||||||
|
@ -2254,7 +2291,7 @@ coff_write_object_contents (abfd)
|
||||||
#endif
|
#endif
|
||||||
#if defined(PPC)
|
#if defined(PPC)
|
||||||
#define __A_MAGIC_SET__
|
#define __A_MAGIC_SET__
|
||||||
internal_a.magic = PPCMAGIC;
|
internal_a.magic = IMAGE_NT_OPTIONAL_HDR_MAGIC;
|
||||||
#endif
|
#endif
|
||||||
#if defined(I386)
|
#if defined(I386)
|
||||||
#define __A_MAGIC_SET__
|
#define __A_MAGIC_SET__
|
||||||
|
|
|
@ -204,6 +204,7 @@ _bfd_coff_link_hash_newfunc (entry, table, string)
|
||||||
ret->numaux = 0;
|
ret->numaux = 0;
|
||||||
ret->auxbfd = NULL;
|
ret->auxbfd = NULL;
|
||||||
ret->aux = NULL;
|
ret->aux = NULL;
|
||||||
|
ret->toc_offset = 1; /* invalid toc address, sets the high bit */
|
||||||
}
|
}
|
||||||
|
|
||||||
return (struct bfd_hash_entry *) ret;
|
return (struct bfd_hash_entry *) ret;
|
||||||
|
@ -313,6 +314,7 @@ coff_link_add_object_symbols (abfd, info)
|
||||||
return false;
|
return false;
|
||||||
if (! coff_link_add_symbols (abfd, info))
|
if (! coff_link_add_symbols (abfd, info))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (! info->keep_memory)
|
if (! info->keep_memory)
|
||||||
{
|
{
|
||||||
if (! _bfd_coff_free_symbols (abfd))
|
if (! _bfd_coff_free_symbols (abfd))
|
||||||
|
@ -529,6 +531,7 @@ coff_link_add_symbols (abfd, info)
|
||||||
(*sym_hash)->type = sym.n_type;
|
(*sym_hash)->type = sym.n_type;
|
||||||
(*sym_hash)->numaux = sym.n_numaux;
|
(*sym_hash)->numaux = sym.n_numaux;
|
||||||
(*sym_hash)->auxbfd = abfd;
|
(*sym_hash)->auxbfd = abfd;
|
||||||
|
(*sym_hash)->toc_offset = 1;
|
||||||
if (sym.n_numaux != 0)
|
if (sym.n_numaux != 0)
|
||||||
{
|
{
|
||||||
union internal_auxent *alloc;
|
union internal_auxent *alloc;
|
||||||
|
@ -2345,7 +2348,6 @@ _bfd_coff_generic_relocate_section (output_bfd, info, input_bfd,
|
||||||
struct internal_reloc *rel;
|
struct internal_reloc *rel;
|
||||||
struct internal_reloc *relend;
|
struct internal_reloc *relend;
|
||||||
|
|
||||||
|
|
||||||
rel = relocs;
|
rel = relocs;
|
||||||
relend = rel + input_section->reloc_count;
|
relend = rel + input_section->reloc_count;
|
||||||
for (; rel < relend; rel++)
|
for (; rel < relend; rel++)
|
||||||
|
|
|
@ -40,6 +40,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
#define obj_coff_keep_strings(bfd) (coff_data (bfd)->keep_strings)
|
#define obj_coff_keep_strings(bfd) (coff_data (bfd)->keep_strings)
|
||||||
#define obj_coff_sym_hashes(bfd) (coff_data (bfd)->sym_hashes)
|
#define obj_coff_sym_hashes(bfd) (coff_data (bfd)->sym_hashes)
|
||||||
|
|
||||||
|
#define obj_coff_local_toc_table(bfd) (coff_data(bfd)->local_toc_sym_map)
|
||||||
|
|
||||||
/* `Tdata' information kept for COFF files. */
|
/* `Tdata' information kept for COFF files. */
|
||||||
|
|
||||||
typedef struct coff_tdata
|
typedef struct coff_tdata
|
||||||
|
@ -83,6 +85,9 @@ typedef struct coff_tdata
|
||||||
/* Used by the COFF backend linker. */
|
/* Used by the COFF backend linker. */
|
||||||
struct coff_link_hash_entry **sym_hashes;
|
struct coff_link_hash_entry **sym_hashes;
|
||||||
|
|
||||||
|
/* used by the pe linker for PowerPC */
|
||||||
|
int *local_toc_sym_map;
|
||||||
|
|
||||||
struct bfd_link_info *link_info;
|
struct bfd_link_info *link_info;
|
||||||
} coff_data_type;
|
} coff_data_type;
|
||||||
|
|
||||||
|
@ -94,6 +99,7 @@ typedef struct pe_tdata
|
||||||
int dll;
|
int dll;
|
||||||
int has_reloc_section;
|
int has_reloc_section;
|
||||||
boolean (*in_reloc_p) PARAMS((bfd *, reloc_howto_type *));
|
boolean (*in_reloc_p) PARAMS((bfd *, reloc_howto_type *));
|
||||||
|
flagword real_flags;
|
||||||
} pe_data_type;
|
} pe_data_type;
|
||||||
|
|
||||||
#define pe_data(bfd) ((bfd)->tdata.pe_obj_data)
|
#define pe_data(bfd) ((bfd)->tdata.pe_obj_data)
|
||||||
|
@ -217,6 +223,11 @@ struct coff_link_hash_entry
|
||||||
|
|
||||||
/* Pointer to array of auxiliary entries, if any. */
|
/* Pointer to array of auxiliary entries, if any. */
|
||||||
union internal_auxent *aux;
|
union internal_auxent *aux;
|
||||||
|
|
||||||
|
/* If this symbol requires an entry in the table of contents, the
|
||||||
|
processor specific backend uses this field to hold the offset
|
||||||
|
into the .toc section. */
|
||||||
|
bfd_vma toc_offset;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* COFF linker hash table. */
|
/* COFF linker hash table. */
|
||||||
|
|
|
@ -40,6 +40,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
#define obj_coff_keep_strings(bfd) (coff_data (bfd)->keep_strings)
|
#define obj_coff_keep_strings(bfd) (coff_data (bfd)->keep_strings)
|
||||||
#define obj_coff_sym_hashes(bfd) (coff_data (bfd)->sym_hashes)
|
#define obj_coff_sym_hashes(bfd) (coff_data (bfd)->sym_hashes)
|
||||||
|
|
||||||
|
#define obj_coff_local_toc_table(bfd) (coff_data(bfd)->local_toc_sym_map)
|
||||||
|
|
||||||
/* `Tdata' information kept for COFF files. */
|
/* `Tdata' information kept for COFF files. */
|
||||||
|
|
||||||
typedef struct coff_tdata
|
typedef struct coff_tdata
|
||||||
|
@ -83,6 +85,9 @@ typedef struct coff_tdata
|
||||||
/* Used by the COFF backend linker. */
|
/* Used by the COFF backend linker. */
|
||||||
struct coff_link_hash_entry **sym_hashes;
|
struct coff_link_hash_entry **sym_hashes;
|
||||||
|
|
||||||
|
/* used by the pe linker for PowerPC */
|
||||||
|
int *local_toc_sym_map;
|
||||||
|
|
||||||
struct bfd_link_info *link_info;
|
struct bfd_link_info *link_info;
|
||||||
} coff_data_type;
|
} coff_data_type;
|
||||||
|
|
||||||
|
@ -94,6 +99,7 @@ typedef struct pe_tdata
|
||||||
int dll;
|
int dll;
|
||||||
int has_reloc_section;
|
int has_reloc_section;
|
||||||
boolean (*in_reloc_p) PARAMS((bfd *, reloc_howto_type *));
|
boolean (*in_reloc_p) PARAMS((bfd *, reloc_howto_type *));
|
||||||
|
flagword real_flags;
|
||||||
} pe_data_type;
|
} pe_data_type;
|
||||||
|
|
||||||
#define pe_data(bfd) ((bfd)->tdata.pe_obj_data)
|
#define pe_data(bfd) ((bfd)->tdata.pe_obj_data)
|
||||||
|
@ -217,6 +223,11 @@ struct coff_link_hash_entry
|
||||||
|
|
||||||
/* Pointer to array of auxiliary entries, if any. */
|
/* Pointer to array of auxiliary entries, if any. */
|
||||||
union internal_auxent *aux;
|
union internal_auxent *aux;
|
||||||
|
|
||||||
|
/* If this symbol requires an entry in the table of contents, the
|
||||||
|
processor specific backend uses this field to hold the offset
|
||||||
|
into the .toc section. */
|
||||||
|
bfd_vma toc_offset;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* COFF linker hash table. */
|
/* COFF linker hash table. */
|
||||||
|
|
Loading…
Reference in New Issue