github.com/razvanm/vanadium-go-1.3@v0.0.0-20160721203343-4a65068e5915/src/cmd/ld/macho.h (about)

     1  // Copyright 2009 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  typedef struct MachoHdr MachoHdr;
     6  struct MachoHdr {
     7  	uint32	cpu;
     8  	uint32	subcpu;
     9  };
    10  
    11  typedef struct MachoSect MachoSect;
    12  struct MachoSect {
    13  	char*	name;
    14  	char*	segname;
    15  	uint64	addr;
    16  	uint64	size;
    17  	uint32	off;
    18  	uint32	align;
    19  	uint32	reloc;
    20  	uint32	nreloc;
    21  	uint32	flag;
    22  	uint32	res1;
    23  	uint32	res2;
    24  };
    25  
    26  typedef struct MachoSeg MachoSeg;
    27  struct MachoSeg {
    28  	char*	name;
    29  	uint64	vsize;
    30  	uint64	vaddr;
    31  	uint64	fileoffset;
    32  	uint64	filesize;
    33  	uint32	prot1;
    34  	uint32	prot2;
    35  	uint32	nsect;
    36  	uint32	msect;
    37  	MachoSect	*sect;
    38  	uint32	flag;
    39  };
    40  
    41  typedef struct MachoLoad MachoLoad;
    42  struct MachoLoad {
    43  	uint32	type;
    44  	uint32	ndata;
    45  	uint32	*data;
    46  };
    47  
    48  MachoHdr*	getMachoHdr(void);
    49  MachoSeg*	newMachoSeg(char*, int);
    50  MachoSect*	newMachoSect(MachoSeg*, char*, char*);
    51  MachoLoad*	newMachoLoad(uint32, uint32);
    52  int	machowrite(void);
    53  void	machoinit(void);
    54  void	machosymorder(void);
    55  void	machoemitreloc(void);
    56  int	machoreloc1(Reloc*, vlong);
    57  
    58  /*
    59   * Total amount of space to reserve at the start of the file
    60   * for Header, PHeaders, and SHeaders.
    61   * May waste some.
    62   */
    63  #define	INITIAL_MACHO_HEADR	4*1024
    64  
    65  enum {
    66  	MACHO_CPU_AMD64 = (1<<24)|7,
    67  	MACHO_CPU_386 = 7,
    68  	MACHO_SUBCPU_X86 = 3,
    69  
    70  	MACHO32SYMSIZE = 12,
    71  	MACHO64SYMSIZE = 16,
    72  	
    73  	MACHO_X86_64_RELOC_UNSIGNED = 0,
    74  	MACHO_X86_64_RELOC_SIGNED = 1,
    75  	MACHO_X86_64_RELOC_BRANCH = 2,
    76  	MACHO_X86_64_RELOC_GOT_LOAD = 3,
    77  	MACHO_X86_64_RELOC_GOT = 4,
    78  	MACHO_X86_64_RELOC_SUBTRACTOR = 5,
    79  	MACHO_X86_64_RELOC_SIGNED_1 = 6,
    80  	MACHO_X86_64_RELOC_SIGNED_2 = 7,
    81  	MACHO_X86_64_RELOC_SIGNED_4 = 8,
    82  	
    83  	MACHO_GENERIC_RELOC_VANILLA = 0,
    84  	
    85  	MACHO_FAKE_GOTPCREL = 100,
    86  };
    87  
    88  void	domacho(void);
    89  vlong	domacholink(void);
    90  void	asmbmacho(void);
    91  void	machoadddynlib(char*);