This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: PATCH: PR binutils/3281: objcopy changes PT_GNU_RELRO when there is PT_TLS
On Mon, Oct 23, 2006 at 10:55:59PM -0700, H. J. Lu wrote:
> + if (p->p_type == PT_GNU_RELRO)
> + {
> + /* When we get here, we are copying executable
> + or shared library. But we need to use the same
> + linker logic. */
> + Elf_Internal_Phdr *lp;
> +
> + for (lp = phdrs; lp < phdrs + count; ++lp)
> + {
> + if (lp->p_type == PT_LOAD
> + && lp->p_paddr == p->p_paddr)
> + break;
> + }
> +
> + if (lp < phdrs + count)
> + {
> + p->p_filesz += p->p_vaddr - lp->p_vaddr;
> + p->p_vaddr = lp->p_vaddr;
> + p->p_offset = lp->p_offset;
> + p->p_memsz = p->p_filesz;
> + p->p_align = 1;
> + }
> + else
> + abort ();
> + }
I don't think this is going to work in all cases. objcopy can do some
really nasty things as far as GNU_RELRO segment is concerned, deleting
sections, adding sections, changing section lmas. I think instead
you should set the GNU_RELRO segment info from the section map, and
try to get the section map correct in rewrite_elf_program_header. I
noticed at least one problem with rewrite_elf_program_header "Step
Three": It should not be allowed to split a GNU_RELRO segment into
two due to gaps.
> +lang_size_relro_sections (void)
Should probably be called lang_find_relro_sections. You aren't doing
any sizing here.
--
Alan Modra
IBM OzLabs - Linux Technology Centre