This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: Preserve the original p_align and p_flags if they are valid


Plain text of patch attached.

On Fri, May 4, 2012 at 1:59 PM, Ben Cheng <bccheng@google.com> wrote:
> Objcopy/strip will unconditionally change the flag to R and alignment
> to 1 for the PT_GNU_RELRO section, but sometimes the Gold linker mark
> them as RW with alignment of 4. This patch will preserve these
> attributes when they are marked as valid.
>
> Thanks,
> -Ben
>
> Index: bfd/ChangeLog
> ===================================================================
> RCS file: /cvs/src/src/bfd/ChangeLog,v
> retrieving revision 1.5667
> diff -u -r1.5667 ChangeLog
> --- bfd/ChangeLog 3 May 2012 13:11:53 -0000 1.5667
> +++ bfd/ChangeLog 4 May 2012 20:50:05 -0000
> @@ -1,3 +1,7 @@
> +2012-05-04 ?Ben Cheng ?<bccheng@google.com>
> +
> + ? ?* bfd/elf.c: Preserve the original p_align and p_flags if they are valid.
> +
> ?2012-05-03 ?Sean Keys ?<skeys@ipdatasys.com>
>
> ? * cpu-xgate.c: New file. Added XGATE support.
> Index: bfd/elf.c
> ===================================================================
> RCS file: /cvs/src/src/bfd/elf.c,v
> retrieving revision 1.552
> diff -u -r1.552 elf.c
> --- bfd/elf.c 24 Apr 2012 05:12:30 -0000 1.552
> +++ bfd/elf.c 4 May 2012 20:50:05 -0000
> @@ -4931,8 +4931,14 @@
> ? ? ? ?else
> ? abort ();
> ? ? ? ?p->p_memsz = p->p_filesz;
> - ? ? ?p->p_align = 1;
> - ? ? ?p->p_flags = (lp->p_flags & ~PF_W);
> + ? ? ? ? ?/* Preserve the alignment and flags if they are valid. The gold
> + ? ? ? ? ? ? linker generates RW/4 for the PT_GNU_RELRO section. It is better
> + ? ? ? ? ? ? for objcopy/strip to honor these attributes otherwise gdb will
> + ? ? ? ? ? ? choke when doing cross-debugging. */
> + ? ? ? ? ?if (!m->p_align_valid)
> + ? ? ? ? ? ?p->p_align = 1;
> + ? ? ? ? ?if (!m->p_flags_valid)
> + ? ? ? ? ? ?p->p_flags = (lp->p_flags & ~PF_W);

Attachment: patch.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]