New relocation types

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1925 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo
2009-06-22 22:12:19 +00:00
parent 7117b39923
commit bd11dc8305
10 changed files with 398 additions and 158 deletions
+13 -8
View File
@@ -107,7 +107,7 @@ extern "C" {
****************************************************************************/
/***********************************************************************
* Name:
* Name: nxflat_verifyheader
*
* Description:
* Given the header from a possible NXFLAT executable, verify that it
@@ -122,7 +122,7 @@ extern "C" {
EXTERN int nxflat_verifyheader(const struct nxflat_hdr_s *header);
/***********************************************************************
* Name:
* Name: nxflat_init
*
* Description:
* This function is called to configure the library to process an NXFLAT
@@ -138,7 +138,7 @@ EXTERN int nxflat_init(const char *filename, struct nxflat_hdr_s *header,
struct nxflat_loadinfo_s *loadinfo);
/***********************************************************************
* Name:
* Name: nxflat_uninit
*
* Description:
* Releases any resources committed by nxflat_init(). This essentially
@@ -153,11 +153,14 @@ EXTERN int nxflat_init(const char *filename, struct nxflat_hdr_s *header,
EXTERN int nxflat_uninit(struct nxflat_loadinfo_s *loadinfo);
/***********************************************************************
* Name:
* Name: nxflat_load
*
* Description:
* Loads the binary specified by nxflat_init into memory,
* Completes all relocations, and clears BSS.
* Loads the binary specified by nxflat_init into memory, mapping
* the I-space executable regions, allocating the D-Space region,
* and inializing the data segment (relocation information is
* temporarily loaded into the BSS region. BSS will be cleared
* by nxflat_bind() after the relocation data has been processed).
*
* Returned Value:
* 0 (OK) is returned on success and a negated errno is returned on
@@ -168,7 +171,7 @@ EXTERN int nxflat_uninit(struct nxflat_loadinfo_s *loadinfo);
EXTERN int nxflat_load(struct nxflat_loadinfo_s *loadinfo);
/***********************************************************************
* Name:
* Name: nxflat_read
*
* Description:
* Read 'readsize' bytes from the object file at 'offset'
@@ -188,6 +191,8 @@ EXTERN int nxflat_read(struct nxflat_loadinfo_s *loadinfo, char *buffer,
* Description:
* Bind the imported symbol names in the loaded module described by
* 'loadinfo' using the exported symbol values provided by 'symtab'
* After binding the module, clear the BSS region (which held the relocation
* data) in preparation for execution.
*
* Returned Value:
* 0 (OK) is returned on success and a negated errno is returned on
@@ -200,7 +205,7 @@ EXTERN int nxflat_bind(FAR struct nxflat_loadinfo_s *loadinfo,
FAR const struct symtab_s *exports, int nexports);
/***********************************************************************
* Name:
* Name: nxflat_unload
*
* Description:
* This function unloads the object from memory. This essentially
+31 -11
View File
@@ -104,7 +104,8 @@ struct nxflat_hdr_s
uint32 h_stacksize;
/* Relocation entries
/* Relocation entries:
*
* h_relocstart - Offset to the beginning of an array of relocation
* records (struct nxflat_reloc). The offset is
* relative to the start of the file
@@ -114,7 +115,7 @@ struct nxflat_hdr_s
uint32 h_relocstart; /* Offset of relocation records */
uint32 h_reloccount; /* Number of relocation records */
/* Imported symbol table (NOTE no symbols are exported)
/* Imported symbol table (NOTE no symbols are exported):
*
* h_importsymbols - Offset to the beginning of an array of imported
* symbol structures (struct nxflat_import). The
@@ -143,27 +144,46 @@ struct nxflat_reloc_s
/* Pack the type and the offset into one 32-bit value */
#define NXFLAT_RELOC(t,o) (((u_int32_t)((t) & 3) << 28) | ((o) & 0x1fffffff))
#define NXFLAT_RELOC(t,o) (((u_int32_t)((t) & 3) << 30) | ((o) & 0x1fffffff))
/* The top three bits of the relocation info is the relocation type (see the
* NXFLAT_RELOC_TYPE_* definitions below. This is an unsigned value.
*/
#define NXFLAT_RELOC_TYPE(r) ((uint32)(r) >> 28)
#define NXFLAT_RELOC_TYPE(r) ((uint32)(r) >> 30)
/* The bottom 28 bits of the relocation info is the (non-negative) offset into
* the D-Space that needs the fixup.
*/
#define NXFLAT_RELOC_OFFSET(r) ((uint32)(r) & 0x1fffffff)
#define NXFLAT_RELOC_OFFSET(r) ((uint32)(r) & 0x3fffffff)
/* These are possible values for the relocation type */
/* These are possible values for the relocation type:
*
* NXFLAT_RELOC_TYPE_REL32I Meaning: Object file contains a 32-bit offset
* into I-Space at the the offset.
* Fixup: Add mapped I-Space address to the offset.
* NXFLAT_RELOC_TYPE_REL32D Meaning: Object file contains a 32-bit offset
* into D-Space at the the offset.
* Fixup: Add allocated D-Space address to the
* offset.
* NXFLAT_RELOC_TYPE_REL32ID Meaning: Object file contains a 32-bit offset
* into I-Space at the the offset, but will
* be referenced as data
* Fixup: Add mapped I-Space address - allocated
* D-Space address to the offset.
* NXFLAT_RELOC_TYPE_ABS32 Meaning: Offset refers to a struct nxflat_import_s
* describing a function pointer to be
* imported.
* Fixup: Provide the absolute function address
* in the struct nxflat_import_s instance.
*/
#define NXFLAT_RELOC_TYPE_NONE 0 /* Invalid relocation type */
#define NXFLAT_RELOC_TYPE_TEXT 1 /* Symbol lies in .text region */
#define NXFLAT_RELOC_TYPE_DATA 2 /* Symbol lies in .data region */
#define NXFLAT_RELOC_TYPE_BSS 3 /* Symbol lies in .bss region */
#define NXFLAT_RELOC_TYPE_NUM 4
#define NXFLAT_RELOC_TYPE_REL32I 0
#define NXFLAT_RELOC_TYPE_REL32D 1
#define NXFLAT_RELOC_TYPE_REL32ID 2
#define NXFLAT_RELOC_TYPE_ABS32 3
#define NXFLAT_RELOC_TYPE_NUM 4 /* Number of relocation types */
/****************************************************************************
* NXFLAT Imported symbol type