Main Page | Class List | Directories | File List | Class Members | File Members

ld_object.c File Reference

CKPM linker object manipulation. More...

#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include "cpp_io.h"
#include "cpp_conv.h"
#include "ld_object.h"
#include "cklf.h"

Functions

_ld_symLdSym_Create (char *name, int val, int size, int typ, int bnd, struct _ld_sym *nxt)
 create a linker symbol list entry
void LdSym_Destroy (struct _ld_sym *lds)
 destroy a linker symbol list entry
void LdSym_Dump (struct _ld_sym *lds, int fd)
 dump the entire linker symbol list
_ld_symLdSym_Find (struct _ld_sym *lds, char *n)
 find a linker symbol in the list
int LdSym_Length (struct _ld_sym *lds)
 determine the length of the symbol list
int LdSym_StrLength (struct _ld_sym *lds)
 determine the length of the symbol list strings
_ld_link_mgmtLdMgmt_Create ()
 create a struct _ld_link_mgmt on the heap
void LdMgmt_Destroy (struct _ld_link_mgmt *m)
 destroy a struct _ld_link_mgmt on the heap
int Ld_Align (int a, int b)
 alignment calculation
int Ld_Read_Long (char *c, int at)
 read four bytes from the code at a given address
void Ld_Write_Long (char *c, int at, int with)
 write four bytes to the code
void Ld_Fix_Link_Long (char *c, int dst, int l, int o)
 do the branch destination fixup
int CKLF_Store (int fd_err, char *fname, char *data, int datsz, char *code, int codsz, struct _ld_sym *lds)
 create a CKLF file from compiled code, data and symbol table
int CKLF_Load (int fd_err, char *fname, char *mem, int memsz, int *start)
 load a CKLF file
_ld_link_objCKLF_Load_File_Info (int fd_err, int nr, char **ifiles)
 load the headers from cklf files and create a struct _ld_link_obj list
int CKLF_Load_Files (int fd_err, struct _ld_link_mgmt *m)
 load code and data segments for linking
int CKLF_Merge_Chains (char *s, int old_chain, int new_chain, int offs)
 join a link chain with an existing link chain and correct the offsets
void CKLF_Create_SymTab (int fd_err, struct _ld_link_mgmt *m)
 join the symbol tables of all loaded files
int CKLF_Link (int fd_err, int verbose, char *ofile, int nr, char **ifiles)
 link a set of CKLF files


Detailed Description

CKPM linker object manipulation.


Function Documentation

void CKLF_Create_SymTab int  fd_err,
struct _ld_link_mgmt m
 

join the symbol tables of all loaded files

Parameters:
fd_err a file discriptor index to an open file for error output
m a pointer to the linking management sytucture
Returns:
the list of symbols on success, otherwise 0

int CKLF_Link int  fd_err,
int  verbose,
char *  ofile,
int  nr,
char **  ifiles
 

link a set of CKLF files

Parameters:
fd_err a file discriptor index to an open file for error output
verbose if != 0 this function will provide verbose output
ofile the file name of the linked file
nr the number of files to be linked
ifiles the names of the files to be linked
Returns:
!= 0 on success, otherwise 0

int CKLF_Load int  fd_err,
char *  fname,
char *  mem,
int  memsz,
int *  start
 

load a CKLF file

Parameters:
fd_err a file discriptor index to an open file for error output
fname the file to be loaded
mem the memory of the virtual machine
memsz the size of the virtual machine memory
start the start of the program, i.e. function main() (output)
Returns:
allocated memory on success, otherwise 0

struct _ld_link_obj* CKLF_Load_File_Info int  fd_err,
int  nr,
char **  ifiles
 

load the headers from cklf files and create a struct _ld_link_obj list

Parameters:
fd_err a file discriptor index to an open file for error output
nr the number of files to be linked
ifiles the names of the files to be linked
Returns:
the linked list on success, otherwise 0

int CKLF_Load_Files int  fd_err,
struct _ld_link_mgmt m
 

load code and data segments for linking

Parameters:
fd_err a file discriptor index to an open file for error output
m a pointer to the linking management sytucture
Returns:
!= 0 on success, otherwise 0

int CKLF_Merge_Chains char *  s,
int  old_chain,
int  new_chain,
int  offs
 

join a link chain with an existing link chain and correct the offsets

Parameters:
s the start address of the segment
old_chain the address of the old chain (points to already fixed links)
new_chain the address of the new chain (not corrected)
offs the offset of the corresponding new segment
Returns:
corrected new chain address

int CKLF_Store int  fd_err,
char *  fname,
char *  data,
int  datsz,
char *  code,
int  codsz,
struct _ld_sym lds
 

create a CKLF file from compiled code, data and symbol table

Parameters:
fd_err a file discriptor index to an open file for error output
fname the name of the file for saving
data the area of initialised data
datsz the size of this data area
code the compiled code
codsz the size of this code area
lds a pointer to the linker symbol table
Returns:
<0 on failure during I/O, otherwise all ran ok.

int Ld_Align int  a,
int  b
 

alignment calculation

Parameters:
a the address
b the alignment size

void Ld_Fix_Link_Long char *  c,
int  dst,
int  l,
int  o
 

do the branch destination fixup

Parameters:
c a pointer to the code
dst the new destination
l the address in the code of the parameter of a branch statement
o offset in the code

int Ld_Read_Long char *  c,
int  at
 

read four bytes from the code at a given address

Parameters:
c a pointer to the code
at the address in the code
Returns:
the four bytes as an integer value

void Ld_Write_Long char *  c,
int  at,
int  with
 

write four bytes to the code

Parameters:
c a pointer to the code
at the address in the code
with the new value

struct _ld_link_mgmt* LdMgmt_Create  ) 
 

create a struct _ld_link_mgmt on the heap

Returns:
a pointer to the created structure

void LdMgmt_Destroy struct _ld_link_mgmt m  ) 
 

destroy a struct _ld_link_mgmt on the heap

Parameters:
m a pointer to the _ld_link_mgmt structure

struct _ld_sym* LdSym_Create char *  name,
int  val,
int  size,
int  typ,
int  bnd,
struct _ld_sym nxt
 

create a linker symbol list entry

Parameters:
name the symbol name
val the symbol value
size the symbol size
typ the symbol type
bnd the symbol binding information
nxt a pointer to the next node
Returns:
a pointer to the newly created symbol list entry

void LdSym_Destroy struct _ld_sym lds  ) 
 

destroy a linker symbol list entry

Parameters:
lds a pointer to the linker symbol table

void LdSym_Dump struct _ld_sym lds,
int  fd
 

dump the entire linker symbol list

Parameters:
lds a pointer to the linker symbol table
fd a filedescriptor index of an open file

struct _ld_sym* LdSym_Find struct _ld_sym lds,
char *  n
 

find a linker symbol in the list

Parameters:
lds the linker symbol list
n the symbol name
Returns:
a pointer to the entry or 0 if none was found

int LdSym_Length struct _ld_sym lds  ) 
 

determine the length of the symbol list

Parameters:
lds the linker symbol list
Returns:
the length of this list

int LdSym_StrLength struct _ld_sym lds  ) 
 

determine the length of the symbol list strings

Parameters:
lds the linker symbol list
Returns:
the length of this list


Generated on Thu Jul 13 03:56:36 2006 for CKPMcc by  doxygen 1.4.4