diff options
Diffstat (limited to 'rtl-obj.c')
-rw-r--r-- | rtl-obj.c | 38 |
1 files changed, 23 insertions, 15 deletions
@@ -115,11 +115,14 @@ rtems_rtl_obj_unresolved (rtems_rtl_obj_t* obj) return (obj->flags & RTEMS_RTL_OBJ_UNRESOLVED) != 0 ? true : false; } -static bool -rtems_rtl_obj_parse_name (rtems_rtl_obj_t* obj, const char* name) +bool +rtems_rtl_parse_name (const char* name, + const char** aname, + const char** oname, + int* ooffset) { - const char* aname = NULL; - const char* oname = NULL; + const char* laname = NULL; + const char* loname = NULL; const char* colon; const char* end; @@ -133,14 +136,14 @@ rtems_rtl_obj_parse_name (rtems_rtl_obj_t* obj, const char* name) if (colon == NULL || colon < strrchr(name, '/')) colon = end; - oname = rtems_rtl_alloc_new (RTEMS_RTL_ALLOC_OBJECT, colon - name + 1, true); + loname = rtems_rtl_alloc_new (RTEMS_RTL_ALLOC_OBJECT, colon - name + 1, true); if (!oname) { rtems_rtl_set_error (ENOMEM, "no memory for object file name"); return false; } - memcpy ((void*) oname, name, colon - name); + memcpy ((void*) loname, name, colon - name); /* * If the pointers match there is no ':' delimiter. @@ -153,7 +156,7 @@ rtems_rtl_obj_parse_name (rtems_rtl_obj_t* obj, const char* name) * The file name is an archive and the object file name is next after the * delimiter. Move the pointer to the archive name. */ - aname = oname; + laname = loname; ++colon; /* @@ -166,15 +169,15 @@ rtems_rtl_obj_parse_name (rtems_rtl_obj_t* obj, const char* name) at = end; - oname = rtems_rtl_alloc_new (RTEMS_RTL_ALLOC_OBJECT, at - colon + 1, true); - if (!oname) + loname = rtems_rtl_alloc_new (RTEMS_RTL_ALLOC_OBJECT, at - colon + 1, true); + if (!loname) { - rtems_rtl_alloc_del (RTEMS_RTL_ALLOC_OBJECT, (void*) aname); + rtems_rtl_alloc_del (RTEMS_RTL_ALLOC_OBJECT, (void*) laname); rtems_rtl_set_error (ENOMEM, "no memory for object file name"); return false; } - memcpy ((void*) oname, colon, at - colon); + memcpy ((void*) loname, colon, at - colon); if (at != end) { @@ -183,17 +186,22 @@ rtems_rtl_obj_parse_name (rtems_rtl_obj_t* obj, const char* name) * does not parse 0 will be returned and the archive will be * searched. */ - obj->ooffset = strtoul (at + 1, 0, 0); + *ooffset = strtoul (at + 1, 0, 0); } } - obj->oname = oname; - obj->aname = aname; - + *oname = loname; + *aname = laname; return true; } static bool +rtems_rtl_obj_parse_name (rtems_rtl_obj_t* obj, const char* name) +{ + return rtems_rtl_parse_name (name, &(obj->aname), &(obj->oname), &(obj->ooffset)); +} + +static bool rtems_rtl_seek_read (int fd, off_t off, size_t len, uint8_t* buffer) { if (lseek (fd, off, SEEK_SET) < 0) |