View | Details | Return to bug 69880 | Differences between
and this patch

Collapse All | Expand All

(-)a/bfd/peXXigen.c (-16 / +22 lines)
Lines 4097-4102 rsrc_process_section (bfd * abfd, Link Here
4097
  unsigned int      num_input_rsrc = 0;
4097
  unsigned int      num_input_rsrc = 0;
4098
  unsigned int      max_num_input_rsrc = 4;
4098
  unsigned int      max_num_input_rsrc = 4;
4099
  ptrdiff_t *       rsrc_sizes = NULL;
4099
  ptrdiff_t *       rsrc_sizes = NULL;
4100
  unsigned long     page_size;
4101
4100
4102
4101
  new_table.names.num_entries = 0;
4103
  new_table.names.num_entries = 0;
4102
  new_table.ids.num_entries = 0;
4104
  new_table.ids.num_entries = 0;
Lines 4139-4145 rsrc_process_section (bfd * abfd, Link Here
4139
    {
4141
    {
4140
      asection * rsrc_sec = bfd_get_section_by_name (input, ".rsrc");
4142
      asection * rsrc_sec = bfd_get_section_by_name (input, ".rsrc");
4141
4143
4142
      if (rsrc_sec != NULL)
4144
      /* PR 18372 - skip discarded .rsrc sections.  */
4145
      if (rsrc_sec != NULL && !discarded_section (rsrc_sec))
4143
	{
4146
	{
4144
	  if (num_input_rsrc == max_num_input_rsrc)
4147
	  if (num_input_rsrc == max_num_input_rsrc)
4145
	    {
4148
	    {
Lines 4274-4295 rsrc_process_section (bfd * abfd, Link Here
4274
     We recompute the size as we may have lost entries due to mergeing.  */
4277
     We recompute the size as we may have lost entries due to mergeing.  */
4275
  size = ((write_data.next_data - new_data) + 3) & ~ 3;
4278
  size = ((write_data.next_data - new_data) + 3) & ~ 3;
4276
4279
4277
  {
4280
  if (coff_data (abfd)->link_info)
4278
    int page_size;
4281
    {
4279
4282
      page_size = pe_data (abfd)->pe_opthdr.FileAlignment;
4280
    if (coff_data (abfd)->link_info)
4281
      {
4282
	page_size = pe_data (abfd)->pe_opthdr.FileAlignment;
4283
4283
4284
	/* If no file alignment has been set, default to one.
4284
      /* If no file alignment has been set, default to one.
4285
	   This repairs 'ld -r' for arm-wince-pe target.  */
4285
	 This repairs 'ld -r' for arm-wince-pe target.  */
4286
	if (page_size == 0)
4286
      if (page_size == 0)
4287
	  page_size = 1;
4287
	page_size = 1;
4288
      }
4288
    }
4289
    else
4289
  else
4290
      page_size = PE_DEF_FILE_ALIGNMENT;
4290
    page_size = PE_DEF_FILE_ALIGNMENT;
4291
    size = (size + page_size - 1) & - page_size;
4291
4292
  }
4292
  size = (size + page_size - 1) & - page_size;
4293
  /* PR gcc/69880: We must ensure that there are no gaps between the end
4294
     of the .rsrc section and whichever section comes next in the file.
4295
     This does mean that we can end up with a lot of unused space at
4296
     the end of the .rsrc section, but at least this way works.  */
4297
  if (sec->next && sec->next->filepos > (file_ptr)(sec->filepos + size))
4298
    size = sec->next->filepos - sec->filepos;
4293
4299
4294
  bfd_set_section_contents (pfinfo->output_bfd, sec, new_data, 0, size);
4300
  bfd_set_section_contents (pfinfo->output_bfd, sec, new_data, 0, size);
4295
  sec->size = sec->rawsize = size;
4301
  sec->size = sec->rawsize = size;

Return to bug 69880