From 9870fe4f883ad20482ade6a4044657d738daa337 Mon Sep 17 00:00:00 2001 From: Rafael Avila de Espindola Date: Tue, 17 Nov 2009 16:00:19 +0000 Subject: lto-elf.c (lto_file_init): Add offset argument. 2009-11-17 Rafael Avila de Espindola * lto-elf.c (lto_file_init): Add offset argument. (lto_elf_file_open): Record the offset. * lto.c (lto_resolution_read): Change file_name into a lto_file argument. Check offsets. (lto_file_read): Update call to lto_resolution_read. * lto.h (lto_file_struct): Add the offset field. From-SVN: r154251 --- gcc/lto/lto-elf.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'gcc/lto/lto-elf.c') diff --git a/gcc/lto/lto-elf.c b/gcc/lto/lto-elf.c index bc8e137..368d8d4d 100644 --- a/gcc/lto/lto-elf.c +++ b/gcc/lto/lto-elf.c @@ -32,9 +32,10 @@ along with GCC; see the file COPYING3. If not see /* Initialize FILE, an LTO file object for FILENAME. */ static void -lto_file_init (lto_file *file, const char *filename) +lto_file_init (lto_file *file, const char *filename, off_t offset) { file->filename = filename; + file->offset = offset; } /* An ELF file. */ @@ -542,6 +543,7 @@ lto_elf_file_open (const char *filename, bool writable) lto_elf_file *elf_file; lto_file *result = NULL; off_t offset; + off_t header_offset; const char *offset_p; char *fname; @@ -550,6 +552,7 @@ lto_elf_file_open (const char *filename, bool writable) { fname = xstrdup (filename); offset = 0; + header_offset = 0; } else { @@ -567,13 +570,13 @@ lto_elf_file_open (const char *filename, bool writable) /* elf_rand expects the offset to point to the ar header, not the object itself. Subtract the size of the ar header (60 bytes). We don't uses sizeof (struct ar_hd) to avoid including ar.h */ - offset -= 60; + header_offset = offset - 60; } /* Set up. */ elf_file = XCNEW (lto_elf_file); result = (lto_file *) elf_file; - lto_file_init (result, fname); + lto_file_init (result, fname, offset); elf_file->fd = -1; /* Open the file. */ @@ -603,8 +606,8 @@ lto_elf_file_open (const char *filename, bool writable) if (offset != 0) { Elf *e; - off_t t = elf_rand (elf_file->elf, offset); - if (t != offset) + off_t t = elf_rand (elf_file->elf, header_offset); + if (t != header_offset) { error ("could not seek in archive"); goto fail; -- cgit v1.1