binutils-gdb/gdb/nat
Pedro Alves 4655f8509f Don't run personality syscall at configure time; don't check it at all
Currently, in order to tell whether support for disabling address
space randomization on Linux is available, GDB checks if the
personality syscall works, at configure time.  I.e., it does a run
test, instead of a compile/link test:

  AC_RUN_IFELSE([PERSONALITY_TEST],
		[have_personality=true],
		[have_personality=false],

This is a bit bogus, because the machine the build is done on may not
(and is when you consider distro gdbs) be the machine that eventually
runs gdb.  It would be better if this were a compile/link test
instead, and then at runtime, GDB coped with the personality syscall
failing.  Actually, GDB already copes.

One environment where this is problematic is building GDB in a Docker
container -- by default, Docker runs the container with seccomp, with
a profile that disables the personality syscall.  You can tell Docker
to use a less restricted seccomp profile, but I think we should just
fix it in GDB.

"man 2 personality" says:

       This system call first appeared in Linux 1.1.20 (and thus first
       in a stable kernel release with Linux 1.2.0); library support
       was added in glibc 2.3.

...

       ADDR_NO_RANDOMIZE (since Linux 2.6.12)
              With this flag set, disable address-space-layout randomization.

glibc 2.3 was released in 2002.
Linux 2.6.12 was released in 2005.

The original patch that added the configure checks was submitted in
2008.  The first version of the patch that was submitted to the list
called personality from common code:

 https://sourceware.org/pipermail/gdb-patches/2008-June/058204.html

and then was moved to Linux-specific code:

 https://sourceware.org/pipermail/gdb-patches/2008-June/058209.html

Since HAVE_PERSONALITY is only checked in Linux code, and
ADDR_NO_RANDOMIZE exists for over 15 years, I propose just completely
removing the configure checks.

If for some odd reason, some remotely modern system still needs a
configure check, then we can revert this commit but drop the
AC_RUN_IFELSE in favor of always doing the AC_LINK_IFELSE
cross-compile fallback.

gdb/ChangeLog:

	* linux-nat.c (linux_nat_target::supports_disable_randomization):
	Remove references to HAVE_PERSONALITY.
	* nat/linux-personality.c: Remove references to HAVE_PERSONALITY.
	(maybe_disable_address_space_randomization)
	(~maybe_disable_address_space_randomizatio): Remove references to
	HAVE_PERSONALITY.
	* config.in, configure: Regenerate.

gdbserver/ChangeLog:

	* linux-low.cc:
	(linux_process_target::supports_disable_randomization): Remove
	reference to HAVE_PERSONALITY.
	* config.in, configure: Regenerate.

gdbsupport/ChangeLog:

	* common.m4 (personality test): Remove.
2021-05-08 13:45:36 +01:00
..
aarch64-linux-hw-point.c Add comment regarding include order of <sys/ptrace.h> and <asm/ptrace.h> 2021-02-24 14:35:07 -07:00
aarch64-linux-hw-point.h Update copyright year range in all GDB files 2021-01-01 12:12:21 +04:00
aarch64-linux.c Update copyright year range in all GDB files 2021-01-01 12:12:21 +04:00
aarch64-linux.h Update copyright year range in all GDB files 2021-01-01 12:12:21 +04:00
aarch64-mte-linux-ptrace.c [AArch64] Fix include order for MTE 2021-04-09 11:36:55 -03:00
aarch64-mte-linux-ptrace.h AArch64: Implement memory tagging target methods for AArch64 2021-03-24 14:53:56 -03:00
aarch64-sve-linux-ptrace.c Update copyright year range in all GDB files 2021-01-01 12:12:21 +04:00
aarch64-sve-linux-ptrace.h Add comment regarding include order of <sys/ptrace.h> and <asm/ptrace.h> 2021-02-25 15:30:32 -07:00
aarch64-sve-linux-sigcontext.h Update copyright year range in all GDB files 2021-01-01 12:12:21 +04:00
amd64-linux-siginfo.c amd64-linux-siginfo.c: Adjust include order to avoid gnulib error 2021-02-18 22:56:56 -07:00
amd64-linux-siginfo.h Update copyright year range in all GDB files 2021-01-01 12:12:21 +04:00
fork-inferior.c Update copyright year range in all GDB files 2021-01-01 12:12:21 +04:00
fork-inferior.h Update copyright year range in all GDB files 2021-01-01 12:12:21 +04:00
gdb_ptrace.h Update copyright year range in all GDB files 2021-01-01 12:12:21 +04:00
gdb_thread_db.h Update copyright year range in all GDB files 2021-01-01 12:12:21 +04:00
glibc_thread_db.h
linux-btrace.c Update copyright year range in all GDB files 2021-01-01 12:12:21 +04:00
linux-btrace.h Update copyright year range in all GDB files 2021-01-01 12:12:21 +04:00
linux-namespaces.c Update copyright year range in all GDB files 2021-01-01 12:12:21 +04:00
linux-namespaces.h Update copyright year range in all GDB files 2021-01-01 12:12:21 +04:00
linux-nat.h Update copyright year range in all GDB files 2021-01-01 12:12:21 +04:00
linux-osdata.c gdb: make some variables static 2021-01-20 20:55:05 -05:00
linux-osdata.h Update copyright year range in all GDB files 2021-01-01 12:12:21 +04:00
linux-personality.c Don't run personality syscall at configure time; don't check it at all 2021-05-08 13:45:36 +01:00
linux-personality.h Update copyright year range in all GDB files 2021-01-01 12:12:21 +04:00
linux-procfs.c Update copyright year range in all GDB files 2021-01-01 12:12:21 +04:00
linux-procfs.h Update copyright year range in all GDB files 2021-01-01 12:12:21 +04:00
linux-ptrace.c Update copyright year range in all GDB files 2021-01-01 12:12:21 +04:00
linux-ptrace.h Update copyright year range in all GDB files 2021-01-01 12:12:21 +04:00
linux-waitpid.c Update copyright year range in all GDB files 2021-01-01 12:12:21 +04:00
linux-waitpid.h Update copyright year range in all GDB files 2021-01-01 12:12:21 +04:00
mips-linux-watch.c Update copyright year range in all GDB files 2021-01-01 12:12:21 +04:00
mips-linux-watch.h Update copyright year range in all GDB files 2021-01-01 12:12:21 +04:00
netbsd-nat.c Update copyright year range in all GDB files 2021-01-01 12:12:21 +04:00
netbsd-nat.h Update copyright year range in all GDB files 2021-01-01 12:12:21 +04:00
ppc-linux.c Update copyright year range in all GDB files 2021-01-01 12:12:21 +04:00
ppc-linux.h Update copyright year range in all GDB files 2021-01-01 12:12:21 +04:00
riscv-linux-tdesc.c Update copyright year range in all GDB files 2021-01-01 12:12:21 +04:00
riscv-linux-tdesc.h Update copyright year range in all GDB files 2021-01-01 12:12:21 +04:00
windows-nat.c Make get_image_name static 2021-04-30 10:22:24 -06:00
windows-nat.h Make get_image_name static 2021-04-30 10:22:24 -06:00
x86-cpuid.h Update copyright year range in all GDB files 2021-01-01 12:12:21 +04:00
x86-dregs.c Update copyright year range in all GDB files 2021-01-01 12:12:21 +04:00
x86-dregs.h Update copyright year range in all GDB files 2021-01-01 12:12:21 +04:00
x86-gcc-cpuid.h Update copyright year range in all GDB files 2021-01-01 12:12:21 +04:00
x86-linux-dregs.c Update copyright year range in all GDB files 2021-01-01 12:12:21 +04:00
x86-linux-dregs.h Update copyright year range in all GDB files 2021-01-01 12:12:21 +04:00
x86-linux.c Update copyright year range in all GDB files 2021-01-01 12:12:21 +04:00
x86-linux.h Update copyright year range in all GDB files 2021-01-01 12:12:21 +04:00