Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP2:GA
cross-armv6hl-gcc48-icecream-backend.10984
gcc48-lto-plugin-short-readwrite.diff
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File gcc48-lto-plugin-short-readwrite.diff of Package cross-armv6hl-gcc48-icecream-backend.10984
2014-03-28 Richard Biener <rguenther@suse.de> * simple-object.c (simple_object_internal_read): Handle EINTR and short reads. * lto-plugin.c (process_symtab): Handle EINTR and short reads. 2014-04-01 Richard Biener <rguenther@suse.de> * simple-object.c (simple_object_internal_write): Handle EINTR and short writes. Index: libiberty/simple-object.c =================================================================== --- libiberty/simple-object.c (revision 208897) +++ libiberty/simple-object.c (revision 208898) @@ -63,8 +63,6 @@ simple_object_internal_read (int descrip unsigned char *buffer, size_t size, const char **errmsg, int *err) { - ssize_t got; - if (lseek (descriptor, offset, SEEK_SET) < 0) { *errmsg = "lseek"; @@ -72,15 +70,26 @@ simple_object_internal_read (int descrip return 0; } - got = read (descriptor, buffer, size); - if (got < 0) + do { - *errmsg = "read"; - *err = errno; - return 0; + ssize_t got = read (descriptor, buffer, size); + if (got == 0) + break; + else if (got > 0) + { + buffer += got; + size -= got; + } + else if (errno != EINTR) + { + *errmsg = "read"; + *err = errno; + return 0; + } } + while (size > 0); - if ((size_t) got < size) + if (size > 0) { *errmsg = "file too short"; *err = 0; Index: lto-plugin/lto-plugin.c =================================================================== --- lto-plugin/lto-plugin.c (revision 208897) +++ lto-plugin/lto-plugin.c (revision 208898) @@ -39,6 +39,7 @@ along with this program; see the file CO #include <stdint.h> #endif #include <assert.h> +#include <errno.h> #include <string.h> #include <stdlib.h> #include <stdio.h> @@ -817,7 +818,7 @@ process_symtab (void *data, const char * { struct plugin_objfile *obj = (struct plugin_objfile *)data; char *s; - char *secdata; + char *secdatastart, *secdata; if (strncmp (name, LTO_SECTION_PREFIX, LTO_SECTION_PREFIX_LEN) != 0) return 1; @@ -825,23 +826,40 @@ process_symtab (void *data, const char * s = strrchr (name, '.'); if (s) sscanf (s, ".%" PRI_LL "x", &obj->out->id); - secdata = xmalloc (length); + secdata = secdatastart = xmalloc (length); offset += obj->file->offset; - if (offset != lseek (obj->file->fd, offset, SEEK_SET) - || length != read (obj->file->fd, secdata, length)) + if (offset != lseek (obj->file->fd, offset, SEEK_SET)) + goto err; + + do { - if (message) - message (LDPL_FATAL, "%s: corrupt object file", obj->file->name); - /* Force claim_file_handler to abandon this file. */ - obj->found = 0; - free (secdata); - return 0; + ssize_t got = read (obj->file->fd, secdata, length); + if (got == 0) + break; + else if (got > 0) + { + secdata += got; + length -= got; + } + else if (errno != EINTR) + goto err; } + while (length > 0); + if (length > 0) + goto err; - translate (secdata, secdata + length, obj->out); + translate (secdatastart, secdata, obj->out); obj->found++; - free (secdata); + free (secdatastart); return 1; + +err: + if (message) + message (LDPL_FATAL, "%s: corrupt object file", obj->file->name); + /* Force claim_file_handler to abandon this file. */ + obj->found = 0; + free (secdatastart); + return 0; } /* Callback used by gold to check if the plugin will claim FILE. Writes Index: libiberty/simple-object.c =================================================================== --- libiberty/simple-object.c (revision 208971) +++ libiberty/simple-object.c (revision 208972) @@ -107,8 +107,6 @@ simple_object_internal_write (int descri const unsigned char *buffer, size_t size, const char **errmsg, int *err) { - ssize_t wrote; - if (lseek (descriptor, offset, SEEK_SET) < 0) { *errmsg = "lseek"; @@ -116,15 +114,26 @@ simple_object_internal_write (int descri return 0; } - wrote = write (descriptor, buffer, size); - if (wrote < 0) + do { - *errmsg = "write"; - *err = errno; - return 0; + ssize_t wrote = write (descriptor, buffer, size); + if (wrote == 0) + break; + else if (wrote > 0) + { + buffer += wrote; + size -= wrote; + } + else if (errno != EINTR) + { + *errmsg = "write"; + *err = errno; + return 0; + } } + while (size > 0); - if ((size_t) wrote < size) + if (size > 0) { *errmsg = "short write"; *err = 0;
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor