aboutsummaryrefslogtreecommitdiff
path: root/gdb/solib-svr4.c
diff options
context:
space:
mode:
authorDoug Evans <dje@google.com>2013-11-07 16:43:39 -0800
committerDoug Evans <dje@google.com>2013-11-07 16:43:39 -0800
commit204b53315d81361b008036d93c355ab1f2a44997 (patch)
tree408c2b581fa9aa038f4a040b2b6b37a2e7b08e1e /gdb/solib-svr4.c
parent459d52c84aa5eee986006b793794e382861c073d (diff)
downloadgdb-204b53315d81361b008036d93c355ab1f2a44997.zip
gdb-204b53315d81361b008036d93c355ab1f2a44997.tar.gz
gdb-204b53315d81361b008036d93c355ab1f2a44997.tar.bz2
PR 11786
* solib-svr4.c (svr4_exec_displacement): Ignore filesz, memsz, flags and align fields for PT_GNU_RELRO segments. testsuite/ * gdb.base/gcore-relro-pie.c: New file. * gdb.base/gcore-relro-pie.exp: New file.
Diffstat (limited to 'gdb/solib-svr4.c')
-rw-r--r--gdb/solib-svr4.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index 3eea057..9538af6 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -2604,6 +2604,28 @@ svr4_exec_displacement (CORE_ADDR *displacementp)
if (memcmp (phdrp, phdr2p, sizeof (*phdrp)) == 0)
continue;
+ /* Strip modifies the flags and alignment of PT_GNU_RELRO.
+ CentOS-5 has problems with filesz, memsz as well.
+ See PR 11786. */
+ if (phdr2[i].p_type == PT_GNU_RELRO)
+ {
+ Elf32_External_Phdr tmp_phdr = *phdrp;
+ Elf32_External_Phdr tmp_phdr2 = *phdr2p;
+
+ memset (tmp_phdr.p_filesz, 0, 4);
+ memset (tmp_phdr.p_memsz, 0, 4);
+ memset (tmp_phdr.p_flags, 0, 4);
+ memset (tmp_phdr.p_align, 0, 4);
+ memset (tmp_phdr2.p_filesz, 0, 4);
+ memset (tmp_phdr2.p_memsz, 0, 4);
+ memset (tmp_phdr2.p_flags, 0, 4);
+ memset (tmp_phdr2.p_align, 0, 4);
+
+ if (memcmp (&tmp_phdr, &tmp_phdr2, sizeof (tmp_phdr))
+ == 0)
+ continue;
+ }
+
/* prelink can convert .plt SHT_NOBITS to SHT_PROGBITS. */
plt2_asect = bfd_get_section_by_name (exec_bfd, ".plt");
if (plt2_asect)
@@ -2713,6 +2735,28 @@ svr4_exec_displacement (CORE_ADDR *displacementp)
if (memcmp (phdrp, phdr2p, sizeof (*phdrp)) == 0)
continue;
+ /* Strip modifies the flags and alignment of PT_GNU_RELRO.
+ CentOS-5 has problems with filesz, memsz as well.
+ See PR 11786. */
+ if (phdr2[i].p_type == PT_GNU_RELRO)
+ {
+ Elf64_External_Phdr tmp_phdr = *phdrp;
+ Elf64_External_Phdr tmp_phdr2 = *phdr2p;
+
+ memset (tmp_phdr.p_filesz, 0, 8);
+ memset (tmp_phdr.p_memsz, 0, 8);
+ memset (tmp_phdr.p_flags, 0, 4);
+ memset (tmp_phdr.p_align, 0, 8);
+ memset (tmp_phdr2.p_filesz, 0, 8);
+ memset (tmp_phdr2.p_memsz, 0, 8);
+ memset (tmp_phdr2.p_flags, 0, 4);
+ memset (tmp_phdr2.p_align, 0, 8);
+
+ if (memcmp (&tmp_phdr, &tmp_phdr2, sizeof (tmp_phdr))
+ == 0)
+ continue;
+ }
+
/* prelink can convert .plt SHT_NOBITS to SHT_PROGBITS. */
plt2_asect = bfd_get_section_by_name (exec_bfd, ".plt");
if (plt2_asect)