binutils-gdb/gdb/testsuite/gdb.base/gcore-tls-pie.c
Michael Spang be2d111a87 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.
2018-08-19 11:00:39 -04:00

49 lines
1.1 KiB
C

/* Copyright 2013-2018 Free Software Foundation, Inc.
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* The size of these variables is chosen so that gold will add some padding
to the TLS program header (total size of 16 bytes on x86_64) which strip
will remove (bringing it down to 9 bytes). */
__thread long j;
__thread char i;
void
break_here (void)
{
*(int *) 0 = 0;
}
void
foo (void)
{
break_here ();
}
void
bar (void)
{
foo ();
}
int
main (void)
{
bar ();
return 0;
}