Changes in uspace/lib/c/generic/rtld/module.c [09ab0a9a:a0e2f9c] in mainline
- File:
-
- 1 edited
-
uspace/lib/c/generic/rtld/module.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/rtld/module.c
r09ab0a9a ra0e2f9c 50 50 #include <rtld/rtld_arch.h> 51 51 #include <rtld/module.h> 52 #include <libarch/rtld/module.h> 52 53 53 54 #include "../private/libc.h" … … 64 65 65 66 module = calloc(1, sizeof(module_t)); 66 if (module == NULL) 67 if (module == NULL) { 68 DPRINTF("malloc failed\n"); 67 69 return ENOMEM; 70 } 68 71 69 72 module->id = rtld_get_next_id(rtld); … … 181 184 char name_buf[NAME_BUF_SIZE]; 182 185 module_t *m; 183 int rc;186 errno_t rc; 184 187 185 188 m = calloc(1, sizeof(module_t)); 186 189 if (m == NULL) { 187 printf("malloc failed\n");188 exit(1);190 DPRINTF("malloc failed\n"); 191 goto error; 189 192 } 190 193 … … 196 199 197 200 if (str_size(name) > NAME_BUF_SIZE - 2) { 198 printf("soname too long. increase NAME_BUF_SIZE\n");199 exit(1);201 DPRINTF("soname too long. increase NAME_BUF_SIZE\n"); 202 goto error; 200 203 } 201 204 … … 206 209 DPRINTF("filename:'%s'\n", name_buf); 207 210 208 rc = elf_load_file_name(name_buf, ELDF_RW, &info);209 if (rc != E E_OK) {210 printf("Failed to load '%s'\n", name_buf);211 exit(1);211 rc = elf_load_file_name(name_buf, RTLD_MODULE_LDF, &info); 212 if (rc != EOK) { 213 DPRINTF("Failed to load '%s'\n", name_buf); 214 goto error; 212 215 } 213 216 … … 217 220 218 221 if (info.dynamic == NULL) { 219 printf("Error: '%s' is not a dynamically-linked object.\n",222 DPRINTF("Error: '%s' is not a dynamically-linked object.\n", 220 223 name_buf); 221 exit(1);224 goto error; 222 225 } 223 226 … … 242 245 243 246 return m; 247 248 error: 249 if (m) 250 free(m); 251 252 return NULL; 244 253 } 245 254 246 255 /** Load all modules on which m (transitively) depends. 247 256 */ 248 voidmodule_load_deps(module_t *m, mlflags_t flags)257 errno_t module_load_deps(module_t *m, mlflags_t flags) 249 258 { 250 259 elf_dyn_t *dp; … … 273 282 /* There are no dependencies, so we are done. */ 274 283 m->deps = NULL; 275 return ;284 return EOK; 276 285 } 277 286 278 287 m->deps = malloc(n * sizeof(module_t *)); 279 288 if (!m->deps) { 280 printf("malloc failed\n");281 exit(1);289 DPRINTF("malloc failed\n"); 290 return ENOMEM; 282 291 } 283 292 … … 293 302 if (!dm) { 294 303 dm = module_load(m->rtld, dep_name, flags); 295 module_load_deps(dm, flags); 304 if (!dm) { 305 return EINVAL; 306 } 307 308 errno_t rc = module_load_deps(dm, flags); 309 if (rc != EOK) { 310 return rc; 311 } 296 312 } 297 313 … … 301 317 ++dp; 302 318 } 319 320 return EOK; 303 321 } 304 322
Note:
See TracChangeset
for help on using the changeset viewer.
