Message ID | 20100727145128.GA32142@basil.fritz.box |
---|---|
State | New |
Headers | show |
On Tue, Jul 27, 2010 at 4:51 PM, Andi Kleen <andi@firstfloor.org> wrote: > LTO: Handle merged option sections > > This closes one small hole in the merged section "ld -r" handling. > The options section does not have a suffix and can be merged. > Fix the option reader to loop over all copies of the options. > > Passed a bootstrap and full test suite run on x86_64-linux > > Ok to commit? Ok. Thanks, RIchard. > 2010-07-27 Andi Kleen <ak@linux.intel.com> > > * lto-opts.c (lto_file_read_options): Add loop over all inputs. > > Index: gcc/lto-opts.c > =================================================================== > --- gcc/lto-opts.c (revision 162566) > +++ gcc/lto-opts.c (working copy) > @@ -349,8 +349,8 @@ > void > lto_read_file_options (struct lto_file_decl_data *file_data) > { > - size_t len; > - const char *data; > + size_t len, l, skip; > + const char *data, *p; > const struct lto_simple_header *header; > int32_t opts_offset; > struct lto_input_block ib; > @@ -358,14 +358,30 @@ > data = lto_get_section_data (file_data, LTO_section_opts, NULL, &len); > if (!data) > return; > - header = (const struct lto_simple_header *) data; > - opts_offset = sizeof (*header); > > - lto_check_version (header->lto_header.major_version, > - header->lto_header.minor_version); > + /* Option could be multiple sections merged (through ld -r) > + Keep reading all options. This is ok right now because > + the options just get mashed together anyways. > + This will have to be done differently once lto-opts knows > + how to associate options with different files. */ > + l = len; > + p = data; > + do > + { > + header = (const struct lto_simple_header *) p; > + opts_offset = sizeof (*header); > > - LTO_INIT_INPUT_BLOCK (ib, data + opts_offset, 0, header->main_size); > - input_options (&ib); > + lto_check_version (header->lto_header.major_version, > + header->lto_header.minor_version); > + > + LTO_INIT_INPUT_BLOCK (ib, p + opts_offset, 0, header->main_size); > + input_options (&ib); > + > + skip = header->main_size + opts_offset; > + l -= skip; > + p += skip; > + } > + while (l > 0); > > lto_free_section_data (file_data, LTO_section_opts, 0, data, len); > } >
Index: gcc/lto-opts.c =================================================================== --- gcc/lto-opts.c (revision 162566) +++ gcc/lto-opts.c (working copy) @@ -349,8 +349,8 @@ void lto_read_file_options (struct lto_file_decl_data *file_data) { - size_t len; - const char *data; + size_t len, l, skip; + const char *data, *p; const struct lto_simple_header *header; int32_t opts_offset; struct lto_input_block ib; @@ -358,14 +358,30 @@ data = lto_get_section_data (file_data, LTO_section_opts, NULL, &len); if (!data) return; - header = (const struct lto_simple_header *) data; - opts_offset = sizeof (*header); - lto_check_version (header->lto_header.major_version, - header->lto_header.minor_version); + /* Option could be multiple sections merged (through ld -r) + Keep reading all options. This is ok right now because + the options just get mashed together anyways. + This will have to be done differently once lto-opts knows + how to associate options with different files. */ + l = len; + p = data; + do + { + header = (const struct lto_simple_header *) p; + opts_offset = sizeof (*header); - LTO_INIT_INPUT_BLOCK (ib, data + opts_offset, 0, header->main_size); - input_options (&ib); + lto_check_version (header->lto_header.major_version, + header->lto_header.minor_version); + + LTO_INIT_INPUT_BLOCK (ib, p + opts_offset, 0, header->main_size); + input_options (&ib); + + skip = header->main_size + opts_offset; + l -= skip; + p += skip; + } + while (l > 0); lto_free_section_data (file_data, LTO_section_opts, 0, data, len); }