/* Mach-O support for BFD.
- Copyright 1999, 2000, 2001, 2002
+ Copyright 1999, 2000, 2001, 2002, 2003, 2004
Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
#define bfd_mach_o_new_section_hook _bfd_generic_new_section_hook
#define bfd_mach_o_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
#define bfd_mach_o_bfd_is_local_label_name _bfd_nosymbols_bfd_is_local_label_name
+#define bfd_mach_o_bfd_is_target_special_symbol ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
+#define bfd_mach_o_bfd_is_local_label_name _bfd_nosymbols_bfd_is_local_label_name
#define bfd_mach_o_get_lineno _bfd_nosymbols_get_lineno
#define bfd_mach_o_find_nearest_line _bfd_nosymbols_find_nearest_line
#define bfd_mach_o_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
#define bfd_mach_o_set_section_contents _bfd_generic_set_section_contents
#define bfd_mach_o_bfd_gc_sections bfd_generic_gc_sections
#define bfd_mach_o_bfd_merge_sections bfd_generic_merge_sections
+#define bfd_mach_o_bfd_is_group_section bfd_generic_is_group_section
#define bfd_mach_o_bfd_discard_group bfd_generic_discard_group
-
-static boolean bfd_mach_o_bfd_copy_private_symbol_data PARAMS ((bfd *, asymbol *, bfd *, asymbol *));
-static boolean bfd_mach_o_bfd_copy_private_section_data PARAMS ((bfd *, asection *, bfd *, asection *));
-static boolean bfd_mach_o_bfd_copy_private_bfd_data PARAMS ((bfd *, bfd *));
-static long bfd_mach_o_count_symbols PARAMS ((bfd *));
-static long bfd_mach_o_get_symtab_upper_bound PARAMS ((bfd *));
-static long bfd_mach_o_get_symtab PARAMS ((bfd *, asymbol **));
-static void bfd_mach_o_get_symbol_info PARAMS ((bfd *, asymbol *, symbol_info *));
-static void bfd_mach_o_print_symbol PARAMS ((bfd *, PTR, asymbol *, bfd_print_symbol_type));
-static void bfd_mach_o_convert_architecture PARAMS ((bfd_mach_o_cpu_type, bfd_mach_o_cpu_subtype, enum bfd_architecture *, unsigned long *));
-static boolean bfd_mach_o_write_contents PARAMS ((bfd *));
-static int bfd_mach_o_sizeof_headers PARAMS ((bfd *, boolean));
-static asymbol * bfd_mach_o_make_empty_symbol PARAMS ((bfd *));
-static int bfd_mach_o_write_header PARAMS ((bfd *, bfd_mach_o_header *));
-static int bfd_mach_o_read_header PARAMS ((bfd *, bfd_mach_o_header *));
-static asection * bfd_mach_o_make_bfd_section PARAMS ((bfd *, bfd_mach_o_section *));
-static int bfd_mach_o_scan_read_section PARAMS ((bfd *, bfd_mach_o_section *, bfd_vma));
-static int bfd_mach_o_scan_write_section PARAMS ((bfd *, bfd_mach_o_section *, bfd_vma));
-static int bfd_mach_o_scan_write_symtab_symbols PARAMS ((bfd *, bfd_mach_o_load_command *));
-static int bfd_mach_o_scan_write_thread PARAMS ((bfd *, bfd_mach_o_load_command *));
-static int bfd_mach_o_scan_read_dylinker PARAMS ((bfd *, bfd_mach_o_load_command *));
-static int bfd_mach_o_scan_read_dylib PARAMS ((bfd *, bfd_mach_o_load_command *));
-static int bfd_mach_o_scan_read_prebound_dylib PARAMS ((bfd *, bfd_mach_o_load_command *));
-static int bfd_mach_o_scan_read_thread PARAMS ((bfd *, bfd_mach_o_load_command *));
-static int bfd_mach_o_scan_write_symtab PARAMS ((bfd *, bfd_mach_o_load_command *));
-static int bfd_mach_o_scan_read_dysymtab PARAMS ((bfd *, bfd_mach_o_load_command *));
-static int bfd_mach_o_scan_read_symtab PARAMS ((bfd *, bfd_mach_o_load_command *));
-static int bfd_mach_o_scan_read_segment PARAMS ((bfd *, bfd_mach_o_load_command *));
-static int bfd_mach_o_scan_write_segment PARAMS ((bfd *, bfd_mach_o_load_command *));
-static int bfd_mach_o_scan_read_command PARAMS ((bfd *, bfd_mach_o_load_command *));
-static void bfd_mach_o_flatten_sections PARAMS ((bfd *));
-static const char * bfd_mach_o_i386_flavour_string PARAMS ((unsigned int));
-static const char * bfd_mach_o_ppc_flavour_string PARAMS ((unsigned int));
+#define bfd_mach_o_section_already_linked \
+ _bfd_generic_section_already_linked
+#define bfd_mach_o_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data
+
+static bfd_boolean bfd_mach_o_bfd_copy_private_symbol_data
+ PARAMS ((bfd *, asymbol *, bfd *, asymbol *));
+static bfd_boolean bfd_mach_o_bfd_copy_private_section_data
+ PARAMS ((bfd *, asection *, bfd *, asection *));
+static bfd_boolean bfd_mach_o_bfd_copy_private_bfd_data
+ PARAMS ((bfd *, bfd *));
+static long bfd_mach_o_count_symbols
+ PARAMS ((bfd *));
+static long bfd_mach_o_get_symtab_upper_bound
+ PARAMS ((bfd *));
+static long bfd_mach_o_canonicalize_symtab
+ PARAMS ((bfd *, asymbol **));
+static void bfd_mach_o_get_symbol_info
+ PARAMS ((bfd *, asymbol *, symbol_info *));
+static void bfd_mach_o_print_symbol
+ PARAMS ((bfd *, PTR, asymbol *, bfd_print_symbol_type));
+static void bfd_mach_o_convert_architecture
+ PARAMS ((bfd_mach_o_cpu_type, bfd_mach_o_cpu_subtype,
+ enum bfd_architecture *, unsigned long *));
+static bfd_boolean bfd_mach_o_write_contents
+ PARAMS ((bfd *));
+static int bfd_mach_o_sizeof_headers
+ PARAMS ((bfd *, bfd_boolean));
+static asymbol * bfd_mach_o_make_empty_symbol
+ PARAMS ((bfd *));
+static int bfd_mach_o_write_header
+ PARAMS ((bfd *, bfd_mach_o_header *));
+static int bfd_mach_o_read_header
+ PARAMS ((bfd *, bfd_mach_o_header *));
+static asection * bfd_mach_o_make_bfd_section
+ PARAMS ((bfd *, bfd_mach_o_section *));
+static int bfd_mach_o_scan_read_section
+ PARAMS ((bfd *, bfd_mach_o_section *, bfd_vma));
+static int bfd_mach_o_scan_write_section
+ PARAMS ((bfd *, bfd_mach_o_section *, bfd_vma));
+static int bfd_mach_o_scan_write_symtab_symbols
+ PARAMS ((bfd *, bfd_mach_o_load_command *));
+static int bfd_mach_o_scan_write_thread
+ PARAMS ((bfd *, bfd_mach_o_load_command *));
+static int bfd_mach_o_scan_read_dylinker
+ PARAMS ((bfd *, bfd_mach_o_load_command *));
+static int bfd_mach_o_scan_read_dylib
+ PARAMS ((bfd *, bfd_mach_o_load_command *));
+static int bfd_mach_o_scan_read_prebound_dylib
+ PARAMS ((bfd *, bfd_mach_o_load_command *));
+static int bfd_mach_o_scan_read_thread
+ PARAMS ((bfd *, bfd_mach_o_load_command *));
+static int bfd_mach_o_scan_write_symtab
+ PARAMS ((bfd *, bfd_mach_o_load_command *));
+static int bfd_mach_o_scan_read_dysymtab
+ PARAMS ((bfd *, bfd_mach_o_load_command *));
+static int bfd_mach_o_scan_read_symtab
+ PARAMS ((bfd *, bfd_mach_o_load_command *));
+static int bfd_mach_o_scan_read_segment
+ PARAMS ((bfd *, bfd_mach_o_load_command *));
+static int bfd_mach_o_scan_write_segment
+ PARAMS ((bfd *, bfd_mach_o_load_command *));
+static int bfd_mach_o_scan_read_command
+ PARAMS ((bfd *, bfd_mach_o_load_command *));
+static void bfd_mach_o_flatten_sections
+ PARAMS ((bfd *));
+static const char * bfd_mach_o_i386_flavour_string
+ PARAMS ((unsigned int));
+static const char * bfd_mach_o_ppc_flavour_string
+ PARAMS ((unsigned int));
/* The flags field of a section structure is separated into two parts a section
type and section attributes. The section types are mutually exclusive (it
#define N_SECT 0xe
#define N_INDR 0xa
-boolean
+bfd_boolean
bfd_mach_o_valid (abfd)
bfd *abfd;
{
/* Copy any private info we understand from the input symbol
to the output symbol. */
-static boolean
+static bfd_boolean
bfd_mach_o_bfd_copy_private_symbol_data (ibfd, isymbol, obfd, osymbol)
bfd *ibfd ATTRIBUTE_UNUSED;
asymbol *isymbol ATTRIBUTE_UNUSED;
bfd *obfd ATTRIBUTE_UNUSED;
asymbol *osymbol ATTRIBUTE_UNUSED;
{
- return true;
+ return TRUE;
}
/* Copy any private info we understand from the input section
to the output section. */
-static boolean
+static bfd_boolean
bfd_mach_o_bfd_copy_private_section_data (ibfd, isection, obfd, osection)
bfd *ibfd ATTRIBUTE_UNUSED;
asection *isection ATTRIBUTE_UNUSED;
bfd *obfd ATTRIBUTE_UNUSED;
asection *osection ATTRIBUTE_UNUSED;
{
- return true;
+ return TRUE;
}
/* Copy any private info we understand from the input bfd
to the output bfd. */
-static boolean
+static bfd_boolean
bfd_mach_o_bfd_copy_private_bfd_data (ibfd, obfd)
bfd *ibfd;
bfd *obfd;
obfd->tdata.mach_o_data = ibfd->tdata.mach_o_data;
obfd->tdata.mach_o_data->ibfd = ibfd;
- return true;
+ return TRUE;
}
static long
}
static long
-bfd_mach_o_get_symtab (abfd, alocation)
+bfd_mach_o_canonicalize_symtab (abfd, alocation)
bfd *abfd;
asymbol **alocation;
{
if (bfd_mach_o_scan_read_symtab_symbols (abfd, &mdata->commands[i].command.symtab) != 0)
{
- fprintf (stderr, "bfd_mach_o_get_symtab: unable to load symbols for section %lu\n", i);
+ fprintf (stderr, "bfd_mach_o_canonicalize_symtab: unable to load symbols for section %lu\n", i);
return 0;
}
}
}
-static boolean
+static bfd_boolean
bfd_mach_o_write_contents (abfd)
bfd *abfd;
{
bfd_seek (abfd, curoff, SEEK_SET);
if (bfd_bread ((PTR) buf, thisread, abfd) != thisread)
- return false;
+ return FALSE;
bfd_seek (abfd, curoff, SEEK_SET);
if (bfd_bwrite ((PTR) buf, thisread, abfd) != thisread)
- return false;
+ return FALSE;
nbytes -= thisread;
curoff += thisread;
/* Now write header information. */
if (bfd_mach_o_write_header (abfd, &mdata->header) != 0)
- return false;
+ return FALSE;
for (i = 0; i < mdata->header.ncmds; i++)
{
bfd_seek (abfd, cur->offset, SEEK_SET);
if (bfd_bwrite ((PTR) buf, 8, abfd) != 8)
- return false;
+ return FALSE;
switch (cur->type)
{
case BFD_MACH_O_LC_SEGMENT:
if (bfd_mach_o_scan_write_segment (abfd, cur) != 0)
- return false;
+ return FALSE;
break;
case BFD_MACH_O_LC_SYMTAB:
if (bfd_mach_o_scan_write_symtab (abfd, cur) != 0)
- return false;
+ return FALSE;
break;
case BFD_MACH_O_LC_SYMSEG:
break;
case BFD_MACH_O_LC_THREAD:
case BFD_MACH_O_LC_UNIXTHREAD:
if (bfd_mach_o_scan_write_thread (abfd, cur) != 0)
- return false;
+ return FALSE;
break;
case BFD_MACH_O_LC_LOADFVMLIB:
case BFD_MACH_O_LC_IDFVMLIB:
fprintf (stderr,
"unable to write unknown load command 0x%lx\n",
(long) cur->type);
- return false;
+ return FALSE;
}
}
- return true;
+ return TRUE;
}
static int
bfd_mach_o_sizeof_headers (a, b)
bfd *a ATTRIBUTE_UNUSED;
- boolean b ATTRIBUTE_UNUSED;
+ bfd_boolean b ATTRIBUTE_UNUSED;
{
return 0;
}
bfd_mach_o_header *header;
{
unsigned char buf[28];
- bfd_vma (*get32) PARAMS ((const bfd_byte *)) = NULL;
+ bfd_vma (*get32) (const void *) = NULL;
bfd_seek (abfd, 0, SEEK_SET);
bfdsec->vma = section->addr;
bfdsec->lma = section->addr;
- bfdsec->_raw_size = section->size;
+ bfdsec->size = section->size;
bfdsec->filepos = section->offset;
bfdsec->alignment_power = section->align;
bfdsec->vma = 0;
bfdsec->lma = 0;
- bfdsec->_raw_size = command->len - 8;
+ bfdsec->size = command->len - 8;
bfdsec->filepos = command->offset + 8;
bfdsec->alignment_power = 0;
bfdsec->flags = SEC_HAS_CONTENTS;
bfdsec->vma = 0;
bfdsec->lma = 0;
- bfdsec->_raw_size = command->len - 8;
+ bfdsec->size = command->len - 8;
bfdsec->filepos = command->offset + 8;
bfdsec->alignment_power = 0;
bfdsec->flags = SEC_HAS_CONTENTS;
bfdsec->vma = 0;
bfdsec->lma = 0;
- bfdsec->_raw_size = cmd->flavours[i].size;
+ bfdsec->size = cmd->flavours[i].size;
bfdsec->filepos = cmd->flavours[i].offset;
bfdsec->alignment_power = 0x0;
bfdsec->flags = SEC_HAS_CONTENTS;
bfdsec->vma = 0;
bfdsec->lma = 0;
- bfdsec->_raw_size = seg->nsyms * 12;
+ bfdsec->size = seg->nsyms * 12;
bfdsec->filepos = seg->symoff;
bfdsec->alignment_power = 0;
bfdsec->flags = SEC_HAS_CONTENTS;
bfdsec->vma = 0;
bfdsec->lma = 0;
- bfdsec->_raw_size = seg->strsize;
+ bfdsec->size = seg->strsize;
bfdsec->filepos = seg->stroff;
bfdsec->alignment_power = 0;
bfdsec->flags = SEC_HAS_CONTENTS;
bfdsec->vma = seg->vmaddr;
bfdsec->lma = seg->vmaddr;
- bfdsec->_raw_size = seg->filesize;
+ bfdsec->size = seg->filesize;
bfdsec->filepos = seg->fileoff;
bfdsec->alignment_power = 0x0;
bfdsec->flags = SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC | SEC_CODE;
return 0;
}
-boolean
+bfd_boolean
bfd_mach_o_mkobject (abfd)
bfd *abfd;
{
mdata = ((bfd_mach_o_data_struct *)
bfd_alloc (abfd, sizeof (bfd_mach_o_data_struct)));
if (mdata == NULL)
- return false;
+ return FALSE;
abfd->tdata.mach_o_data = mdata;
mdata->header.magic = 0;
mdata->sections = NULL;
mdata->ibfd = NULL;
- return true;
+ return TRUE;
}
const bfd_target *
return 0;
}
-boolean
+bfd_boolean
bfd_mach_o_core_file_matches_executable_p (core_bfd, exec_bfd)
bfd *core_bfd ATTRIBUTE_UNUSED;
bfd *exec_bfd ATTRIBUTE_UNUSED;
{
- return true;
+ return TRUE;
}
#define TARGET_NAME mach_o_be_vec