binutils/assign-file-positions.diff

49 lines
1.5 KiB
Diff

2008-11-07 Andreas Schwab <schwab@suse.de>
PR 7011
* elf.c (assign_file_positions_for_non_load_sections): Handle
PT_GNU_RELRO that covers only a part of a single section.
--- bfd/elf.c.~1.466.~ 2008-10-09 11:07:35.000000000 +0200
+++ bfd/elf.c 2008-11-07 11:32:56.000000000 +0100
@@ -4631,7 +4631,9 @@ assign_file_positions_for_non_load_secti
m != NULL;
m = m->next, p++)
{
- if (m->count != 0)
+ if (m->count != 0
+ /* Always handle PT_GNU_RELRO here if not linking. */
+ || (p->p_type == PT_GNU_RELRO && link_info == NULL))
{
if (p->p_type != PT_LOAD
&& (p->p_type != PT_NOTE
@@ -4642,12 +4644,6 @@ assign_file_positions_for_non_load_secti
BFD_ASSERT (!m->includes_filehdr && !m->includes_phdrs);
- sect = m->sections[m->count - 1];
- hdr = &elf_section_data (sect)->this_hdr;
- p->p_filesz = sect->filepos - m->sections[0]->filepos;
- if (hdr->sh_type != SHT_NOBITS)
- p->p_filesz += hdr->sh_size;
-
if (p->p_type == PT_GNU_RELRO)
{
/* When we get here, we are copying executable
@@ -4680,7 +4676,14 @@ assign_file_positions_for_non_load_secti
abort ();
}
else
- p->p_offset = m->sections[0]->filepos;
+ {
+ sect = m->sections[m->count - 1];
+ hdr = &elf_section_data (sect)->this_hdr;
+ p->p_filesz = sect->filepos - m->sections[0]->filepos;
+ if (hdr->sh_type != SHT_NOBITS)
+ p->p_filesz += hdr->sh_size;
+ p->p_offset = m->sections[0]->filepos;
+ }
}
}
else