This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Commit: Add support for merging PE/COFF .rsrc sections
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Nick Clifton <nickc at redhat dot com>
- Cc: Binutils <binutils at sourceware dot org>
- Date: Tue, 17 Dec 2013 10:11:48 -0800
- Subject: Re: Commit: Add support for merging PE/COFF .rsrc sections
- Authentication-results: sourceware.org; auth=none
- References: <87wqj3sd0l dot fsf at redhat dot com> <CAMe9rOrNOSy4RVkNGkV1NV7W9W6=Ek_dMd8KqCqiQCw9Va3nwQ at mail dot gmail dot com>
On Tue, Dec 17, 2013 at 10:05 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Tue, Dec 17, 2013 at 7:39 AM, Nick Clifton <nickc@redhat.com> wrote:
>> Hi Guys,
>>
>> I am applying the patch below to add support for merging the contents
>> of .rsrc sections to PE/COFF targets. Unfortunately the specification
>> for the contents of a .rsrc section means that multiple sections
>> cannot just be concatenated when linking - they have to be manipulated
>> and merged together properly.
>>
>> Tested with x86_64-pc-cygwin and i686-pc-cygwin toolchains.
>>
>> Cheers
>> Nick
>>
>> bfd/ChangeLog
>> 2013-12-17 Nick Clifton <nickc@redhat.com>
>>
>> * peXXigen.c: Include wchar.h if available.
>> Include safe-ctype.h.
>> (HighBitSet, SetHighBit, WithoutHighBit): New macros.
>> (pe_print_resource_entries): Rename to
>> rsrc_print_resource_entries. Handle names that are not RVAs.
>> (pe_print_resource_directory): Rename to
>> rsrc_print_resource_directory.
>> (pe_print_rsrc): Rename to rsrc_print_section. Corrupt
>> computation of RVA bias.
>> (rsrc_count_entries): New function.
>> (rsrc_count_directory): New function.
>> (rsrc_parse_entry): New function.
>> (rsrc_parse_entries): New function.
>> (rsrc_parse_directory): New function.
>> (rsrc_write_string): New function.
>> (rsrc_compute_rva): New function.
>> (rsrc_write_leaf): New function.
>> (rsrc_write_entry): New function.
>> (rsrc_write_directory): New function.
>> (u16_mbtouc): New function.
>> (rsrc_cmp): New function.
>> (rsrc_print_name): New function.
>> (rsrc_resource_name): New function.
>> (rsrc_merge_string_entries): New function.
>> (rsrc_sort_entries): New function.
>> (rsrc_attach_chain): New function.
>> (rsrc_merge): New function.
>> (rsrc_process_section): New function - merges the contents of a
>> .rsrc section.
>> (_bfd_XXi_final_link_postscript): Call rsrc_process_section.
>> * configure.in (AC_CHECK_HEADERS): Add wchar.h
>> * config.in: Regenerate.
>> * configure: Regenerate.
>>
>
> With GCC 4.2, I got
>
> peigen.c: In function ‘rsrc_process_section’:
> peigen.c:3522: warning: declaration of ‘index’ shadows a global declaration
> /usr/include/string.h:304: warning: shadowed declaration is here
> make[6]: *** [peigen.lo] Error 1
> make[6]: *** Waiting for unfinished jobs....
> mv -f .deps/pei-i386.Tpo .deps/pei-i386.Plo
> mv -f .deps/elflink.Tpo .deps/elflink.Plo
> mv -f .deps/aout32.Tpo .deps/aout32.Plo
>
>
I checked in this patch to fix it.
--
H.J.
----
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 4df87fe..19596a9 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,7 @@
+2013-12-17 H.J. Lu <hongjiu.lu@intel.com>
+
+ * peXXigen.c (rsrc_process_section): Rename index to indx.
+
2013-12-17 Nick Clifton <nickc@redhat.com>
* peXXigen.c: Include wchar.h if available.
diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c
index cddb38f..5e2a876 100644
--- a/bfd/peXXigen.c
+++ b/bfd/peXXigen.c
@@ -3519,20 +3519,20 @@ rsrc_process_section (bfd * abfd,
if (type_tables == NULL)
goto end;
- unsigned int index = 0;
+ unsigned int indx = 0;
while (data < dataend)
{
bfd_byte * p = data;
- data = rsrc_parse_directory (abfd, type_tables + index, data,
data, dataend,
+ data = rsrc_parse_directory (abfd, type_tables + indx, data,
data, dataend,
rva_bias, NULL);
data = (bfd_byte *) (((long) (data + 3)) & ~ 3);
rva_bias += data - p;
if (data == (dataend - 4))
data = dataend;
- index ++;
+ indx ++;
}
- BFD_ASSERT (index == num_resource_sets);
+ BFD_ASSERT (indx == num_resource_sets);
/* Step three: Merge the top level tables (there can be only one).
@@ -3551,8 +3551,8 @@ rsrc_process_section (bfd * abfd,
new_table.names.first_entry = NULL;
new_table.names.last_entry = NULL;
- for (index = 0; index < num_resource_sets; index++)
- rsrc_attach_chain (& new_table.names, & type_tables[index].names);
+ for (indx = 0; indx < num_resource_sets; indx++)
+ rsrc_attach_chain (& new_table.names, & type_tables[indx].names);
rsrc_sort_entries (& new_table.names, TRUE, & new_table);
@@ -3560,8 +3560,8 @@ rsrc_process_section (bfd * abfd,
new_table.ids.first_entry = NULL;
new_table.ids.last_entry = NULL;
- for (index = 0; index < num_resource_sets; index++)
- rsrc_attach_chain (& new_table.ids, & type_tables[index].ids);
+ for (indx = 0; indx < num_resource_sets; indx++)
+ rsrc_attach_chain (& new_table.ids, & type_tables[indx].ids);
rsrc_sort_entries (& new_table.ids, FALSE, & new_table);