mirror of git://gcc.gnu.org/git/gcc.git
re PR bootstrap/42096 (lto.c:289:7: error: implicit declaration of function 'strtoll')
2009-11-19 Rafael Avila de Espindola <espindola@google.com> PR bootstrap/42096 * lto-plugin.c (claim_file_handler): Print offsets in hex. 2009-11-19 Rafael Avila de Espindola <espindola@google.com> PR bootstrap/42096 * lto-elf.c (lto_elf_file_open): Use lto_parse_hex. * lto.c (lto_parse_hex): New. (lto_resolution_read): Use lto_parse_hex. * lto.h (lto_parse_hex): New. From-SVN: r154330
This commit is contained in:
parent
986ad1338d
commit
92fa7608a4
|
@ -1,3 +1,11 @@
|
||||||
|
2009-11-19 Rafael Avila de Espindola <espindola@google.com>
|
||||||
|
|
||||||
|
PR bootstrap/42096
|
||||||
|
* lto-elf.c (lto_elf_file_open): Use lto_parse_hex.
|
||||||
|
* lto.c (lto_parse_hex): New.
|
||||||
|
(lto_resolution_read): Use lto_parse_hex.
|
||||||
|
* lto.h (lto_parse_hex): New.
|
||||||
|
|
||||||
2009-11-17 Rafael Avila de Espindola <espindola@google.com>
|
2009-11-17 Rafael Avila de Espindola <espindola@google.com>
|
||||||
|
|
||||||
* lto-elf.c (lto_file_init): Add offset argument.
|
* lto-elf.c (lto_file_init): Add offset argument.
|
||||||
|
|
|
@ -559,14 +559,8 @@ lto_elf_file_open (const char *filename, bool writable)
|
||||||
fname = (char *) xmalloc (offset_p - filename + 1);
|
fname = (char *) xmalloc (offset_p - filename + 1);
|
||||||
memcpy (fname, filename, offset_p - filename);
|
memcpy (fname, filename, offset_p - filename);
|
||||||
fname[offset_p - filename] = '\0';
|
fname[offset_p - filename] = '\0';
|
||||||
offset_p++;
|
offset_p += 3; /* skip the @0x */
|
||||||
errno = 0;
|
offset = lto_parse_hex (offset_p);
|
||||||
offset = strtoll (offset_p, NULL, 10);
|
|
||||||
if (errno != 0)
|
|
||||||
{
|
|
||||||
error ("could not parse offset %s", offset_p);
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
/* elf_rand expects the offset to point to the ar header, not the
|
/* elf_rand expects the offset to point to the ar header, not the
|
||||||
object itself. Subtract the size of the ar header (60 bytes).
|
object itself. Subtract the size of the ar header (60 bytes).
|
||||||
We don't uses sizeof (struct ar_hd) to avoid including ar.h */
|
We don't uses sizeof (struct ar_hd) to avoid including ar.h */
|
||||||
|
|
|
@ -249,6 +249,28 @@ lto_read_decls (struct lto_file_decl_data *decl_data, const void *data,
|
||||||
lto_data_in_delete (data_in);
|
lto_data_in_delete (data_in);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* strtoll is not portable. */
|
||||||
|
int64_t
|
||||||
|
lto_parse_hex (const char *p) {
|
||||||
|
uint64_t ret = 0;
|
||||||
|
for (; *p != '\0'; ++p)
|
||||||
|
{
|
||||||
|
char c = *p;
|
||||||
|
unsigned char part;
|
||||||
|
ret <<= 4;
|
||||||
|
if (c >= '0' && c <= '9')
|
||||||
|
part = c - '0';
|
||||||
|
else if (c >= 'a' && c <= 'f')
|
||||||
|
part = c - 'a' + 10;
|
||||||
|
else if (c >= 'A' && c <= 'F')
|
||||||
|
part = c - 'A' + 10;
|
||||||
|
else
|
||||||
|
internal_error ("could not parse hex number");
|
||||||
|
ret |= part;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/* Read resolution for file named FILE_NAME. The resolution is read from
|
/* Read resolution for file named FILE_NAME. The resolution is read from
|
||||||
RESOLUTION. An array with the symbol resolution is returned. The array
|
RESOLUTION. An array with the symbol resolution is returned. The array
|
||||||
size is written to SIZE. */
|
size is written to SIZE. */
|
||||||
|
@ -280,15 +302,12 @@ lto_resolution_read (FILE *resolution, lto_file *file)
|
||||||
if (file->offset != 0)
|
if (file->offset != 0)
|
||||||
{
|
{
|
||||||
int t;
|
int t;
|
||||||
char offset_p[21];
|
char offset_p[17];
|
||||||
long long offset;
|
int64_t offset;
|
||||||
t = fscanf (resolution, "@%20s", offset_p);
|
t = fscanf (resolution, "@0x%16s", offset_p);
|
||||||
if (t != 1)
|
if (t != 1)
|
||||||
internal_error ("could not parse file offset");
|
internal_error ("could not parse file offset");
|
||||||
errno = 0;
|
offset = lto_parse_hex (offset_p);
|
||||||
offset = strtoll(offset_p, NULL, 10);
|
|
||||||
if (errno != 0)
|
|
||||||
internal_error ("could not parse file offset");
|
|
||||||
if (offset != file->offset)
|
if (offset != file->offset)
|
||||||
internal_error ("unexpected offset");
|
internal_error ("unexpected offset");
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,5 +57,6 @@ struct lto_section_slot
|
||||||
size_t len;
|
size_t len;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
int64_t lto_parse_hex (const char *p);
|
||||||
|
|
||||||
#endif /* LTO_H */
|
#endif /* LTO_H */
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
2009-11-19 Rafael Avila de Espindola <espindola@google.com>
|
||||||
|
|
||||||
|
PR bootstrap/42096
|
||||||
|
* lto-plugin.c (claim_file_handler): Print offsets in hex.
|
||||||
|
|
||||||
2009-11-12 Rafael Avila de Espindola <espindola@google.com>
|
2009-11-12 Rafael Avila de Espindola <espindola@google.com>
|
||||||
|
|
||||||
* lto-plugin.c (write_resolution): Assume resolution_file is set.
|
* lto-plugin.c (write_resolution): Assume resolution_file is set.
|
||||||
|
|
|
@ -551,7 +551,7 @@ claim_file_handler (const struct ld_plugin_input_file *file, int *claimed)
|
||||||
Elf *archive;
|
Elf *archive;
|
||||||
off_t offset;
|
off_t offset;
|
||||||
/* We pass the offset of the actual file, not the archive header. */
|
/* We pass the offset of the actual file, not the archive header. */
|
||||||
int t = asprintf (&objname, "%s@%" PRId64, file->name,
|
int t = asprintf (&objname, "%s@0x%" PRIx64, file->name,
|
||||||
(int64_t) file->offset);
|
(int64_t) file->offset);
|
||||||
check (t >= 0, LDPL_FATAL, "asprintf failed");
|
check (t >= 0, LDPL_FATAL, "asprintf failed");
|
||||||
lto_file.name = objname;
|
lto_file.name = objname;
|
||||||
|
|
Loading…
Reference in New Issue