aboutsummaryrefslogtreecommitdiff
path: root/gdb/solib-svr4.c
diff options
context:
space:
mode:
authorMichael Spang <spang@google.com>2018-08-19 10:55:58 -0400
committerSimon Marchi <simon.marchi@polymtl.ca>2018-08-19 11:00:39 -0400
commitbe2d111a878e1422c921226bc7714131a5c470fa (patch)
tree08db3b7291d7c9cc082e387f79af5fd04bf9888a /gdb/solib-svr4.c
parentd604f19adeb96f96213f4825e56053fac50723c6 (diff)
downloadgdb-be2d111a878e1422c921226bc7714131a5c470fa.zip
gdb-be2d111a878e1422c921226bc7714131a5c470fa.tar.gz
gdb-be2d111a878e1422c921226bc7714131a5c470fa.tar.bz2
Fix debugging of stripped PIE executables with padded PT_TLS
Certain PIE executables produced by gold cannot be debugged by gdb after being stripped. GDB requires program headers of PIE executables to match, and those checks may fail due to adjustments made during stripping. One case of this occurs because strip recomputes the memsz of PT_TLS and does not add alignment, while gold does. This is another variant of PR 11786, so apply the same fix of relaxing the program header matching. gdb/ChangeLog: PR gdb/11786 * solib-svr4.c (svr4_exec_displacement): Ignore memsz fields for PT_TLS segments. gdb/testsuite/ChangeLog: PR gdb/11786 * gdb.base/gcore-tls-pie.c: New file. * gdb.base/gcore-tls-pie.exp: New file.
Diffstat (limited to 'gdb/solib-svr4.c')
-rw-r--r--gdb/solib-svr4.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index 6f48c68..8458950 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -2709,8 +2709,10 @@ svr4_exec_displacement (CORE_ADDR *displacementp)
/* Strip modifies the flags and alignment of PT_GNU_RELRO.
CentOS-5 has problems with filesz, memsz as well.
+ Strip also modifies memsz of PT_TLS.
See PR 11786. */
- if (phdr2[i].p_type == PT_GNU_RELRO)
+ if (phdr2[i].p_type == PT_GNU_RELRO ||
+ phdr2[i].p_type == PT_TLS)
{
Elf32_External_Phdr tmp_phdr = *phdrp;
Elf32_External_Phdr tmp_phdr2 = *phdr2p;
@@ -2840,8 +2842,10 @@ svr4_exec_displacement (CORE_ADDR *displacementp)
/* Strip modifies the flags and alignment of PT_GNU_RELRO.
CentOS-5 has problems with filesz, memsz as well.
+ Strip also modifies memsz of PT_TLS.
See PR 11786. */
- if (phdr2[i].p_type == PT_GNU_RELRO)
+ if (phdr2[i].p_type == PT_GNU_RELRO ||
+ phdr2[i].p_type == PT_TLS)
{
Elf64_External_Phdr tmp_phdr = *phdrp;
Elf64_External_Phdr tmp_phdr2 = *phdr2p;