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 21:13:27 -0000 @@ -1,3 +1,7 @@ +2012-05-04 Ben Cheng + + * bfd/elf.c: Preserve the original p_align and p_flags if they are valid. + 2012-05-03 Sean Keys * 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 21:13:27 -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); } else {