diff options
-rw-r--r-- | binutils-2.22/bfd/elf.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/binutils-2.22/bfd/elf.c b/binutils-2.22/bfd/elf.c index aa40c339..c0bcaacd 100644 --- a/binutils-2.22/bfd/elf.c +++ b/binutils-2.22/bfd/elf.c @@ -4926,8 +4926,14 @@ assign_file_positions_for_non_load_sections (bfd *abfd, 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 { |