Changeset 00c2de63 in mainline for uspace/lib/c/generic/elf/elf_load.c
- Timestamp:
- 2011-07-29T14:50:22Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b6759f4
- Parents:
- 6c69d19 (diff), 7ae249d (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 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/elf/elf_load.c
r6c69d19 r00c2de63 29 29 */ 30 30 31 /** @addtogroup generic 31 /** @addtogroup generic 32 32 * @{ 33 33 */ … … 49 49 #include <assert.h> 50 50 #include <as.h> 51 #include <elf/elf.h> 51 52 #include <unistd.h> 52 53 #include <fcntl.h> … … 55 56 #include <entry_point.h> 56 57 57 #include "elf.h" 58 #include "elf_load.h" 58 #include <elf/elf_load.h> 59 59 60 60 #define DPRINTF(...) … … 74 74 static int load_segment(elf_ld_t *elf, elf_segment_header_t *entry); 75 75 76 /** Read until the buffer is read in its entirety. */77 static int my_read(int fd, void *buf, size_t len)78 {79 int cnt = 0;80 do {81 buf += cnt;82 len -= cnt;83 cnt = read(fd, buf, len);84 } while ((cnt > 0) && ((len - cnt) > 0));85 86 return cnt;87 }88 89 76 /** Load ELF binary from a file. 90 77 * … … 160 147 int i, rc; 161 148 162 rc = my_read(elf->fd, header, sizeof(elf_header_t));163 if (rc < 0) {149 rc = read_all(elf->fd, header, sizeof(elf_header_t)); 150 if (rc != sizeof(elf_header_t)) { 164 151 DPRINTF("Read error.\n"); 165 152 return EE_INVALID; … … 222 209 + i * sizeof(elf_segment_header_t), SEEK_SET); 223 210 224 rc = my_read(elf->fd, &segment_hdr,211 rc = read_all(elf->fd, &segment_hdr, 225 212 sizeof(elf_segment_header_t)); 226 if (rc < 0) {213 if (rc != sizeof(elf_segment_header_t)) { 227 214 DPRINTF("Read error.\n"); 228 215 return EE_INVALID; … … 244 231 + i * sizeof(elf_section_header_t), SEEK_SET); 245 232 246 rc = my_read(elf->fd, §ion_hdr,233 rc = read_all(elf->fd, §ion_hdr, 247 234 sizeof(elf_section_header_t)); 248 if (rc < 0) {235 if (rc != sizeof(elf_section_header_t)) { 249 236 DPRINTF("Read error.\n"); 250 237 return EE_INVALID; … … 334 321 uintptr_t seg_addr; 335 322 size_t mem_sz; 336 int rc;323 ssize_t rc; 337 324 338 325 bias = elf->bias; … … 412 399 if (now > left) now = left; 413 400 414 rc = my_read(elf->fd, dp, now);415 416 if (rc < 0) {401 rc = read_all(elf->fd, dp, now); 402 403 if (rc != (ssize_t) now) { 417 404 DPRINTF("Read error.\n"); 418 405 return EE_INVALID;
Note:
See TracChangeset
for help on using the changeset viewer.