dmd.backend.machobj

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

Obj_addrel
void Obj_addrel(int seg, targ_size_t offset, Symbol* targsym, uint targseg, int rtype, int val = 0)

Add a relocation entry for seg/offset.

Obj_addstr
IDXSTR Obj_addstr(Outbuffer* strtab, const(char)* str)

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

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

Output an alias definition record.

Obj_allowZeroSize
bool Obj_allowZeroSize()

Do we allow zero sized objects?

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

Output byte to object file.

Obj_bytes
uint Obj_bytes(int seg, targ_size_t offset, uint nbytes, void* p)

Output bytes to object file.

Obj_codeseg
int Obj_codeseg(const 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

Obj_comdatsize
int Obj_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

Obj_common_block
int Obj_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

Obj_compiler
void Obj_compiler()

Embed compiler version in .obj file.

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

Ouput read only data for data

Obj_data_start
int Obj_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.

Obj_ehsections
void Obj_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.

Obj_ehtables
void Obj_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

Obj_exestr
void Obj_exestr(const(char)* p)

Embed string in executable.

Obj_export_symbol
void Obj_export_symbol(Symbol* s, uint argsize)

Export a function name.

Obj_external
int Obj_external(Symbol* s)

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

Obj_external_def
int Obj_external_def(const(char)* name)

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

Obj_far16thunk
void Obj_far16thunk(Symbol* s)

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

Obj_fltused
void Obj_fltused()

Mark object file as using floating point.

Obj_func_start
void Obj_func_start(Symbol* sfunc)

Update function info before codgen

Obj_func_term
void Obj_func_term(Symbol* sfunc)

Update function info after codgen

Obj_getGOTsym
Symbol* Obj_getGOTsym()
Obj_getsegment
int Obj_getsegment(const(char)* sectname, const(char)* segname, int align_, int flags)

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

Obj_gotref
void Obj_gotref(Symbol* s)
Obj_includelib
bool Obj_includelib(const(char)* name)

Output library name.

Obj_init
Obj Obj_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

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

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

Obj_jmpTableSegment
int Obj_jmpTableSegment(Symbol* s)
Obj_lidata
void Obj_lidata(int seg, targ_size_t offset, targ_size_t count)

Output an iterated data block of 0s.

Obj_linkerdirective
bool Obj_linkerdirective(const(char)* name)

Output linker directive.

Obj_linnum
void Obj_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().

Obj_moduleinfo
void Obj_moduleinfo(Symbol* scc)

Stuff pointer to ModuleInfo in its own segment.

Obj_pubdefsize
void Obj_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

Obj_reftocodeseg
void Obj_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

Obj_reftodatseg
void Obj_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

Obj_reftoident
int Obj_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

Obj_setModuleCtorDtor
void Obj_setModuleCtorDtor(Symbol* sfunc, bool isCtor)

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

Obj_setcodeseg
void Obj_setcodeseg(int seg)

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

Obj_startaddress
void Obj_startaddress(Symbol* s)

Set start address

Obj_staticctor
void Obj_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

Obj_staticdtor
void Obj_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

Obj_string_literal_segment
int Obj_string_literal_segment(uint sz)

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

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

Ouput read only data and generate a symbol for it.

Obj_term
void Obj_term(const(char)* objfilename)

Terminate package.

Obj_termfile
void Obj_termfile()

Fixup and terminate object file.

Obj_tlsseg
seg_data* Obj_tlsseg()

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

Obj_tlsseg_bss
seg_data* Obj_tlsseg_bss()

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

Obj_tlsseg_data
seg_data* Obj_tlsseg_data()

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

Obj_tlv_bootstrap
Symbol* Obj_tlv_bootstrap()

Returns the symbol for the __tlv_bootstrap function.

Obj_user
void Obj_user(const(char)* p)

Embed string in obj.

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

Output a weak extern record.

Obj_write_byte
void Obj_write_byte(seg_data* pseg, uint byte_)

Append byte to segment.

Obj_write_bytes
void Obj_write_bytes(seg_data* pseg, uint nbytes, void* p)

Append bytes to segment.

Obj_write_zeros
void Obj_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

dwarf_reftoident
int 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.

elf_align
int elf_align(targ_size_t size, int foffset)

Write to the object file

mach_numbersyms
void mach_numbersyms()

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

obj_filename
void obj_filename(const(char)* modname)

Output file name record.

obj_mangle2
char* obj_mangle2(Symbol* s, char* dest)

Mangle a name.

objfile_delete
void objfile_delete()

Close and delete .OBJ file.

objfile_term
void objfile_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.

seg_data_isCode
int seg_data_isCode(const ref seg_data sd)

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

Static variables

seg_tlsseg
int seg_tlsseg;

Section index for the __thread_vars/__tls_data section.

seg_tlsseg_bss
int seg_tlsseg_bss;

Section index for the __thread_bss section.

seg_tlsseg_data
int seg_tlsseg_data;

Section index for the __thread_data section.

Structs

Relocation
struct Relocation

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.

Meta