2012-05-08 Ben Cheng <bccheng@google.com>
authorDoug Kwan <dougkwan@google.com>
Tue, 8 May 2012 17:18:21 +0000 (17:18 +0000)
committerDoug Kwan <dougkwan@google.com>
Tue, 8 May 2012 17:18:21 +0000 (17:18 +0000)
* bfd/elf.c: Preserve the original p_align and p_flags if they are
valid.

bfd/ChangeLog
bfd/elf.c

index f695aef0d4a70f1554f062b60c961e5526846415..4c49cf9b59d68fe9a4b46e2768037c6687663d42 100644 (file)
@@ -1,3 +1,8 @@
+2012-05-08  Ben Cheng  <bccheng@google.com>
+
+       * bfd/elf.c: Preserve the original p_align and p_flags if they are
+       valid.
+
 2012-05-07  Alan Modra  <amodra@gmail.com>
 
        * elf64-ia64-vms.c (elf64_ia64_relocate_section): Update
index d040d1470001b93754a2ced767d268c99961d07f..9481c0e1d5692d430426224286440c36e2d39007 100644 (file)
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -4931,8 +4931,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 using separate debug files. */
+          if (!m->p_align_valid)
+            p->p_align = 1;
+          if (!m->p_flags_valid)
+            p->p_flags = (lp->p_flags & ~PF_W);
            }
          else
            {