diff options
author | Richard Guenther <rguenther@suse.de> | 2009-11-04 17:24:37 +0000 |
---|---|---|
committer | Rafael Espindola <espindola@gcc.gnu.org> | 2009-11-04 17:24:37 +0000 |
commit | 7e9dc421e5619c53ef12192450ef03fd4d7f5d63 (patch) | |
tree | bbdb30714a65a45ea093d3c41499626e8893a5bb /gcc | |
parent | 43a8b705906034ecb3edfb54558a34bd362a7213 (diff) | |
download | gcc-7e9dc421e5619c53ef12192450ef03fd4d7f5d63.zip gcc-7e9dc421e5619c53ef12192450ef03fd4d7f5d63.tar.gz gcc-7e9dc421e5619c53ef12192450ef03fd4d7f5d63.tar.bz2 |
gcc.c (process_command): Handle arguments name@offset.
2009-11-04 Richard Guenther <rguenther@suse.de>
Rafael Avila de Espindola <espindola@google.com>
* gcc.c (process_command): Handle arguments name@offset.
2009-11-04 Richard Guenther <rguenther@suse.de>
Rafael Avila de Espindola <espindola@google.com>
* lto-elf.c (lto_elf_build_section_table): Add the base offset.
(lto_elf_file_open): Handle offsets in arguments name@offest.
2009-11-04 Richard Guenther <rguenther@suse.de>
Rafael Avila de Espindola <espindola@google.com>
* lto-plugin.c (plugin_file_info): Remove temp field.
(cleanup_handler): Don't delete temporary objects.
(claim_file_handler): Don't create temporary objects.
Co-Authored-By: Rafael Avila de Espindola <espindola@google.com>
From-SVN: r153903
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/gcc.c | 32 | ||||
-rw-r--r-- | gcc/lto/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/lto/lto-elf.c | 55 |
4 files changed, 83 insertions, 15 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c3b8d86..619e450 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2009-11-04 Richard Guenther <rguenther@suse.de> + Rafael Avila de Espindola <espindola@google.com> + + * gcc.c (process_command): Handle arguments name@offset. + 2009-11-04 Harsha Jagasia <harsha.jagasia@amd.com> Dwarakanath Rajagopal <dwarak.rajagopal@amd.com> @@ -4568,20 +4568,32 @@ process_command (int argc, const char **argv) } else { + const char *p = strchr (argv[i], '@'); + char *fname; #ifdef HAVE_TARGET_OBJECT_SUFFIX argv[i] = convert_filename (argv[i], 0, access (argv[i], F_OK)); #endif + if (!p) + fname = xstrdup (argv[i]); + else + { + fname = (char *)xmalloc (p - argv[i] + 1); + memcpy (fname, argv[i], p - argv[i]); + fname[p - argv[i]] = '\0'; + } + + if (strcmp (fname, "-") != 0 && access (fname, F_OK) < 0) + { + perror_with_name (fname); + error_count++; + } + else + { + infiles[n_infiles].language = spec_lang; + infiles[n_infiles++].name = argv[i]; + } - if (strcmp (argv[i], "-") != 0 && access (argv[i], F_OK) < 0) - { - perror_with_name (argv[i]); - error_count++; - } - else - { - infiles[n_infiles].language = spec_lang; - infiles[n_infiles++].name = argv[i]; - } + free (fname); } } diff --git a/gcc/lto/ChangeLog b/gcc/lto/ChangeLog index 0d464ec..3334de7 100644 --- a/gcc/lto/ChangeLog +++ b/gcc/lto/ChangeLog @@ -1,3 +1,9 @@ +2009-11-04 Richard Guenther <rguenther@suse.de> + Rafael Avila de Espindola <espindola@google.com> + + * lto-elf.c (lto_elf_build_section_table): Add the base offset. + (lto_elf_file_open): Handle offsets in arguments name@offest. + 2009-10-30 Richard Guenther <rguenther@suse.de> PR lto/41858 diff --git a/gcc/lto/lto-elf.c b/gcc/lto/lto-elf.c index 190430b..ee587f7 100644 --- a/gcc/lto/lto-elf.c +++ b/gcc/lto/lto-elf.c @@ -167,9 +167,11 @@ lto_elf_build_section_table (lto_file *lto_file) lto_elf_file *elf_file = (lto_elf_file *)lto_file; htab_t section_hash_table; Elf_Scn *section; + size_t base_offset; section_hash_table = htab_create (37, hash_name, eq_name, free); + base_offset = elf_getbase (elf_file->elf); for (section = elf_getscn (elf_file->elf, 0); section; section = elf_nextscn (elf_file->elf, section)) @@ -206,7 +208,7 @@ lto_elf_build_section_table (lto_file *lto_file) new_slot->name = new_name; /* The offset into the file for this section. */ - new_slot->start = shdr->sh_offset; + new_slot->start = base_offset + shdr->sh_offset; new_slot->len = shdr->sh_size; *slot = new_slot; } @@ -530,7 +532,6 @@ init_ehdr (lto_elf_file *elf_file) } } - /* Open ELF file FILENAME. If WRITABLE is true, the file is opened for write and, if necessary, created. Otherwise, the file is opened for reading. Returns the opened file. */ @@ -540,18 +541,42 @@ lto_elf_file_open (const char *filename, bool writable) { lto_elf_file *elf_file; lto_file *result; + off_t offset; + const char *offset_p; + char *fname; + + offset_p = strchr (filename, '@'); + if (!offset_p) + { + fname = xstrdup (filename); + offset = 0; + } + else + { + int64_t t; + fname = (char *) xmalloc (offset_p - filename + 1); + memcpy (fname, filename, offset_p - filename); + fname[offset_p - filename] = '\0'; + offset_p++; + sscanf(offset_p, "%" PRId64 , &t); + offset = t; + /* 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; + } /* Set up. */ elf_file = XCNEW (lto_elf_file); result = (lto_file *) elf_file; - lto_file_init (result, filename); + lto_file_init (result, fname); elf_file->fd = -1; /* Open the file. */ - elf_file->fd = open (filename, writable ? O_WRONLY|O_CREAT : O_RDONLY, 0666); + elf_file->fd = open (fname, writable ? O_WRONLY|O_CREAT : O_RDONLY, 0666); if (elf_file->fd == -1) { - error ("could not open file %s", filename); + error ("could not open file %s", fname); goto fail; } @@ -571,6 +596,26 @@ lto_elf_file_open (const char *filename, bool writable) goto fail; } + if (offset != 0) + { + Elf *e; + off_t t = elf_rand (elf_file->elf, offset); + if (t != offset) + { + error ("could not seek in archive"); + goto fail; + } + + e = elf_begin (elf_file->fd, ELF_C_READ, elf_file->elf); + if (e == NULL) + { + error("could not find archive member"); + goto fail; + } + elf_end (elf_file->elf); + elf_file->elf = e; + } + if (writable) { init_ehdr (elf_file); |