dmd.backend.machobj

Generate Mach-O object files

Compiler implementation of the D programming language.

Members

Enums

RELaddr
anonymousenum RELaddr

Because the Mach-O relocations cannot be computed until after all the segments are written out, and we need more information than the Mach-O relocations provide, make our own relocation type. Later, translate to Mach-O relocation structure.

Functions

MachObj_addrel
void MachObj_addrel(int seg, targ_size_t offset, Symbol* targsym, uint targseg, int rtype, int val)

Add a relocation entry for seg/offset.

MachObj_addstr
IDXSTR MachObj_addstr(OutBuffer* strtab, const(char)* str)

Output a string into a string table Input: strtab = string table for entry str = string to add

MachObj_alias
void MachObj_alias(const(char)* n1, const(char)* n2)

Output an alias definition record.

MachObj_allowZeroSize
bool MachObj_allowZeroSize()

Do we allow zero sized objects?

MachObj_byte
void MachObj_byte(int seg, targ_size_t offset, uint byte_)

Output byte to object file.

MachObj_bytes
size_t MachObj_bytes(int seg, targ_size_t offset, size_t nbytes, const(void)* p)

Output bytes to object file.

MachObj_codeseg
int MachObj_codeseg(char* name, int suffix)

Define a new code segment. Input: name name of segment, if null then revert to default suffix 0 use name as is 1 append "_TEXT" to name Output: cseg segment index of new current code segment Offset(cseg) starting offset in cseg

MachObj_comdatsize
int MachObj_comdatsize(Symbol* s, targ_size_t symsize)

Setup for Symbol s to go into a COMDAT segment. Output (if s is a function): cseg segment index of new current code segment Offset(cseg) starting offset in cseg

MachObj_common_block
int MachObj_common_block(Symbol* s, targ_size_t size, targ_size_t count)

Output a common block definition. Input: p . external identifier size size in bytes of each elem count number of elems

MachObj_compiler
void MachObj_compiler(const(char)* p)

Embed compiler version in .obj file.

MachObj_data_readonly
int MachObj_data_readonly(char* p, int len, int* pseg)

Ouput read only data for data

MachObj_data_start
int MachObj_data_start(Symbol* sdata, targ_size_t datasize, int seg)

Update data information about symbol align for output and assign segment if not already specified.

MachObj_ehsections
void MachObj_ehsections()

Put out symbols that define the beginning/end of the .deh_eh section. This gets called if this is the module with "main()" in it.

MachObj_ehtables
void MachObj_ehtables(Symbol* sfunc, uint size, Symbol* ehsym)

Stuff the following data (instance of struct FuncTable) in a separate segment: pointer to function pointer to ehsym length of function

MachObj_exestr
void MachObj_exestr(const(char)* p)

Embed string in executable.

MachObj_export_symbol
void MachObj_export_symbol(Symbol* s, uint argsize)

Export a function name.

MachObj_external
int MachObj_external(Symbol* s)

Output an external for existing symbol. Input: s Symbol to do EXTDEF on (Name is to be mangled)

MachObj_external_def
int MachObj_external_def(const(char)* name)

Output an external symbol for name. Input: name Name to do EXTDEF on (Not to be mangled)

MachObj_far16thunk
void MachObj_far16thunk(Symbol* s)

Generate far16 thunk. Input: s Symbol to generate a thunk for

MachObj_filename
void MachObj_filename(const(char)* modname)

Output file name record.

MachObj_fltused
void MachObj_fltused()

Mark object file as using floating point.

MachObj_func_start
void MachObj_func_start(Symbol* sfunc)

Update function info before codgen

MachObj_func_term
void MachObj_func_term(Symbol* sfunc)

Update function info after codgen

MachObj_getGOTsym
Symbol* MachObj_getGOTsym()
MachObj_getsegment
int MachObj_getsegment(const(char)* sectname, const(char)* segname, int align_, int flags)

Get segment. Input: align_ segment alignment as power of 2

MachObj_gotref
void MachObj_gotref(Symbol* s)
MachObj_includelib
bool MachObj_includelib(char[] name)

Output library name.

MachObj_init
Obj MachObj_init(OutBuffer* objbuf, const(char)* filename, const(char)* csegname)

Perform initialization that applies to all .o output files. Called before any other obj_xxx routines

MachObj_initfile
void MachObj_initfile(const(char)* filename, const(char)* csegname, const(char)* modname)

Initialize the start of object output for this particular .o file.

MachObj_jmpTableSegment
int MachObj_jmpTableSegment(Symbol* s)
MachObj_lidata
void MachObj_lidata(int seg, targ_size_t offset, targ_size_t count)

Output an iterated data block of 0s.

MachObj_linkerdirective
bool MachObj_linkerdirective(const(char)* name)

Output linker directive.

MachObj_linnum
void MachObj_linnum(Srcpos srcpos, int seg, targ_size_t offset)

Record file and line number at segment and offset. The actual .debug_line segment is put out by dwarf_termfile().

MachObj_moduleinfo
void MachObj_moduleinfo(Symbol* scc)

Stuff pointer to ModuleInfo in its own segment.

MachObj_pubdefsize
void MachObj_pubdefsize(int seg, Symbol* s, targ_size_t offset, targ_size_t symsize)

Output a public definition. Input: seg = segment index that symbol is defined in s . symbol offset = offset of name within segment

MachObj_reftocodeseg
void MachObj_reftocodeseg(int seg, targ_size_t offset, targ_size_t val)

Refer to address that is in the current function code (funcsym_p). Only offsets are output, regardless of the memory model. Used to put values in switch address tables. Input: seg = where the address is going (CODE or DATA) offset = offset within seg val = displacement from start of this module

