diff options
author | Ben Cheng <bccheng@google.com> | 2012-10-30 17:14:35 -0700 |
---|---|---|
committer | Ben Cheng <bccheng@google.com> | 2012-10-30 17:22:06 -0700 |
commit | 9a293bee6360288fc2c6dad7fc02e1c326bd8fb9 (patch) | |
tree | 0fad1c2cfb4dd38293b8426fe4b3667522e4a4e7 | |
parent | 567dd0efbbea8ef969b42bfb4381df3d50717202 (diff) | |
download | toolchain_binutils-9a293bee6360288fc2c6dad7fc02e1c326bd8fb9.tar.gz toolchain_binutils-9a293bee6360288fc2c6dad7fc02e1c326bd8fb9.tar.bz2 toolchain_binutils-9a293bee6360288fc2c6dad7fc02e1c326bd8fb9.zip |
Backport the objcopy/strip flag preservation change to binutils-2.22.
2012-05-04 Ben Cheng <bccheng@google.com>
* bfd/elf.c: Preserve the original p_align and p_flags if they are valid.
Change-Id: I5237b8b5ee89edb9e1bfabe47db85eaba84167fd
-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 { |