summaryrefslogtreecommitdiff
path: root/bfd/mach-o.h
diff options
context:
space:
mode:
authorTristan Gingold <gingold@adacore.com>2008-11-06 13:03:43 +0000
committerTristan Gingold <gingold@adacore.com>2008-11-06 13:03:43 +0000
commitd297acb5d793f7b228a638296cbdf28df13ba27b (patch)
treecbecca5fa0be480a1128b753a6fe7fd3ae8252fb /bfd/mach-o.h
parent4e87deb1b2bbb9446d99c446ebe092ca9d343ded (diff)
downloadgdb-d297acb5d793f7b228a638296cbdf28df13ba27b.tar.gz
2008-11-06 Tristan Gingold <gingold@adacore.com>
* mach-o.h (BFD_MACH_O_NO_SECT): Add; reorders the macros. (BFD_MACH_O_SYM_NTYPE, BFD_MACH_O_SYM_NSECT, BFD_MACH_O_SYM_NDESC): New macros. (bfd_mach_o_i386_thread_flavour): Define according to the latest definition from system header. (bfd_mach_o_load_command_type): Add BFD_MACH_O_LC_RPATH, BFD_MACH_O_LC_CODE_SIGNATURE. (BFD_MACH_O_SECTION_TYPE_MASK, BFD_MACH_O_SECTION_ATTRIBUTES_MASK, BFD_MACH_O_SECTION_ATTRIBUTES_SYS, BFD_MACH_O_SECTION_ATTRIBUTES_USR, BFD_MACH_O_S_ATTR_LOC_RELOC, BFD_MACH_O_S_ATTR_EXT_RELOC, BFD_MACH_O_S_ATTR_SOME_INSTRUCTIONS, BFD_MACH_O_S_ATTR_DEBUG, BFD_MACH_O_S_ATTR_PURE_INSTRUCTIONS): Add. (bfd_mach_o_segment_command): Add room for a nul terminator in segname field. (BFD_MACH_O_PROT_READ, BFD_MACH_O_PROT_WRITE, BFD_MACH_O_PROT_EXECUTE): Add. (INDIRECT_SYMBOL_LOCAL): Renames to BFD_MACH_O_INDIRECT_SYMBOL_LOCAL. (INDIRECT_SYMBOL_ABS): Renames to BFD_MACH_O_INDIRECT_SYMBOL_ABS. (bfd_mach_o_uuid_command): Add the structure. (bfd_mach_o_load_command): Add uuid field. (bfd_get_mach_o_data): New macro. * mach-o.c (bfd_mach_o_bfd_print_private_bfd_data): New function which replaces the macro. (SECTION_TYPE, SECTION_ATTRIBUTES, SECTION_ATTRIBUTES_USR, S_ATTR_PURE_INSTRUCTIONS, SECTION_ATTRIBUTES_SYS, S_ATTR_SOME_INSTRUCTIONS, S_ATTR_EXT_RELOC, S_ATTR_LOC_RELOC): Renamed and moved to mach-o.h. (N_STAB, N_TYPE, N_EXT, N_UNDF, N_ABS, N_TEXT, N_DATA, N_BSS, N_SECT, N_INDR): Removed as they duplicated macros in mach-o.h. (bfd_mach_o_print_symbol): Print much more details. (bfd_mach_o_make_bfd_section): Add prot argument, use canonical dwarf name for dwarf sections. Precisely set section flags. (bfd_mach_o_scan_read_section_32): Add prot argument. (bfd_mach_o_scan_read_section_64): Ditto. (bfd_mach_o_scan_read_section): Ditto. (bfd_mach_o_scan_read_symtab_symbol): Set section for debugging stabs, set BSF_GLOBAL and LOCAL flags correctly. Fix section for N_SECT symbols. (bfd_mach_o_i386_flavour_string): Reindent and adjust for new names. (bfd_mach_o_scan_read_symtab): Set HAS_SYMS flags on bfd if there are symbols. (bfd_mach_o_scan_read_uuid): New function. (bfd_mach_o_scan_read_segment): Add a trailing nul. Segments flags are now simply HAS_CONTENTS. Pass protection to bfd_mach_o_scan_read_section. (bfd_mach_o_scan_read_command): Decode UUID command. (bfd_mach_o_flatten_sections): Add comments. Fix flavour names. (bfd_mach_o_scan): Set flags according to file type. (mach_o_fat_archentry): Remove abfd field. (bfd_mach_o_archive_p): Remove initialization of abfd field. (bfd_mach_o_openr_next_archived_file): Find previous archive by position and not by bfd (as former bfds may have been freed). Give architecture name to archived file. * mach-o-target.c (TARGET_NAME): Use generic archive for non fat targets.
Diffstat (limited to 'bfd/mach-o.h')
-rw-r--r--bfd/mach-o.h94
1 files changed, 72 insertions, 22 deletions
diff --git a/bfd/mach-o.h b/bfd/mach-o.h
index d73f205e6de..8ffb1b242ea 100644
--- a/bfd/mach-o.h
+++ b/bfd/mach-o.h
@@ -30,9 +30,15 @@
#define BFD_MACH_O_N_EXT 0x01 /* External symbol bit, set for external symbols. */
#define BFD_MACH_O_N_UNDF 0x00 /* Undefined, n_sect == NO_SECT. */
#define BFD_MACH_O_N_ABS 0x02 /* Absolute, n_sect == NO_SECT. */
-#define BFD_MACH_O_N_SECT 0x0e /* Defined in section number n_sect. */
-#define BFD_MACH_O_N_PBUD 0x0c /* Prebound undefined (defined in a dylib). */
#define BFD_MACH_O_N_INDR 0x0a /* Indirect. */
+#define BFD_MACH_O_N_PBUD 0x0c /* Prebound undefined (defined in a dylib). */
+#define BFD_MACH_O_N_SECT 0x0e /* Defined in section number n_sect. */
+
+#define BFD_MACH_O_NO_SECT 0
+
+#define BFD_MACH_O_SYM_NTYPE(SYM) (((SYM)->udata.i >> 24) & 0xff)
+#define BFD_MACH_O_SYM_NSECT(SYM) (((SYM)->udata.i >> 16) & 0xff)
+#define BFD_MACH_O_SYM_NDESC(SYM) ((SYM)->udata.i & 0xffff)
typedef enum bfd_mach_o_ppc_thread_flavour
{
@@ -44,26 +50,22 @@ typedef enum bfd_mach_o_ppc_thread_flavour
}
bfd_mach_o_ppc_thread_flavour;
+/* Defined in <mach/i386/thread_status.h> */
typedef enum bfd_mach_o_i386_thread_flavour
{
- BFD_MACH_O_i386_NEW_THREAD_STATE = 1,
- BFD_MACH_O_i386_FLOAT_STATE = 2,
- BFD_MACH_O_i386_ISA_PORT_MAP_STATE = 3,
- BFD_MACH_O_i386_V86_ASSIST_STATE = 4,
- BFD_MACH_O_i386_REGS_SEGS_STATE = 5,
- BFD_MACH_O_i386_THREAD_SYSCALL_STATE = 6,
- BFD_MACH_O_i386_SAVED_STATE = 8,
- BFD_MACH_O_i386_THREAD_STATE = -1,
- BFD_MACH_O_i386_THREAD_FPSTATE = -2,
- BFD_MACH_O_i386_THREAD_EXCEPTSTATE = -3,
- BFD_MACH_O_i386_THREAD_CTHREADSTATE = -4,
+ BFD_MACH_O_x86_THREAD_STATE32 = 1,
+ BFD_MACH_O_x86_FLOAT_STATE32 = 2,
+ BFD_MACH_O_x86_EXCEPTION_STATE32 = 3,
BFD_MACH_O_x86_THREAD_STATE64 = 4,
BFD_MACH_O_x86_FLOAT_STATE64 = 5,
BFD_MACH_O_x86_EXCEPTION_STATE64 = 6,
BFD_MACH_O_x86_THREAD_STATE = 7,
BFD_MACH_O_x86_FLOAT_STATE = 8,
BFD_MACH_O_x86_EXCEPTION_STATE = 9,
- BFD_MACH_O_i386_THREAD_STATE_NONE = 10,
+ BFD_MACH_O_x86_DEBUG_STATE32 = 10,
+ BFD_MACH_O_x86_DEBUG_STATE64 = 11,
+ BFD_MACH_O_x86_DEBUG_STATE = 12,
+ BFD_MACH_O_THREAD_STATE_NONE = 13
}
bfd_mach_o_i386_thread_flavour;
@@ -99,9 +101,11 @@ typedef enum bfd_mach_o_load_command_type
BFD_MACH_O_LC_LOAD_WEAK_DYLIB = 0x18,
BFD_MACH_O_LC_SEGMENT_64 = 0x19, /* 64-bit segment of this file to be
mapped. */
- BFD_MACH_O_LC_ROUTINES_64 = 0x1a, /* Address of the dyld init routine
- in a dylib. */
- BFD_MACH_O_LC_UUID = 0x1b /* 128-bit UUID of the executable. */
+ BFD_MACH_O_LC_ROUTINES_64 = 0x1a, /* Address of the dyld init routine
+ in a dylib. */
+ BFD_MACH_O_LC_UUID = 0x1b, /* 128-bit UUID of the executable. */
+ BFD_MACH_O_LC_RPATH = 0x1c, /* Run path addiions. */
+ BFD_MACH_O_LC_CODE_SIGNATURE = 0x1d /* Local of code signature. */
}
bfd_mach_o_load_command_type;
@@ -188,6 +192,35 @@ typedef enum bfd_mach_o_section_type
}
bfd_mach_o_section_type;
+/* 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
+ can only have one type) but the section attributes are not (it may have more
+ than one attribute). */
+
+#define BFD_MACH_O_SECTION_TYPE_MASK 0x000000ff
+
+/* Constants for the section attributes part of the flags field of a section
+ structure. */
+#define BFD_MACH_O_SECTION_ATTRIBUTES_MASK 0xffffff00
+/* System setable attributes. */
+#define BFD_MACH_O_SECTION_ATTRIBUTES_SYS 0x00ffff00
+/* User attributes. */
+#define BFD_MACH_O_SECTION_ATTRIBUTES_USR 0xff000000
+
+/* Section has local relocation entries. */
+#define BFD_MACH_O_S_ATTR_LOC_RELOC 0x00000100
+
+/* Section has external relocation entries. */
+#define BFD_MACH_O_S_ATTR_EXT_RELOC 0x00000200
+
+/* Section contains some machine instructions. */
+#define BFD_MACH_O_S_ATTR_SOME_INSTRUCTIONS 0x00004000
+
+#define BFD_MACH_O_S_ATTR_DEBUG 0x02000000
+
+/* Section contains only true machine instructions. */
+#define BFD_MACH_O_S_ATTR_PURE_INSTRUCTIONS 0x80000000
+
typedef unsigned long bfd_mach_o_cpu_subtype;
typedef struct bfd_mach_o_header
@@ -226,13 +259,13 @@ bfd_mach_o_section;
typedef struct bfd_mach_o_segment_command
{
- char segname[16];
+ char segname[16 + 1];
bfd_vma vmaddr;
bfd_vma vmsize;
bfd_vma fileoff;
unsigned long filesize;
- unsigned long maxprot;
- unsigned long initprot;
+ unsigned long maxprot; /* Maximum permitted protection. */
+ unsigned long initprot; /* Initial protection. */
unsigned long nsects;
unsigned long flags;
bfd_mach_o_section *sections;
@@ -240,6 +273,11 @@ typedef struct bfd_mach_o_segment_command
}
bfd_mach_o_segment_command;
+/* Protection flags. */
+#define BFD_MACH_O_PROT_READ 0x01
+#define BFD_MACH_O_PROT_WRITE 0x02
+#define BFD_MACH_O_PROT_EXECUTE 0x04
+
typedef struct bfd_mach_o_symtab_command
{
unsigned long symoff;
@@ -399,8 +437,8 @@ bfd_mach_o_dysymtab_command;
removed. In which case it has the value INDIRECT_SYMBOL_LOCAL. If the
symbol was also absolute INDIRECT_SYMBOL_ABS is or'ed with that. */
-#define INDIRECT_SYMBOL_LOCAL 0x80000000
-#define INDIRECT_SYMBOL_ABS 0x40000000
+#define BFD_MACH_O_INDIRECT_SYMBOL_LOCAL 0x80000000
+#define BFD_MACH_O_INDIRECT_SYMBOL_ABS 0x40000000
typedef struct bfd_mach_o_thread_flavour
{
@@ -452,6 +490,15 @@ typedef struct bfd_mach_o_prebound_dylib_command
}
bfd_mach_o_prebound_dylib_command;
+typedef struct bfd_mach_o_uuid_command
+{
+ unsigned long cmd; /* LC_PREBOUND_DYLIB. */
+ unsigned long cmdsize; /* Includes uuid. */
+ unsigned char uuid[16]; /* Uuid. */
+ asection *section;
+}
+bfd_mach_o_uuid_command;
+
typedef struct bfd_mach_o_load_command
{
bfd_mach_o_load_command_type type;
@@ -467,6 +514,7 @@ typedef struct bfd_mach_o_load_command
bfd_mach_o_dylib_command dylib;
bfd_mach_o_dylinker_command dylinker;
bfd_mach_o_prebound_dylib_command prebound_dylib;
+ bfd_mach_o_uuid_command uuid;
}
command;
}
@@ -484,6 +532,8 @@ typedef struct mach_o_data_struct
}
mach_o_data_struct;
+#define bfd_get_mach_o_data(abfd) ((abfd)->tdata.mach_o_data)
+
typedef struct mach_o_data_struct bfd_mach_o_data_struct;
bfd_boolean bfd_mach_o_valid (bfd *);