MachObj_reftodatseg
void MachObj_reftodatseg(int seg, targ_size_t offset, targ_size_t val, uint targetdatum, int flags)

Refer to address that is in the data segment. Input: seg:offset = the address being fixed up val = displacement from start of target segment targetdatum = target segment number (DATA, CDATA or UDATA, etc.) flags = CFoff, CFseg

MachObj_reftoident
int MachObj_reftoident(int seg, targ_size_t offset, Symbol* s, targ_size_t val, int flags)

Refer to an identifier. Input: seg = where the address is going (CODE or DATA) offset = offset within seg s . Symbol table entry for identifier val = displacement from identifier flags = CFselfrel: self-relative CFseg: get segment CFoff: get offset CFpc32: RIP addressing, val is 0, -1, -2 or -4 CFoffset64: 8 byte offset for 64 bit builds

MachObj_setModuleCtorDtor
void MachObj_setModuleCtorDtor(Symbol* sfunc, bool isCtor)

Stuff pointer to function in its own segment. Used for static ctor and dtor lists.

MachObj_setcodeseg
void MachObj_setcodeseg(int seg)

Reset code seg to existing seg. Used after a COMDAT for a function is done.

MachObj_startaddress
void MachObj_startaddress(Symbol* s)

Set start address

MachObj_staticctor
void MachObj_staticctor(Symbol* s, int , int )

Symbol is the function that calls the static constructors. Put a pointer to it into a special segment that the startup code looks at. Input: s static constructor function dtor !=0 if leave space for static destructor seg 1: user 2: lib 3: compiler

MachObj_staticdtor
void MachObj_staticdtor(Symbol* s)

Symbol is the function that calls the static destructors. Put a pointer to it into a special segment that the exit code looks at. Input: s static destructor function

MachObj_string_literal_segment
int MachObj_string_literal_segment(uint sz)

Get segment for readonly string literals. The linker will pool strings in this section.

MachObj_sym_cdata
Symbol* MachObj_sym_cdata(tym_t ty, char* p, int len)

Ouput read only data and generate a symbol for it.

MachObj_term
void MachObj_term(const(char)* objfilename)

Terminate package.

MachObj_termfile
void MachObj_termfile()

Fixup and terminate object file.

MachObj_tlsseg
seg_data* MachObj_tlsseg()

Define segments for Thread Local Storage for 32bit. Output: seg_tlsseg set to segment number for TLS segment.

MachObj_tlsseg_bss
seg_data* MachObj_tlsseg_bss()

Define segments for Thread Local Storage. Output: seg_tlsseg_bss set to segment number for TLS segment.

MachObj_tlsseg_data
seg_data* MachObj_tlsseg_data()

Define segments for Thread Local Storage data. Output: seg_tlsseg_data set to segment number for TLS data segment.

MachObj_tlv_bootstrap
Symbol* MachObj_tlv_bootstrap()

Returns the symbol for the __tlv_bootstrap function.

MachObj_user
void MachObj_user(const(char)* p)

Embed string in obj.

MachObj_wkext
void MachObj_wkext(Symbol* s1, Symbol* s2)

Output a weak extern record.

MachObj_write_byte
void MachObj_write_byte(seg_data* pseg, uint byte_)

Append byte to segment.

MachObj_write_bytes
void MachObj_write_bytes(seg_data* pseg, const(void[]) a)

Append bytes to segment.

MachObj_write_zeros
void MachObj_write_zeros(seg_data* pseg, targ_size_t count)

Append an iterated data block of 0s. (uninitialized data only)

dwarf_eh_frame_fixup
int dwarf_eh_frame_fixup(int dfseg, targ_size_t offset, Symbol* s, targ_size_t val, Symbol* fdesym)

Generate LSDA and PC_Begin fixups in the __eh_frame segment encoded as DW_EH_PE_pcrel|ptr. 64 bits LSDA [0] address x0071 symbolnum 6 pcrel 0 length 3 extern 1 type 5 RELOC_SUBTRACTOR __Z3foov.eh [1] address x0071 symbolnum 1 pcrel 0 length 3 extern 1 type 0 RELOC_UNSIGNED GCC_except_table2

getsegment2
int getsegment2(int seg, const(char)* sectname, const(char)* segname, int align_, int flags)

Memoize seg index.

mach_dwarf_reftoident
int mach_dwarf_reftoident(int seg, targ_size_t offset, Symbol* s, targ_size_t val)

Generate fixup specific to .eh_frame and .gcc_except_table sections.

mach_numbersyms
void mach_numbersyms()

Number symbols so they are ordered as locals, public and then extern/comdef

mach_seg_data_isCode
int mach_seg_data_isCode(seg_data sd)

Returns !=0 if this segment is a code segment.

machobjfile_delete
void machobjfile_delete()

Close and delete .OBJ file.

machobjfile_term
void machobjfile_term()

Terminate.

patchAddr
int32_t* patchAddr(int seg, targ_size_t offset)

Patch pseg/offset by adding in the vmaddr difference from pseg/offset to start of seg.

Static variables

eh_frame_seg (from dmd.backend.dwarfdbginf)
int eh_frame_seg; via public import dmd.backend.dwarfdbginf : except_table_seg, eh_frame_seg;
Undocumented in source.
except_table_seg (from dmd.backend.dwarfdbginf)
int except_table_seg; via public import dmd.backend.dwarfdbginf : except_table_seg, eh_frame_seg;
Undocumented in source.
seg_tlsseg_data
int seg_tlsseg_data;

Section index for the __thread_data section.

Meta