Changeset 132ab5d1 in mainline for uspace/lib/c/generic/elf/elf_mod.c
- Timestamp:
- 2018-01-30T03:20:45Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5a6cc679
- Parents:
- 8bfb163 (diff), 6a5d05b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - File:
-
- 1 edited
-
uspace/lib/c/generic/elf/elf_mod.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/elf/elf_mod.c
r8bfb163 r132ab5d1 69 69 "incompatible image", 70 70 "unsupported image type", 71 "irrecoverable error" 71 "irrecoverable error", 72 "file io error" 72 73 }; 73 74 … … 90 91 * extracted from the binary. 91 92 * 92 * @return E OK on success or negativeerror code.93 * @return EE_OK on success or EE_xx error code. 93 94 * 94 95 */ … … 97 98 elf_ld_t elf; 98 99 99 int ofile = vfs_clone(file, -1, true); 100 int rc = vfs_open(ofile, MODE_READ); 100 int ofile; 101 int rc = vfs_clone(file, -1, true, &ofile); 102 if (rc == EOK) { 103 rc = vfs_open(ofile, MODE_READ); 104 } 101 105 if (rc != EOK) { 102 return rc;106 return EE_IO; 103 107 } 104 108 … … 107 111 elf.flags = flags; 108 112 109 rc= elf_load_module(&elf, so_bias);113 int ret = elf_load_module(&elf, so_bias); 110 114 111 115 vfs_put(ofile); 112 return r c;116 return ret; 113 117 } 114 118 … … 116 120 elf_finfo_t *info) 117 121 { 118 int file = vfs_lookup(path, 0); 119 int rc = elf_load_file(file, so_bias, flags, info); 120 vfs_put(file); 121 return rc; 122 int file; 123 int rc = vfs_lookup(path, 0, &file); 124 if (rc == EOK) { 125 int ret = elf_load_file(file, so_bias, flags, info); 126 vfs_put(file); 127 return ret; 128 } else { 129 return EE_IO; 130 } 122 131 } 123 132 … … 137 146 elf_header_t *header = &header_buf; 138 147 aoff64_t pos = 0; 139 int i, rc; 140 141 rc = vfs_read(elf->fd, &pos, header, sizeof(elf_header_t)); 142 if (rc != sizeof(elf_header_t)) { 148 size_t nr; 149 int i, ret; 150 int rc; 151 152 rc = vfs_read(elf->fd, &pos, header, sizeof(elf_header_t), &nr); 153 if (rc != EOK || nr != sizeof(elf_header_t)) { 143 154 DPRINTF("Read error.\n"); 144 return EE_I NVALID;155 return EE_IO; 145 156 } 146 157 … … 199 210 pos = header->e_phoff + i * sizeof(elf_segment_header_t); 200 211 rc = vfs_read(elf->fd, &pos, &segment_hdr, 201 sizeof(elf_segment_header_t) );202 if (rc != sizeof(elf_segment_header_t)) {212 sizeof(elf_segment_header_t), &nr); 213 if (rc != EOK || nr != sizeof(elf_segment_header_t)) { 203 214 DPRINTF("Read error.\n"); 204 return EE_I NVALID;215 return EE_IO; 205 216 } 206 217 207 r c= segment_header(elf, &segment_hdr);208 if (r c!= EE_OK)209 return r c;218 ret = segment_header(elf, &segment_hdr); 219 if (ret != EE_OK) 220 return ret; 210 221 } 211 222 … … 218 229 pos = header->e_shoff + i * sizeof(elf_section_header_t); 219 230 rc = vfs_read(elf->fd, &pos, §ion_hdr, 220 sizeof(elf_section_header_t) );221 if (rc != sizeof(elf_section_header_t)) {231 sizeof(elf_section_header_t), &nr); 232 if (rc != EOK || nr != sizeof(elf_section_header_t)) { 222 233 DPRINTF("Read error.\n"); 223 return EE_I NVALID;234 return EE_IO; 224 235 } 225 236 226 r c= section_header(elf, §ion_hdr);227 if (r c!= EE_OK)228 return r c;237 ret = section_header(elf, §ion_hdr); 238 if (ret != EE_OK) 239 return ret; 229 240 } 230 241 … … 330 341 size_t mem_sz; 331 342 aoff64_t pos; 332 ssize_t rc; 343 int rc; 344 size_t nr; 333 345 334 346 bias = elf->bias; … … 388 400 */ 389 401 pos = entry->p_offset; 390 rc = vfs_read(elf->fd, &pos, seg_ptr, entry->p_filesz );391 if (rc < 0) {402 rc = vfs_read(elf->fd, &pos, seg_ptr, entry->p_filesz, &nr); 403 if (rc != EOK || nr != entry->p_filesz) { 392 404 DPRINTF("read error\n"); 393 return EE_I NVALID;405 return EE_IO; 394 406 } 395 407
Note:
See TracChangeset
for help on using the changeset viewer.
