diff options
-rw-r--r-- | nuttx/binfmt/libnxflat/libnxflat_bind.c | 60 | ||||
-rw-r--r-- | nuttx/include/nxflat.h | 17 |
2 files changed, 70 insertions, 7 deletions
diff --git a/nuttx/binfmt/libnxflat/libnxflat_bind.c b/nuttx/binfmt/libnxflat/libnxflat_bind.c index 98b00996b..2afb92f12 100644 --- a/nuttx/binfmt/libnxflat/libnxflat_bind.c +++ b/nuttx/binfmt/libnxflat/libnxflat_bind.c @@ -145,6 +145,49 @@ static inline int nxflat_bindrel32d(FAR struct nxflat_loadinfo_s *loadinfo, } /**************************************************************************** + * Name: nxflat_bindrel32id + * + * Description: + * Perform the NXFLAT_RELOC_TYPE_REL32ID binding: + * + * Meaning: Object file contains a 32-bit offset into I-Space at the offset + * that will unfortunately be references relative to the GOT + * Fixup: Add allocated the mapped I-Space address MINUS the allocated + * D-Space address to the offset. + * + * Returned Value: + * 0 (OK) is returned on success and a negated errno is returned on + * failure. + * + ****************************************************************************/ + +#ifdef NXFLAT_RELOC_TYPE_REL32ID +static inline int nxflat_bindrel32id(FAR struct nxflat_loadinfo_s *loadinfo, + uint32 offset) +{ + uint32 *addr; + + bvdbg("NXFLAT_RELOC_TYPE_REL32D Offset: %08x D-Space: %p\n", + offset, loadinfo->dspace->region); + + if (offset < loadinfo->dsize) + { + addr = (uint32*)(offset + loadinfo->dspace->region); + bvdbg(" Before: %08x\n", *addr); + *addr += ((uint32)loadinfo->ispace - (uint32)(loadinfo->dspace->region)); + bvdbg(" After: %08x\n", *addr); + return OK; + } + else + { + bdbg("Offset: %08 does not lie in D-Space size: %08x\n", + offset, loadinfo->dsize); + return -EINVAL; + } +} +#endif + +/**************************************************************************** * Name: nxflat_gotrelocs * * Description: @@ -221,6 +264,23 @@ static inline int nxflat_gotrelocs(FAR struct nxflat_loadinfo_s *loadinfo) } break; + /* NXFLAT_RELOC_TYPE_REL32ID Meaning: Object file contains a 32-bit offset + * into I-Space at the offset that will + * unfortunately be references relative + * to the GOT + * Fixup: Add allocated the mapped I-Space + * address MINUS the allocated D-Space + * address to the offset. + */ + +#ifdef NXFLAT_RELOC_TYPE_REL32ID + case NXFLAT_RELOC_TYPE_REL32ID: + { + result = nxflat_bindrel32id(loadinfo, NXFLAT_RELOC_OFFSET(reloc.r_info)); + } + break; +#endif + default: { bdbg("ERROR: Unrecognized relocation type: %d\n", NXFLAT_RELOC_TYPE(reloc.r_info)); diff --git a/nuttx/include/nxflat.h b/nuttx/include/nxflat.h index aa90d6330..f65310244 100644 --- a/nuttx/include/nxflat.h +++ b/nuttx/include/nxflat.h @@ -161,21 +161,24 @@ struct nxflat_reloc_s /* 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. + * into I-Space at 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. + * into D-Space at the offset. * Fixup: Add 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. + * NXFLAT_RELOC_TYPE_REL32ID Meaning: Object file contains a 32-bit offset + * into I-Space at the offset that will + * unfortunately be references relative + * to the GOT + * Fixup: Add allocated the mapped I-Space + * address MINUS the allocated D-Space + * address to the offset. */ #define NXFLAT_RELOC_TYPE_REL32I 0 #define NXFLAT_RELOC_TYPE_REL32D 1 +#undef NXFLAT_RELOC_TYPE_REL32ID /* May not need */ #define NXFLAT_RELOC_TYPE_NUM 2 /* Number of relocation types */ /**************************************************************************** |